mirror of
https://github.com/ansible/awx.git
synced 2026-02-25 23:16:01 -03:30
Moved form element selectors out into props in the form definition. Added checkAllFieldsDisabled to createFormSection.
This commit is contained in:
@@ -9,8 +9,30 @@ import pagination from './sections/pagination.js';
|
||||
import permissions from './sections/permissions.js';
|
||||
import search from './sections/search.js';
|
||||
|
||||
const details = createFormSection({
|
||||
selector: 'form'
|
||||
const standardInvDetails = createFormSection({
|
||||
selector: 'form',
|
||||
props: {
|
||||
formElementSelectors: [
|
||||
'#inventory_form .Form-textInput',
|
||||
'#inventory_form select.Form-dropDown',
|
||||
'#inventory_form .Form-textArea',
|
||||
'#inventory_form input[type="checkbox"]',
|
||||
'#inventory_form .ui-spinner-input',
|
||||
'#inventory_form .ScheduleToggle-switch'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
const smartInvDetails = createFormSection({
|
||||
selector: 'form',
|
||||
props: {
|
||||
formElementSelectors: [
|
||||
'#smartinventory_form input.Form-textInput',
|
||||
'#smartinventory_form textarea.Form-textArea',
|
||||
'#smartinventory_form .Form-lookupButton',
|
||||
'#smartinventory_form #InstanceGroups'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
@@ -25,7 +47,7 @@ module.exports = {
|
||||
addStandardInventory: {
|
||||
selector: 'div[ui-view="form"]',
|
||||
sections: {
|
||||
details
|
||||
standardInvDetails
|
||||
},
|
||||
elements: {
|
||||
title: 'div[class^="Form-title"]'
|
||||
@@ -34,7 +56,7 @@ module.exports = {
|
||||
editStandardInventory: {
|
||||
selector: 'div[ui-view="form"]',
|
||||
sections: {
|
||||
details,
|
||||
standardInvDetails,
|
||||
permissions
|
||||
},
|
||||
elements: {
|
||||
@@ -44,7 +66,7 @@ module.exports = {
|
||||
addSmartInventory: {
|
||||
selector: 'div[ui-view="form"]',
|
||||
sections: {
|
||||
details
|
||||
smartInvDetails
|
||||
},
|
||||
elements: {
|
||||
title: 'div[class^="Form-title"]'
|
||||
@@ -53,7 +75,7 @@ module.exports = {
|
||||
editSmartInventory: {
|
||||
selector: 'div[ui-view="form"]',
|
||||
sections: {
|
||||
details,
|
||||
smartInvDetails,
|
||||
permissions
|
||||
},
|
||||
elements: {
|
||||
|
||||
@@ -10,7 +10,14 @@ import permissions from './sections/permissions.js';
|
||||
import search from './sections/search.js';
|
||||
|
||||
const details = createFormSection({
|
||||
selector: 'form'
|
||||
selector: 'form',
|
||||
props: {
|
||||
formElementSelectors: [
|
||||
'#inventory_script_form .Form-textInput',
|
||||
'#inventory_script_form .Form-textArea',
|
||||
'#inventory_script_form .Form-lookupButton'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -10,7 +10,19 @@ import permissions from './sections/permissions.js';
|
||||
import search from './sections/search.js';
|
||||
|
||||
const details = createFormSection({
|
||||
selector: 'form'
|
||||
selector: 'form',
|
||||
props: {
|
||||
formElementSelectors: [
|
||||
'#notification_template_form .Form-textInput',
|
||||
'#notification_template_form select.Form-dropDown',
|
||||
'#notification_template_form input[type="checkbox"]',
|
||||
'#notification_template_form input[type="radio"]',
|
||||
'#notification_template_form .ui-spinner-input',
|
||||
'#notification_template_form .Form-textArea',
|
||||
'#notification_template_form .ScheduleToggle-switch',
|
||||
'#notification_template_form .Form-lookupButton'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -8,7 +8,14 @@ import permissions from './sections/permissions.js';
|
||||
import search from './sections/search.js';
|
||||
|
||||
const details = createFormSection({
|
||||
selector: 'form'
|
||||
selector: 'form',
|
||||
props: {
|
||||
formElementSelectors: [
|
||||
'#organization_form input.Form-textInput',
|
||||
'#organization_form .Form-lookupButton',
|
||||
'#organization_form #InstanceGroups'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -10,7 +10,15 @@ import permissions from './sections/permissions.js';
|
||||
import search from './sections/search.js';
|
||||
|
||||
const details = createFormSection({
|
||||
selector: 'form'
|
||||
selector: 'form',
|
||||
props: {
|
||||
formElementSelectors: [
|
||||
'#project_form .Form-textInput',
|
||||
'#project_form select.Form-dropDown',
|
||||
'#project_form input[type="checkbox"]',
|
||||
'#project_form .ui-spinner-input',
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -79,13 +79,48 @@ const generatorOptions = {
|
||||
};
|
||||
|
||||
|
||||
const createFormSection = function({ selector, labels, strategy }) {
|
||||
const checkAllFieldsDisabled = function() {
|
||||
let client = this.client.api;
|
||||
|
||||
// let selectors = this.props.formElementSelectors ? this.props.formElementSelectors : [
|
||||
// '.at-Input',
|
||||
// '.Form-textInput',
|
||||
// 'select.Form-dropDown',
|
||||
// 'input[type="checkbox"]',
|
||||
// 'input[type="radio"]',
|
||||
// '.ui-spinner-input',
|
||||
// '.Form-textArea',
|
||||
// '.ScheduleToggle-switch',
|
||||
// '.Form-lookupButton'
|
||||
// ];
|
||||
|
||||
let selectors = this.props.formElementSelectors ? this.props.formElementSelectors : [
|
||||
'.at-Input'
|
||||
];
|
||||
|
||||
selectors.forEach(function(selector) {
|
||||
client.elements('css selector', selector, inputs => {
|
||||
inputs.value.map(o => o.ELEMENT).forEach(id => {
|
||||
client.elementIdAttribute(id, 'disabled', ({ value }) => {
|
||||
client.assert.equal(value, 'true');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const createFormSection = function({ selector, labels, strategy, props }) {
|
||||
let options = generatorOptions[strategy || 'default'];
|
||||
|
||||
let formSection = {
|
||||
selector,
|
||||
sections: {},
|
||||
elements: {}
|
||||
elements: {},
|
||||
commands: [{
|
||||
checkAllFieldsDisabled: checkAllFieldsDisabled
|
||||
}],
|
||||
props: props
|
||||
};
|
||||
|
||||
for (let key in labels) {
|
||||
@@ -95,7 +130,7 @@ const createFormSection = function({ selector, labels, strategy }) {
|
||||
|
||||
formSection.elements[key] = inputElement;
|
||||
formSection.sections[key] = inputContainer;
|
||||
};
|
||||
}
|
||||
|
||||
return formSection;
|
||||
};
|
||||
|
||||
@@ -10,7 +10,13 @@ import permissions from './sections/permissions.js';
|
||||
import search from './sections/search.js';
|
||||
|
||||
const details = createFormSection({
|
||||
selector: 'form'
|
||||
selector: 'form',
|
||||
props: {
|
||||
formElementSelectors: [
|
||||
'#team_form input.Form-textInput',
|
||||
'#team_form .Form-lookupButton'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -10,7 +10,17 @@ import permissions from './sections/permissions.js';
|
||||
import search from './sections/search.js';
|
||||
|
||||
const details = createFormSection({
|
||||
selector: 'form'
|
||||
selector: 'form',
|
||||
props: {
|
||||
formElementSelectors: [
|
||||
'#job_template_form .Form-textInput',
|
||||
'#job_template_form select.Form-dropDown',
|
||||
'#job_template_form .Form-textArea',
|
||||
'#job_template_form input[type="checkbox"]',
|
||||
'#job_template_form .ui-spinner-input',
|
||||
'#job_template_form .ScheduleToggle-switch'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -10,7 +10,13 @@ import permissions from './sections/permissions.js';
|
||||
import search from './sections/search.js';
|
||||
|
||||
const details = createFormSection({
|
||||
selector: 'form'
|
||||
selector: 'form',
|
||||
props: {
|
||||
formElementSelectors: [
|
||||
'#user_form .Form-textInput',
|
||||
'#user_form select.Form-dropDown'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -82,18 +82,6 @@ let credentials,
|
||||
inventories,
|
||||
teams;
|
||||
|
||||
function checkDisabledElements(client, selectors) {
|
||||
selectors.forEach(function(selector) {
|
||||
client.elements('css selector', selector, inputs => {
|
||||
inputs.value.map(o => o.ELEMENT).forEach(id => {
|
||||
client.elementIdAttribute(id, 'disabled', ({ value }) => {
|
||||
client.assert.equal(value, 'true');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function navigateAndWaitForSpinner(client, url) {
|
||||
client
|
||||
.url(url)
|
||||
@@ -104,15 +92,17 @@ function navigateAndWaitForSpinner(client, url) {
|
||||
module.exports = {
|
||||
before: function (client, done) {
|
||||
|
||||
credentials = client.useCss().page.credentials();
|
||||
inventoryScripts = client.useCss().page.inventoryScripts();
|
||||
templates = client.useCss().page.templates();
|
||||
notificationTemplates = client.useCss().page.notificationTemplates();
|
||||
organizations = client.useCss().page.organizations();
|
||||
projects = client.useCss().page.projects();
|
||||
users = client.useCss().page.users();
|
||||
inventories = client.useCss().page.inventories();
|
||||
teams = client.useCss().page.teams();
|
||||
client.useCss();
|
||||
|
||||
credentials = client.page.credentials();
|
||||
inventoryScripts = client.page.inventoryScripts();
|
||||
templates = client.page.templates();
|
||||
notificationTemplates = client.page.notificationTemplates();
|
||||
organizations = client.page.organizations();
|
||||
projects = client.page.projects();
|
||||
users = client.page.users();
|
||||
inventories = client.page.inventories();
|
||||
teams = client.page.teams();
|
||||
|
||||
client.login();
|
||||
client.waitForAngular();
|
||||
@@ -233,32 +223,8 @@ module.exports = {
|
||||
};
|
||||
});
|
||||
},
|
||||
({ adminJobTemplate,
|
||||
adminAWSCredential,
|
||||
adminMachineCredential,
|
||||
adminOrganization,
|
||||
adminInventoryScript,
|
||||
adminNotificationTemplate,
|
||||
adminProject,
|
||||
adminSmartInventory,
|
||||
adminStandardInventory,
|
||||
adminTeam,
|
||||
adminUser,
|
||||
auditor }) => {
|
||||
store.created = {
|
||||
adminJobTemplate,
|
||||
adminAWSCredential,
|
||||
adminMachineCredential,
|
||||
adminOrganization,
|
||||
adminInventoryScript,
|
||||
adminNotificationTemplate,
|
||||
adminProject,
|
||||
adminSmartInventory,
|
||||
adminStandardInventory,
|
||||
adminTeam,
|
||||
adminUser,
|
||||
auditor
|
||||
};
|
||||
created => {
|
||||
store.created = created;
|
||||
|
||||
client.login(store.auditor.username, store.auditor.password);
|
||||
|
||||
@@ -271,7 +237,7 @@ module.exports = {
|
||||
credentials.section.edit
|
||||
.expect.element('@title').text.contain(store.created.adminAWSCredential.name);
|
||||
|
||||
checkDisabledElements(client, ['.at-Input']);
|
||||
credentials.section.edit.section.details.checkAllFieldsDisabled();
|
||||
},
|
||||
'verify an auditor\'s inventory scripts inputs are read-only': function (client) {
|
||||
navigateAndWaitForSpinner(client, `${inventoryScripts.url()}/${store.created.adminInventoryScript.id}/`);
|
||||
@@ -279,57 +245,31 @@ module.exports = {
|
||||
inventoryScripts.section.edit
|
||||
.expect.element('@title').text.contain(store.created.adminInventoryScript.name);
|
||||
|
||||
let selectors = [
|
||||
'#inventory_script_form .Form-textInput',
|
||||
'#inventory_script_form .Form-textArea',
|
||||
'#inventory_script_form .Form-lookupButton'
|
||||
];
|
||||
|
||||
checkDisabledElements(client, selectors);
|
||||
inventoryScripts.section.edit.section.details.checkAllFieldsDisabled();
|
||||
},
|
||||
'verify save button hidden from auditor on inventory scripts form': function () {
|
||||
inventoryScripts.expect.element('@save').to.not.be.visible;
|
||||
},
|
||||
'verify an auditor\'s job template inputs are read-only': function (client) {
|
||||
navigateAndWaitForSpinner(client, `${templates.url()}/job_template/${store.created.adminJobTemplate.id}/`);
|
||||
|
||||
templates.section.editJobTemplate
|
||||
.expect.element('@title').text.contain(store.created.adminJobTemplate.name);
|
||||
|
||||
client.pause(2000);
|
||||
|
||||
let selectors = [
|
||||
'#job_template_form .Form-textInput',
|
||||
'#job_template_form select.Form-dropDown',
|
||||
'#job_template_form .Form-textArea',
|
||||
'#job_template_form input[type="checkbox"]',
|
||||
'#job_template_form .ui-spinner-input',
|
||||
'#job_template_form .ScheduleToggle-switch'
|
||||
];
|
||||
|
||||
checkDisabledElements(client, selectors);
|
||||
},
|
||||
'verify save button hidden from auditor on job templates form': function () {
|
||||
templates.expect.element('@save').to.not.be.visible;
|
||||
},
|
||||
// TODO: re-enable these tests when JT edit has been re-factored to reliably show/remove the loading spinner
|
||||
// only one time. Without this, we can't tell when all the requisite data is available.
|
||||
// 'verify an auditor\'s job template inputs are read-only': function (client) {
|
||||
// navigateAndWaitForSpinner(client, `${templates.url()}/job_template/${store.created.adminJobTemplate.id}/`);
|
||||
//
|
||||
// templates.section.editJobTemplate
|
||||
// .expect.element('@title').text.contain(store.created.adminJobTemplate.name);
|
||||
//
|
||||
// templates.section.edit.section.details.checkAllFieldsDisabled();
|
||||
// },
|
||||
// 'verify save button hidden from auditor on job templates form': function () {
|
||||
// templates.expect.element('@save').to.not.be.visible;
|
||||
// },
|
||||
'verify an auditor\'s notification templates inputs are read-only': function (client) {
|
||||
navigateAndWaitForSpinner(client, `${notificationTemplates.url()}/${store.created.adminNotificationTemplate.id}/`);
|
||||
|
||||
notificationTemplates.section.edit
|
||||
.expect.element('@title').text.contain(store.created.adminNotificationTemplate.name);
|
||||
|
||||
let selectors = [
|
||||
'#notification_template_form .Form-textInput',
|
||||
'#notification_template_form select.Form-dropDown',
|
||||
'#notification_template_form input[type="checkbox"]',
|
||||
'#notification_template_form input[type="radio"]',
|
||||
'#notification_template_form .ui-spinner-input',
|
||||
'#notification_template_form .Form-textArea',
|
||||
'#notification_template_form .ScheduleToggle-switch',
|
||||
'#notification_template_form .Form-lookupButton'
|
||||
];
|
||||
|
||||
checkDisabledElements(client, selectors);
|
||||
notificationTemplates.section.edit.section.details.checkAllFieldsDisabled();
|
||||
},
|
||||
'verify save button hidden from auditor on notification templates page': function () {
|
||||
notificationTemplates.expect.element('@save').to.not.be.visible;
|
||||
@@ -340,13 +280,7 @@ module.exports = {
|
||||
organizations.section.edit
|
||||
.expect.element('@title').text.contain(store.created.adminOrganization.name);
|
||||
|
||||
let selectors = [
|
||||
'#organization_form input.Form-textInput',
|
||||
'#organization_form .Form-lookupButton',
|
||||
'#organization_form #InstanceGroups'
|
||||
];
|
||||
|
||||
checkDisabledElements(client, selectors);
|
||||
organizations.section.edit.section.details.checkAllFieldsDisabled();
|
||||
},
|
||||
'verify save button hidden from auditor on organizations form': function () {
|
||||
organizations.expect.element('@save').to.not.be.visible;
|
||||
@@ -357,14 +291,7 @@ module.exports = {
|
||||
inventories.section.editSmartInventory
|
||||
.expect.element('@title').text.contain(store.created.adminSmartInventory.name);
|
||||
|
||||
let selectors = [
|
||||
'#smartinventory_form input.Form-textInput',
|
||||
'#smartinventory_form textarea.Form-textArea',
|
||||
'#smartinventory_form .Form-lookupButton',
|
||||
'#smartinventory_form #InstanceGroups'
|
||||
];
|
||||
|
||||
checkDisabledElements(client, selectors);
|
||||
inventories.section.editSmartInventory.section.smartInvDetails.checkAllFieldsDisabled();
|
||||
},
|
||||
'verify save button hidden from auditor on smart inventories form': function () {
|
||||
inventories.expect.element('@save').to.not.be.visible;
|
||||
@@ -375,14 +302,7 @@ module.exports = {
|
||||
projects.section.edit
|
||||
.expect.element('@title').text.contain(store.created.adminProject.name);
|
||||
|
||||
let selectors = [
|
||||
'#project_form .Form-textInput',
|
||||
'#project_form select.Form-dropDown',
|
||||
'#project_form input[type="checkbox"]',
|
||||
'#project_form .ui-spinner-input',
|
||||
];
|
||||
|
||||
checkDisabledElements(client, selectors);
|
||||
projects.section.edit.section.details.checkAllFieldsDisabled();
|
||||
},
|
||||
'verify save button hidden from auditor on projects form': function () {
|
||||
projects.expect.element('@save').to.not.be.visible;
|
||||
@@ -393,16 +313,7 @@ module.exports = {
|
||||
inventories.section.editStandardInventory
|
||||
.expect.element('@title').text.contain(store.created.adminStandardInventory.name);
|
||||
|
||||
let selectors = [
|
||||
'#inventory_form .Form-textInput',
|
||||
'#inventory_form select.Form-dropDown',
|
||||
'#inventory_form .Form-textArea',
|
||||
'#inventory_form input[type="checkbox"]',
|
||||
'#inventory_form .ui-spinner-input',
|
||||
'#inventory_form .ScheduleToggle-switch'
|
||||
];
|
||||
|
||||
checkDisabledElements(client, selectors);
|
||||
inventories.section.editStandardInventory.section.standardInvDetails.checkAllFieldsDisabled();
|
||||
},
|
||||
'verify save button hidden from auditor on standard inventory form': function () {
|
||||
inventories.expect.element('@save').to.not.be.visible;
|
||||
@@ -413,12 +324,7 @@ module.exports = {
|
||||
teams.section.edit
|
||||
.expect.element('@title').text.contain(store.created.adminTeam.name);
|
||||
|
||||
let selectors = [
|
||||
'#team_form input.Form-textInput',
|
||||
'#team_form .Form-lookupButton'
|
||||
];
|
||||
|
||||
checkDisabledElements(client, selectors);
|
||||
teams.section.edit.section.details.checkAllFieldsDisabled();
|
||||
},
|
||||
'verify save button hidden from auditor on teams form': function () {
|
||||
teams.expect.element('@save').to.not.be.visible;
|
||||
@@ -429,12 +335,7 @@ module.exports = {
|
||||
users.section.edit
|
||||
.expect.element('@title').text.contain(store.created.adminUser.username);
|
||||
|
||||
let selectors = [
|
||||
'#user_form .Form-textInput',
|
||||
'#user_form select.Form-dropDown'
|
||||
];
|
||||
|
||||
checkDisabledElements(client, selectors);
|
||||
users.section.edit.section.details.checkAllFieldsDisabled();
|
||||
},
|
||||
'verify save button hidden from auditor on users form': function (client) {
|
||||
users.expect.element('@save').to.not.be.visible;
|
||||
|
||||
Reference in New Issue
Block a user