1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

add initial test and sanity check for search tags

This commit is contained in:
Jake McDermott 2018-03-04 16:11:45 -05:00
parent 1cc7d5535e
commit c12173233b
No known key found for this signature in database
GPG Key ID: 3B02CAD476EECB35

View File

@ -0,0 +1,125 @@
import { range } from 'lodash';
import { getAdminMachineCredential } from '../fixtures';
// AWX_E2E_URL='https://localhost:3000' npm --prefix awx/ui run e2e -- --filter="*jobz*"
const spinny = 'div.spinny';
const searchInput = 'smart-search input';
const searchSubmit = 'smart-search i[class*="search"]';
const searchTags = 'smart-search .SmartSearch-tagContainer';
const searchClearAll = 'smart-search .SmartSearch-clearAll';
const searchTagDelete = 'i[class*="fa-times"]';
const createTagSelector = n => `${searchTags}:nth-of-type(${n})`;
const createTagDeleteSelector = n => `${searchTags}:nth-of-type(${n}) ${searchTagDelete}`;
const checkTags = (client, tags) => {
const strategy = 'css selector';
const countReached = createTagSelector(tags.length);
const countExceeded = createTagSelector(tags.length + 1);
if (tags.length > 0) {
client.waitForElementVisible(countReached);
client.waitForElementNotPresent(countExceeded);
}
client.elements(strategy, searchTags, tagElements => {
client.assert.equal(tagElements.value.length, tags.length);
let n = -1;
tagElements.value.map(o => o.ELEMENT).forEach(id => {
client.elementIdText(id, ({ value }) => {
client.assert.equal(value, tags[++n]);
});
});
});
};
module.exports = {
before: (client, done) => {
const resources = range(25).map(n => getAdminMachineCredential(`test-search-${n}`));
Promise.all(resources).then(done);
},
'add and remove search tags': client => {
const credentials = client.page.credentials();
client.login();
client.waitForAngular();
credentials.section.navigation.waitForElementVisible('@credentials');
credentials.section.navigation.click('@credentials');
client.waitForElementVisible(spinny);
client.waitForElementNotVisible(spinny);
client.waitForElementVisible(searchInput);
client.waitForElementVisible(searchSubmit);
client.expect.element(searchInput).enabled;
client.expect.element(searchSubmit).enabled;
checkTags(client, []);
client.setValue(searchInput, 'foo');
client.click(searchSubmit);
client.waitForElementVisible(spinny);
client.waitForElementNotVisible(spinny);
checkTags(client, ['foo']);
client.setValue(searchInput, 'bar e2e');
client.click(searchSubmit);
client.waitForElementVisible(spinny);
client.waitForElementNotVisible(spinny);
checkTags(client, ['foo', 'bar', 'e2e']);
client.click(searchClearAll);
client.waitForElementVisible(spinny);
client.waitForElementNotVisible(spinny);
checkTags(client, []);
client.setValue(searchInput, 'fiz name:foo');
client.click(searchSubmit);
client.waitForElementVisible(spinny);
client.waitForElementNotVisible(spinny);
checkTags(client, ['fiz', 'name:foo']);
client.click(searchClearAll);
client.waitForElementVisible(spinny);
client.waitForElementNotVisible(spinny);
checkTags(client, []);
client.setValue(searchInput, 'hello name:world fiz');
client.click(searchSubmit);
client.waitForElementVisible(spinny);
client.waitForElementNotVisible(spinny);
checkTags(client, ['hello', 'fiz', 'name:world']);
client.click(createTagDeleteSelector(2));
client.waitForElementVisible(spinny);
client.waitForElementNotVisible(spinny);
checkTags(client, ['hello', 'name:world']);
client.click(createTagDeleteSelector(1));
client.waitForElementVisible(spinny);
client.waitForElementNotVisible(spinny);
checkTags(client, ['name:world']);
client.click(createTagDeleteSelector(1));
client.waitForElementVisible(spinny);
client.waitForElementNotVisible(spinny);
checkTags(client, []);
client.end();
},
};