1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

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
commit 6e8809fe72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 104 additions and 29 deletions

View File

@ -31,6 +31,7 @@ const addEditElements = {
password: '#user_password_input',
save: '#user_save_btn',
username: '#user_username',
type: '#select2-user_user_type-container',
};
module.exports = {
@ -42,6 +43,46 @@ module.exports = {
this.api.url('data:,'); // https://github.com/nightwatchjs/nightwatch/issues/1724
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) {
this.section.list.section.search
.setValue('@input', username)

View File

@ -8,12 +8,29 @@ const store = {
organization: {
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: {
email: `email-${testID}@example.com`,
firstName: `first-${testID}`,
lastName: `last-${testID}`,
password: `${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();
users.load();
client.waitForSpinny();
users.section.list
.waitForElementVisible('@add')
.click('@add');
users.section.add
.waitForElementVisible('@title')
.setValue('@organization', store.organization.name)
.setValue('@email', store.user.email)
.setValue('@username', store.user.username)
.setValue('@password', store.user.password)
.setValue('@confirmPassword', store.user.password)
.click('@save');
users.create(store.admin, store.organization);
users.search(store.admin.username);
client.logout();
},
'create a system auditor': (client) => {
client.login(store.admin.username, store.admin.password);
const users = client.page.users();
users.load();
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 => {
const users = client.page.users();
@ -64,30 +98,30 @@ module.exports = {
client.waitForSpinny();
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}`);
client.logout();
},
'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) => {
'delete admin': (client) => {
client.login();
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.');
users.delete(store.admin.username);
},
'delete auditor': (client) => {
const users = client.page.users();
users.load();
client.waitForSpinny();
users.delete(store.auditor.username);
},
'delete user': (client) => {
const users = client.page.users();
users.load();
client.waitForSpinny();
users.delete(store.user.username);
},
after: client => {
client.end();