Skip to content

Instantly share code, notes, and snippets.

@adamrneary
Last active March 22, 2016 15:44
Show Gist options
  • Save adamrneary/1f4dd99560fb96a34859 to your computer and use it in GitHub Desktop.
Save adamrneary/1f4dd99560fb96a34859 to your computer and use it in GitHub Desktop.
var urls = require('../utils/urls');
module.exports = {
elements: {
page: '#Templates',
linkTemplates: '.Header--Links a[href="/templates"]',
linkArchived: 'a[href="/templates/archived"]',
linkArchivedActive: 'a.active[href="/templates/archived"]',
buttonAddTemplate: '#wi-TemplateList-AddTemplate',
buttonAddTemplateSet: '#wi-TemplateList-AddTemplateSet',
buttonCancel: '#wi-Template-Cancel',
buttonSubmit: '#wi-Template-Submit',
buttonSubmitDisabled: '#wi-Template-Submit.disabled',
buttonFilter: '.wi-StandardInteractions-Query .wi-Icon',
inputTitle: '#wiTemplateTitle',
inputTitleSet: '#wiTemplateSetTitle',
table: '.wi-TemplateTable',
tableRowTemplate: '.wi-Template-Row',
tableRowTemplateSet: '.wi-TemplateSet-Row',
inputSearch: '.wi-SearchBar',
displayField: 'div[data-key="displayField"]',
stateFetching: '.wi-searchableTable[data-loading="true"]',
stateFetched: '.wi-searchableTable[data-loading="false"]'
},
commands: [{
navigateTo() {
return this
.click('@linkTemplates')
.waitForElementVisible('@page')
},
addTemplate(title){
this
.waitForElementVisible('@buttonAddTemplate')
.click('@buttonAddTemplate')
.waitForElementVisible('@inputTitle')
.setValue('@inputTitle', title)
.waitForElementNotPresent('@buttonSubmitDisabled')
.click('@buttonSubmit');
this.api.page.templateEditor()
.waitForElementPresent('@page');
return this;
},
addTemplateSet(title) {
this
.waitForElementVisible('@buttonAddTemplateSet')
.click('@buttonAddTemplateSet')
.waitForElementVisible('@inputTitleSet')
.setValue('@inputTitleSet', title)
.waitForElementNotPresent('@buttonSubmitDisabled')
.click('@buttonSubmit');
this.api.page.templateSetEditor()
.waitForElementPresent('@page');
return this;
},
archiveTemplateSet(id) {
const row = `tr[id="${id}"]`;
const dropdown = `${row} .wi-Dropdown`;
const archive = `${row} .wi-Dropdown-Item[data-action="archive"]`;
var sweetAlert = this.api.page.sweetAlert();
this
.waitForElementVisible(row)
.click(dropdown)
.waitForElementVisible(archive)
.click(archive);
sweetAlert
.waitForConfirmVisible()
.confirm();
// query should be running
this.waitForElementPresent('@stateFetching');
sweetAlert
.waitForCancelNotVisible()
.confirm()
.waitForNotPresent();
// query should no longer be running
this.waitForElementNotPresent('@stateFetching');
return this;
},
unarchiveTemplateSet(id) {
const row = `tr[id="${id}"]`;
const dropdown = `${row} .wi-Dropdown`;
const unarchive = `${row} .wi-Dropdown-Item[data-action="unarchive"]`;
return this
.waitForElementVisible(row)
.click(dropdown)
.waitForElementVisible(unarchive)
.click(unarchive)
.waitForElementNotPresent(row);
},
navigateWithHeader() {
return this.navigateTo();
},
navigateToArchived() {
return this
.navigateTo()
.click('@linkArchived')
.waitForElementPresent('@linkArchivedActive')
}
}]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment