Tests fixed
gitea/salix/dev This commit looks good Details

This commit is contained in:
Juan Ferrer 2019-10-16 09:54:02 +02:00
parent e1e65e8b2e
commit dbe6161c69
3 changed files with 20 additions and 11 deletions

View File

@ -12,6 +12,7 @@ let asyncActions = {
clickIfExists: async function(selector) { clickIfExists: async function(selector) {
let exists = await this.exists(selector); let exists = await this.exists(selector);
if (exists) await this.click(selector); if (exists) await this.click(selector);
return exists;
}, },
// Salix specific extensions // Salix specific extensions
@ -29,8 +30,16 @@ let asyncActions = {
login: async function(userName) { login: async function(userName) {
if (currentUser !== userName) { if (currentUser !== userName) {
this.clickIfExists('#logout') let logoutClicked = await this.clickIfExists('#logout');
.clickIfExists('.vn-dialog.shown button[response=ACCEPT]');
if (logoutClicked) {
let buttonSelector = '.vn-dialog.shown button[response=ACCEPT]';
this.wait(buttonSelector => {
return document.querySelector(buttonSelector) != null
|| location.hash == '#!/login';
}, buttonSelector);
await this.clickIfExists(buttonSelector);
}
try { try {
await this.waitForURL('#!/login'); await this.waitForURL('#!/login');
@ -86,7 +95,7 @@ let asyncActions = {
pickTime: async function(selector, time) { pickTime: async function(selector, time) {
await this.wait(selector) await this.wait(selector)
.evaluate((selector, time) => { .evaluate((selector, time) => {
let input = document.querySelector(selector); let input = document.querySelector(selector).$ctrl.input;
input.value = time; input.value = time;
input.dispatchEvent(new Event('change')); input.dispatchEvent(new Event('change'));
}, selector, time); }, selector, time);
@ -481,11 +490,6 @@ let actions = {
}, },
}; };
Object.keys(actions).forEach(function(name) {
let fn = actions[name];
Nightmare.action(name, fn);
});
for (let name in asyncActions) { for (let name in asyncActions) {
let fn = asyncActions[name]; let fn = asyncActions[name];
@ -495,3 +499,8 @@ for (let name in asyncActions) {
.then(res => done(null, res), done); .then(res => done(null, res), done);
}); });
} }
Object.keys(actions).forEach(function(name) {
let fn = actions[name];
Nightmare.action(name, fn);
});

View File

@ -363,7 +363,7 @@ export default {
moreMenuMakeInvoice: '.vn-popover.shown .vn-drop-down li[name="Make invoice"]', moreMenuMakeInvoice: '.vn-popover.shown .vn-drop-down li[name="Make invoice"]',
moreMenuChangeShippedHour: '.vn-popover.shown .vn-drop-down li[name="Change shipped hour"]', moreMenuChangeShippedHour: '.vn-popover.shown .vn-drop-down li[name="Change shipped hour"]',
changeShippedHourDialog: 'vn-ticket-descriptor vn-dialog[vn-id="changeShippedDialog"]', changeShippedHourDialog: 'vn-ticket-descriptor vn-dialog[vn-id="changeShippedDialog"]',
changeShippedHourInput: 'vn-ticket-descriptor vn-dialog[vn-id="changeShippedDialog"] vn-input-time[vn-id="newShipped"]', changeShippedHourInput: 'vn-dialog[vn-id="changeShippedDialog"] [ng-model="$ctrl.newShipped"]',
addStowawayDialogFirstTicket: 'vn-ticket-descriptor > vn-add-stowaway > vn-dialog vn-table vn-tbody vn-tr', addStowawayDialogFirstTicket: 'vn-ticket-descriptor > vn-add-stowaway > vn-dialog vn-table vn-tbody vn-tr',
shipButton: 'vn-ticket-descriptor > div > div.body > div.quicklinks vn-icon[icon="icon-stowaway"]', shipButton: 'vn-ticket-descriptor > div > div.body > div.quicklinks vn-icon[icon="icon-stowaway"]',
thursdayButton: 'vn-ticket-descriptor > vn-dialog > div > form > div.body > tpl-body > div > vn-tool-bar > vn-button:nth-child(4)', thursdayButton: 'vn-ticket-descriptor > vn-dialog > div > form > div.body > tpl-body > div > vn-tool-bar > vn-button:nth-child(4)',
@ -671,7 +671,7 @@ export default {
saveButton: 'vn-worker-pbx vn-submit[label="Save"] input' saveButton: 'vn-worker-pbx vn-submit[label="Save"] input'
}, },
workerTimeControl: { workerTimeControl: {
timeDialogInput: 'vn-worker-time-control > vn-dialog input', timeDialogInput: '.vn-dialog.shown [ng-model="$ctrl.newTime"]',
mondayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(1) > vn-icon-button > button > vn-icon', mondayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(1) > vn-icon-button > button > vn-icon',
tuesdayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(2) > vn-icon-button > button > vn-icon', tuesdayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(2) > vn-icon-button > button > vn-icon',
wednesdayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(3) > vn-icon-button > button > vn-icon', wednesdayAddTimeButton: 'vn-worker-time-control > div > vn-card > div > vn-horizontal > vn-table > div > vn-tfoot > vn-tr:nth-child(2) > vn-td:nth-child(3) > vn-icon-button > button > vn-icon',

View File

@ -34,7 +34,7 @@ describe('Ticket descriptor path', () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketDescriptor.moreMenu) .waitToClick(selectors.ticketDescriptor.moreMenu)
.waitToClick(selectors.ticketDescriptor.moreMenuChangeShippedHour) .waitToClick(selectors.ticketDescriptor.moreMenuChangeShippedHour)
.write(selectors.ticketDescriptor.changeShippedHourInput, '08:15') .pickTime(selectors.ticketDescriptor.changeShippedHourInput, '08:15')
.waitToClick(selectors.ticketDescriptor.acceptChangeHourButton) .waitToClick(selectors.ticketDescriptor.acceptChangeHourButton)
.waitForLastSnackbar(); .waitForLastSnackbar();