diff --git a/awx/ui/test/e2e/commands/logout.js b/awx/ui/test/e2e/commands/logout.js new file mode 100644 index 0000000000..2eba1f985d --- /dev/null +++ b/awx/ui/test/e2e/commands/logout.js @@ -0,0 +1,11 @@ +/** + * Logout from the current session by clicking on the power off button on the + * navigation menu. + */ +exports.command = function logout () { + const logoutButton = '.at-Layout-topNav i.fa-power-off'; + this + .waitForElementVisible(logoutButton) + .click(logoutButton) + .waitForElementPresent('#login-button'); +}; diff --git a/awx/ui/test/e2e/objects/users.js b/awx/ui/test/e2e/objects/users.js index b87d43e9b9..716d8e3346 100644 --- a/awx/ui/test/e2e/objects/users.js +++ b/awx/ui/test/e2e/objects/users.js @@ -9,6 +9,8 @@ import pagination from './sections/pagination'; import permissions from './sections/permissions'; import search from './sections/search'; +const row = '#users_table .List-tableRow'; + const details = createFormSection({ selector: 'form', props: { @@ -40,6 +42,15 @@ module.exports = { this.api.url('data:,'); // https://github.com/nightwatchjs/nightwatch/issues/1724 return this.navigate(); }, + search (username) { + this.section.list.section.search + .setValue('@input', username) + .click('@searchButton'); + this.waitForSpinny(); + this.waitForElementNotPresent(`${row}:nth-of-type(2)`); + this.expect.element('.List-titleBadge').text.to.contain('1'); + this.expect.element(row).text.contain(username); + }, }], sections: { header, diff --git a/awx/ui/test/e2e/tests/test-users-crud.js b/awx/ui/test/e2e/tests/test-users-crud.js index fe778f3e34..69579f6cd7 100644 --- a/awx/ui/test/e2e/tests/test-users-crud.js +++ b/awx/ui/test/e2e/tests/test-users-crud.js @@ -47,25 +47,13 @@ module.exports = { .setValue('@confirmPassword', store.user.password) .click('@save'); client.waitForSpinny(); - users.section.list.section.search - .setValue('@input', store.user.username) - .click('@searchButton'); - client.waitForSpinny(); - users.waitForElementNotPresent(`${row}:nth-of-type(2)`); - users.expect.element('.List-titleBadge').text.to.contain('1'); - users.expect.element(row).text.contain(store.user.username); + users.search(store.user.username); }, 'edit an user': client => { const users = client.page.users(); users.load(); client.waitForSpinny(); - users.section.list.section.search - .setValue('@input', store.user.username) - .click('@searchButton'); - client.waitForSpinny(); - users.waitForElementNotPresent(`${row}:nth-of-type(2)`); - users.expect.element('.List-titleBadge').text.to.contain('1'); - users.expect.element(row).text.contain(store.user.username); + users.search(store.user.username); const editButton = `${row} i[class*="fa-pencil"]`; users.waitForElementVisible(editButton).click(editButton); users.section.edit @@ -74,13 +62,33 @@ module.exports = { .setValue('@lastName', store.user.lastName) .click('@save'); client.waitForSpinny(); - users.section.list.section.search - .setValue('@input', store.user.username) - .click('@searchButton'); - client.waitForSpinny(); - users.waitForElementNotPresent(`${row}:nth-of-type(2)`); + users.search(store.user.username); users.expect.element(row).text.contain(`${store.user.username}\n${store.user.firstName[0].toUpperCase() + store.user.firstName.slice(1)}\n${store.user.lastName}`); }, + 'check if the new user can login': (client) => { + client.logout(); + client.login(store.user.username, store.user.password); + client.logout(); + client.login(); + }, + 'delete the user': (client) => { + const users = client.page.users(); + users.load(); + client.waitForSpinny(); + users.search(store.user.username); + const deleteButton = `${row} i[class*="fa-trash-o"]`; + const modalAction = '.modal-dialog #prompt_action_btn'; + users + .waitForElementVisible(deleteButton) + .click(deleteButton) + .waitForElementVisible(modalAction) + .click(modalAction) + .waitForSpinny(); + const searchResults = '.List-searchNoResults'; + users + .waitForElementVisible(searchResults) + .expect.element(searchResults).text.contain('No records matched your search.'); + }, after: client => { client.end(); },