mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 07:17:40 -02:30
Merge pull request #3656 from elyezer/applications-e2e
Add applications to e2e Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
146
awx/ui/test/e2e/objects/applications.js
Normal file
146
awx/ui/test/e2e/objects/applications.js
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
import actions from './sections/actions';
|
||||||
|
import breadcrumb from './sections/breadcrumb';
|
||||||
|
import createTableSection from './sections/createTableSection';
|
||||||
|
import header from './sections/header';
|
||||||
|
import lookupModal from './sections/lookupModal';
|
||||||
|
import navigation from './sections/navigation';
|
||||||
|
import pagination from './sections/pagination';
|
||||||
|
import permissions from './sections/permissions';
|
||||||
|
import search from './sections/search';
|
||||||
|
|
||||||
|
const row = '.at-List-container .at-Row';
|
||||||
|
|
||||||
|
const addEditElements = {
|
||||||
|
name: '#application_name_group input',
|
||||||
|
description: '#application_description_group input',
|
||||||
|
organization: '#application_organization_group input',
|
||||||
|
authorizationGrantType: '#application_authorization_grant_type_group select',
|
||||||
|
redirectUris: '#application_redirect_uris_group input',
|
||||||
|
clientType: '#application_client_type_group select',
|
||||||
|
save: 'button[type=save]',
|
||||||
|
};
|
||||||
|
|
||||||
|
const authorizationGrantTypeOptions = {
|
||||||
|
authorizationCode: 'Authorization code',
|
||||||
|
implicit: 'Implicit',
|
||||||
|
resourceOwnerPasswordBased: 'Resource owner password-based',
|
||||||
|
};
|
||||||
|
|
||||||
|
const clientTypeOptions = {
|
||||||
|
confidential: 'Confidential',
|
||||||
|
public: 'Public',
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
url () {
|
||||||
|
return `${this.api.globals.launch_url}/#/applications`;
|
||||||
|
},
|
||||||
|
commands: [{
|
||||||
|
load () {
|
||||||
|
this.api.url('data:,'); // https://github.com/nightwatchjs/nightwatch/issues/1724
|
||||||
|
return this.navigate();
|
||||||
|
},
|
||||||
|
create (application, organization) {
|
||||||
|
this.section.list
|
||||||
|
.waitForElementVisible('@add')
|
||||||
|
.click('@add');
|
||||||
|
this.section.add
|
||||||
|
.waitForElementVisible('@name')
|
||||||
|
.setValue('@name', application.name)
|
||||||
|
.setValue('@organization', organization.name)
|
||||||
|
.setValue('@authorizationGrantType', application.authorizationGrantType)
|
||||||
|
.setValue('@clientType', application.clientType);
|
||||||
|
if (application.description) {
|
||||||
|
this.section.add.setValue('@description', application.description);
|
||||||
|
}
|
||||||
|
if (application.redirectUris) {
|
||||||
|
this.section.add.setValue('@redirectUris', application.redirectUris);
|
||||||
|
}
|
||||||
|
this.section.add.click('@save');
|
||||||
|
this.waitForSpinny();
|
||||||
|
this
|
||||||
|
.waitForElementVisible('#alert-modal-msg')
|
||||||
|
.expect.element('#alert-modal-msg').text.contain(application.name);
|
||||||
|
this.click('#alert_ok_btn');
|
||||||
|
this.waitForElementNotVisible('#alert-modal-msg');
|
||||||
|
},
|
||||||
|
delete (name) {
|
||||||
|
this.search(name);
|
||||||
|
const deleteButton = `${row} i[class*="fa-trash"]`;
|
||||||
|
const modalAction = '.modal-dialog #prompt_action_btn';
|
||||||
|
this
|
||||||
|
.waitForElementVisible(deleteButton)
|
||||||
|
.click(deleteButton)
|
||||||
|
.waitForElementVisible(modalAction)
|
||||||
|
.click(modalAction)
|
||||||
|
.waitForSpinny();
|
||||||
|
const searchResults = '.at-List--empty';
|
||||||
|
this
|
||||||
|
.waitForElementVisible(searchResults)
|
||||||
|
.expect.element(searchResults).text.equal('PLEASE ADD ITEMS TO THIS LIST.');
|
||||||
|
},
|
||||||
|
search (name) {
|
||||||
|
const searchSection = this.section.list.section.search;
|
||||||
|
searchSection.setValue('@input', name);
|
||||||
|
searchSection.expect.element('@searchButton').to.be.enabled.before(200);
|
||||||
|
searchSection.click('@searchButton');
|
||||||
|
this.waitForSpinny();
|
||||||
|
this.waitForElementNotPresent(`${row}:nth-of-type(2)`);
|
||||||
|
this.expect.element('.at-Panel-headingTitleBadge').text.to.equal('1');
|
||||||
|
this.expect.element(`${row} .at-RowItem-header`).text.equal(name);
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
sections: {
|
||||||
|
header,
|
||||||
|
navigation,
|
||||||
|
breadcrumb,
|
||||||
|
lookupModal,
|
||||||
|
add: {
|
||||||
|
selector: 'div[ui-view="add"]',
|
||||||
|
sections: {
|
||||||
|
// details
|
||||||
|
},
|
||||||
|
elements: addEditElements,
|
||||||
|
},
|
||||||
|
edit: {
|
||||||
|
selector: 'div[ui-view="edit"]',
|
||||||
|
sections: {
|
||||||
|
// details,
|
||||||
|
permissions
|
||||||
|
},
|
||||||
|
elements: addEditElements,
|
||||||
|
},
|
||||||
|
list: {
|
||||||
|
selector: 'div[ui-view="list"]',
|
||||||
|
elements: {
|
||||||
|
badge: 'span[class~="badge"]',
|
||||||
|
title: 'h3[class~="Panel-headingTitle"]',
|
||||||
|
add: '#button-add'
|
||||||
|
},
|
||||||
|
sections: {
|
||||||
|
search,
|
||||||
|
pagination,
|
||||||
|
table: createTableSection({
|
||||||
|
elements: {
|
||||||
|
username: 'td[class~="username-column"]',
|
||||||
|
first_name: 'td[class~="first_name-column"]',
|
||||||
|
last_name: 'td[class~="last_name-column"]'
|
||||||
|
},
|
||||||
|
sections: {
|
||||||
|
actions
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
elements: {
|
||||||
|
cancel: 'button[class*="Form-cancelButton"]',
|
||||||
|
save: 'button[class*="Form-saveButton"]'
|
||||||
|
},
|
||||||
|
props () {
|
||||||
|
return {
|
||||||
|
authorizationGrantTypeOptions,
|
||||||
|
clientTypeOptions,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
85
awx/ui/test/e2e/tests/test-applications.js
Normal file
85
awx/ui/test/e2e/tests/test-applications.js
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/* Tests for applications. */
|
||||||
|
import uuid from 'uuid';
|
||||||
|
|
||||||
|
const row = '.at-List-container .at-Row';
|
||||||
|
const testID = uuid().substr(0, 8);
|
||||||
|
|
||||||
|
const store = {
|
||||||
|
organization: {
|
||||||
|
name: `org-${testID}`
|
||||||
|
},
|
||||||
|
application: {
|
||||||
|
name: `name-${testID}`,
|
||||||
|
description: `description-${testID}`,
|
||||||
|
// authorizationGrantType: `authorization-grand-type-${testID}`,
|
||||||
|
redirectUris: `https://example.com/${testID}/`,
|
||||||
|
// clientType: `client-type-${testID}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
before: (client, done) => {
|
||||||
|
client.login();
|
||||||
|
client.waitForAngular();
|
||||||
|
|
||||||
|
client.inject(
|
||||||
|
[store, 'OrganizationModel'],
|
||||||
|
(_store_, Model) => new Model().http.post({ data: _store_.organization }),
|
||||||
|
({ data }) => {
|
||||||
|
store.organization = data;
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
'create an application': client => {
|
||||||
|
const applications = client.page.applications();
|
||||||
|
applications.load();
|
||||||
|
client.waitForSpinny();
|
||||||
|
const newApplication = {
|
||||||
|
name: store.application.name,
|
||||||
|
redirectUris: store.application.redirectUris,
|
||||||
|
authorizationGrantType:
|
||||||
|
applications.props.authorizationGrantTypeOptions.authorizationCode,
|
||||||
|
clientType: applications.props.clientTypeOptions.confidential,
|
||||||
|
};
|
||||||
|
applications.create(newApplication, store.organization);
|
||||||
|
applications.search(store.application.name);
|
||||||
|
},
|
||||||
|
'edit an application': client => {
|
||||||
|
// Given the application created on the previous test
|
||||||
|
const applications = client.page.applications();
|
||||||
|
applications.load();
|
||||||
|
client.waitForSpinny();
|
||||||
|
applications.search(store.application.name);
|
||||||
|
const editLink = `${row} a.ng-binding`;
|
||||||
|
client
|
||||||
|
.waitForElementVisible(editLink)
|
||||||
|
.expect.element(editLink).text.to.equal(store.application.name);
|
||||||
|
client.click(editLink);
|
||||||
|
applications.section.edit
|
||||||
|
.waitForElementVisible('@description')
|
||||||
|
.setValue('@description', store.application.description)
|
||||||
|
.click('@save');
|
||||||
|
client.waitForSpinny();
|
||||||
|
applications.load();
|
||||||
|
client.waitForSpinny();
|
||||||
|
applications.search(store.application.name);
|
||||||
|
client
|
||||||
|
.waitForElementVisible(editLink)
|
||||||
|
.expect.element(editLink).text.to.equal(store.application.name);
|
||||||
|
client.click(editLink);
|
||||||
|
applications.section.edit
|
||||||
|
.waitForElementVisible('@description')
|
||||||
|
.expect.element('@description').value.to.equal(store.application.description);
|
||||||
|
},
|
||||||
|
'delete an application': client => {
|
||||||
|
// Given the application created on the create application test
|
||||||
|
const applications = client.page.applications();
|
||||||
|
applications.load();
|
||||||
|
client.waitForSpinny();
|
||||||
|
applications.delete(store.application.name);
|
||||||
|
},
|
||||||
|
after: client => {
|
||||||
|
client.end();
|
||||||
|
},
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user