Skip to content

Commit

Permalink
Fixes hint/lint errors in workflow viz test
Browse files Browse the repository at this point in the history
  • Loading branch information
mabashian committed Nov 27, 2018
1 parent 17cc82d commit 51669c9
Showing 1 changed file with 38 additions and 44 deletions.
82 changes: 38 additions & 44 deletions awx/ui/test/e2e/tests/test-workflow-visualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const workflowSearchBar = "//input[contains(@class, 'SmartSearch-input')]";
const workflowText = 'name.iexact:"test-actions-workflow-template"';
const workflowSearchBadgeCount = '//span[contains(@class, "at-Panel-headingTitleBadge") and contains(text(), "1")]';

const startNodeId = "1";
const startNodeId = '1';
let initialJobNodeId;
let initialProjectNodeId;
let initialInventoryNodeId;
Expand Down Expand Up @@ -44,13 +44,8 @@ const linkSelectButton = "//*[@id='workflow_maker_select_link_btn']";
const nodeCancelButton = "//*[@id='workflow_maker_cancel_node_btn']";
const deleteConfirmation = "//button[@ng-click='confirmDeleteNode()']";

const xPathNodeById = (id) => {
return `//*[@id='node-${id}']`;
};

const xPathLinkById = (sourceId, targetId) => {
return `//*[@id='link-${sourceId}-${targetId}']//*[contains(@class, 'WorkflowChart-linkPath')]`;
};
const xPathNodeById = (id) => `//*[@id='node-${id}']`;
const xPathLinkById = (sourceId, targetId) => `//*[@id='link-${sourceId}-${targetId}']//*[contains(@class, 'WorkflowChart-linkPath')]`;

module.exports = {
before: (client, done) => {
Expand Down Expand Up @@ -83,14 +78,14 @@ module.exports = {
.waitForElementVisible('//*[contains(@class, "WorkflowChart-nameText") and contains(text(), "test-actions-job")]/..');

// Grab the ids of the nodes
client.getAttribute('//*[contains(@class, "WorkflowChart-nameText") and contains(text(), "test-actions-job")]/..', 'id', function(res) {
initialJobNodeId = res.value.split('-')[1];
client.getAttribute('//*[contains(@class, "WorkflowChart-nameText") and contains(text(), "test-actions-job")]/..', 'id', (res) => {
initialJobNodeId = res.value.split('-')[1];
});
client.getAttribute('//*[contains(@class, "WorkflowChart-nameText") and contains(text(), "test-actions-project")]/..', 'id', function(res) {
initialProjectNodeId = res.value.split('-')[1];
client.getAttribute('//*[contains(@class, "WorkflowChart-nameText") and contains(text(), "test-actions-project")]/..', 'id', (res) => {
initialProjectNodeId = res.value.split('-')[1];
});
client.getAttribute('//*[contains(@class, "WorkflowChart-nameText") and contains(text(), "test-actions-inventory")]/..', 'id', function(res) {
initialInventoryNodeId = res.value.split('-')[1];
client.getAttribute('//*[contains(@class, "WorkflowChart-nameText") and contains(text(), "test-actions-inventory")]/..', 'id', (res) => {
initialInventoryNodeId = res.value.split('-')[1];
});
},
'verify that workflow visualizer new root node can only be set to always': client => {
Expand Down Expand Up @@ -134,8 +129,8 @@ module.exports = {
.waitForElementNotVisible(spinny);

// Grab the id of the new child node for later
client.getAttribute('//*[contains(@class, "WorkflowChart-isNodeBeingAdded")]/..', 'id', function(res) {
newChildNodeId = res.value.split('-')[1];
client.getAttribute('//*[contains(@class, "WorkflowChart-isNodeBeingAdded")]/..', 'id', (res) => {
newChildNodeId = res.value.split('-')[1];
});

client
Expand Down Expand Up @@ -163,35 +158,34 @@ module.exports = {
.waitForElementNotVisible(spinny);

// Grab the id of the new child node for later
client.getAttribute('//*[contains(@class, "WorkflowChart-isNodeBeingAdded")]/..', 'id', function(res) {
// I had to nest this logic in order to ensure that leafNodeId was available later on.
// Separating this out resulted in leafNodeId being `undefined` when sent to xPathLinkById
leafNodeId = res.value.split('-')[1];
client
.clearValue(jobSearchBar)
.setValue(jobSearchBar, [testActionsJobText, client.Keys.ENTER])
.pause(1000)
.findThenClick(testActionsJob)
.pause(1000)
.waitForElementNotVisible(spinny)
.findThenClick(edgeTypeDropdownBar)
.waitForElementPresent(successDropdown)
.waitForElementPresent(failureDropdown)
.waitForElementPresent(alwaysDropdown)
.findThenClick(alwaysDropdown)
.click(nodeSelectButton)
.moveToElement(xPathNodeById(newChildNodeId), 0, 0, () => {
client.pause(500);
client.waitForElementNotVisible(spinny);
client.click(xPathNodeById(newChildNodeId) + nodeRemove);
})
.pause(1000)
.waitForElementNotVisible(spinny)
.findThenClick(deleteConfirmation)
.waitForElementVisible(xPathLinkById(initialJobNodeId, leafNodeId));
client.getAttribute('//*[contains(@class, "WorkflowChart-isNodeBeingAdded")]/..', 'id', (res) => {
// I had to nest this logic in order to ensure that leafNodeId was available later on.
// Separating this out resulted in leafNodeId being `undefined` when sent to
// xPathLinkById
leafNodeId = res.value.split('-')[1];
client
.clearValue(jobSearchBar)
.setValue(jobSearchBar, [testActionsJobText, client.Keys.ENTER])
.pause(1000)
.findThenClick(testActionsJob)
.pause(1000)
.waitForElementNotVisible(spinny)
.findThenClick(edgeTypeDropdownBar)
.waitForElementPresent(successDropdown)
.waitForElementPresent(failureDropdown)
.waitForElementPresent(alwaysDropdown)
.findThenClick(alwaysDropdown)
.click(nodeSelectButton)
.moveToElement(xPathNodeById(newChildNodeId), 0, 0, () => {
client.pause(500);
client.waitForElementNotVisible(spinny);
client.click(xPathNodeById(newChildNodeId) + nodeRemove);
})
.pause(1000)
.waitForElementNotVisible(spinny)
.findThenClick(deleteConfirmation)
.waitForElementVisible(xPathLinkById(initialJobNodeId, leafNodeId));
});


},
after: client => {
client.end();
Expand Down

0 comments on commit 51669c9

Please sign in to comment.