Merge pull request #3528 from elyezer/e2e-users

Add auditor and admin params to user e2e

Reviewed-by: Elyézer Rezende
             https://github.com/elyezer
This commit is contained in:
softwarefactory-project-zuul[bot]
2019-04-01 19:30:39 +00:00
committed by GitHub
2 changed files with 104 additions and 29 deletions

View File

@@ -31,6 +31,7 @@ const addEditElements = {
password: '#user_password_input', password: '#user_password_input',
save: '#user_save_btn', save: '#user_save_btn',
username: '#user_username', username: '#user_username',
type: '#select2-user_user_type-container',
}; };
module.exports = { module.exports = {
@@ -42,6 +43,46 @@ module.exports = {
this.api.url('data:,'); // https://github.com/nightwatchjs/nightwatch/issues/1724 this.api.url('data:,'); // https://github.com/nightwatchjs/nightwatch/issues/1724
return this.navigate(); return this.navigate();
}, },
create (user, organization) {
this.section.list
.waitForElementVisible('@add')
.click('@add');
this.section.add
.waitForElementVisible('@title')
.setValue('@organization', organization.name)
.setValue('@email', user.email)
.setValue('@username', user.username)
.setValue('@password', user.password)
.setValue('@confirmPassword', user.password);
if (user.firstName) {
this.section.add.setValue('@firstName', user.firstName);
}
if (user.lastName) {
this.section.add.setValue('@lastName', user.lastName);
}
if (user.type) {
this.section.add
.click('@type')
.click(`li[id$=${user.type}]`);
}
this.section.add.click('@save');
this.waitForSpinny();
},
delete (username) {
this.search(username);
const deleteButton = `${row} i[class*="fa-trash-o"]`;
const modalAction = '.modal-dialog #prompt_action_btn';
this
.waitForElementVisible(deleteButton)
.click(deleteButton)
.waitForElementVisible(modalAction)
.click(modalAction)
.waitForSpinny();
const searchResults = '.List-searchNoResults';
this
.waitForElementVisible(searchResults)
.expect.element(searchResults).text.contain('No records matched your search.');
},
search (username) { search (username) {
this.section.list.section.search this.section.list.section.search
.setValue('@input', username) .setValue('@input', username)

View File

@@ -8,12 +8,29 @@ const store = {
organization: { organization: {
name: `org-${testID}` name: `org-${testID}`
}, },
admin: {
email: `email-admin-${testID}@example.com`,
firstName: `first-admin-${testID}`,
lastName: `last-admin-${testID}`,
password: `admin-${testID}`,
username: `admin-${testID}`,
type: 'administrator',
},
auditor: {
email: `email-auditor-${testID}@example.com`,
firstName: `first-auditor-${testID}`,
lastName: `last-auditor-${testID}`,
password: `auditor-${testID}`,
username: `auditor-${testID}`,
type: 'auditor',
},
user: { user: {
email: `email-${testID}@example.com`, email: `email-${testID}@example.com`,
firstName: `first-${testID}`, firstName: `first-${testID}`,
lastName: `last-${testID}`, lastName: `last-${testID}`,
password: `${testID}`, password: `${testID}`,
username: `user-${testID}`, username: `user-${testID}`,
type: 'normal',
}, },
}; };
@@ -31,23 +48,40 @@ module.exports = {
} }
); );
}, },
'create an user': client => { 'create a system administrator': (client) => {
client.login();
const users = client.page.users(); const users = client.page.users();
users.load(); users.load();
client.waitForSpinny(); client.waitForSpinny();
users.section.list users.create(store.admin, store.organization);
.waitForElementVisible('@add') users.search(store.admin.username);
.click('@add'); client.logout();
users.section.add },
.waitForElementVisible('@title') 'create a system auditor': (client) => {
.setValue('@organization', store.organization.name) client.login(store.admin.username, store.admin.password);
.setValue('@email', store.user.email) const users = client.page.users();
.setValue('@username', store.user.username) users.load();
.setValue('@password', store.user.password)
.setValue('@confirmPassword', store.user.password)
.click('@save');
client.waitForSpinny(); client.waitForSpinny();
users.search(store.user.username); users.create(store.auditor, store.organization);
users.search(store.auditor.username);
client.logout();
},
'check if the new system auditor can login': (client) => {
client.login(store.auditor.username, store.auditor.password);
client.logout();
},
'create an user': client => {
client.login(store.admin.username, store.admin.password);
const users = client.page.users();
users.load();
client.waitForSpinny();
const newUser = {
email: store.user.email,
password: store.user.password,
username: store.user.username,
};
users.create(newUser, store.organization);
users.search(newUser.username);
}, },
'edit an user': client => { 'edit an user': client => {
const users = client.page.users(); const users = client.page.users();
@@ -64,30 +98,30 @@ module.exports = {
client.waitForSpinny(); client.waitForSpinny();
users.search(store.user.username); 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}`); users.expect.element(row).text.contain(`${store.user.username}\n${store.user.firstName[0].toUpperCase() + store.user.firstName.slice(1)}\n${store.user.lastName}`);
client.logout();
}, },
'check if the new user can login': (client) => { 'check if the new user can login': (client) => {
client.logout();
client.login(store.user.username, store.user.password); client.login(store.user.username, store.user.password);
client.logout(); client.logout();
client.login();
}, },
'delete the user': (client) => { 'delete admin': (client) => {
client.login();
const users = client.page.users(); const users = client.page.users();
users.load(); users.load();
client.waitForSpinny(); client.waitForSpinny();
users.search(store.user.username); users.delete(store.admin.username);
const deleteButton = `${row} i[class*="fa-trash-o"]`; },
const modalAction = '.modal-dialog #prompt_action_btn'; 'delete auditor': (client) => {
users const users = client.page.users();
.waitForElementVisible(deleteButton) users.load();
.click(deleteButton) client.waitForSpinny();
.waitForElementVisible(modalAction) users.delete(store.auditor.username);
.click(modalAction) },
.waitForSpinny(); 'delete user': (client) => {
const searchResults = '.List-searchNoResults'; const users = client.page.users();
users users.load();
.waitForElementVisible(searchResults) client.waitForSpinny();
.expect.element(searchResults).text.contain('No records matched your search.'); users.delete(store.user.username);
}, },
after: client => { after: client => {
client.end(); client.end();