users e2e

This commit is contained in:
Elyézer Rezende 2019-03-19 15:22:02 -04:00
parent 3d9a47f0d9
commit 46ad3fa7b1
3 changed files with 49 additions and 19 deletions

View File

@ -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');
};

View File

@ -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,

View File

@ -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();
},