Fixed eslint errors.
This commit is contained in:
parent
c11d1a1cbf
commit
c17bc9f2cf
10 changed files with 268 additions and 280 deletions
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
require('./lib/exit-unless-test');
|
require('./lib/exit-unless-test');
|
||||||
const { mocha, driver } = require('./lib/mocha-e2e');
|
const { mocha } = require('./lib/mocha-e2e');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
global.USE_SHARED_DRIVER = true;
|
global.USE_SHARED_DRIVER = true;
|
||||||
|
|
|
@ -12,8 +12,8 @@ module.exports = (...extras) => page({
|
||||||
await this.waitUntilVisible();
|
await this.waitUntilVisible();
|
||||||
},
|
},
|
||||||
|
|
||||||
async ensureUrl(path) {
|
async ensureUrl() {
|
||||||
throw new Error('Unsupported method.');
|
throw new Error('Unsupported method.');
|
||||||
},
|
}
|
||||||
|
|
||||||
}, ...extras);
|
}, ...extras);
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
const Mocha = require('mocha');
|
const Mocha = require('mocha');
|
||||||
const color = Mocha.reporters.Base.color;
|
const color = Mocha.reporters.Base.color;
|
||||||
const Semaphore = require('./semaphore');
|
const WorkerCounter = require('./worker-counter');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
const webdriver = require('selenium-webdriver');
|
const webdriver = require('selenium-webdriver');
|
||||||
|
@ -12,7 +14,7 @@ const driver = new webdriver.Builder()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
const failHandlerRunning = new Semaphore();
|
const failHandlerRunning = new WorkerCounter();
|
||||||
|
|
||||||
|
|
||||||
function UseCaseReporter(runner) {
|
function UseCaseReporter(runner) {
|
||||||
|
@ -25,7 +27,7 @@ function UseCaseReporter(runner) {
|
||||||
return Array(indents).join(' ');
|
return Array(indents).join(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
runner.on('start', function () {
|
runner.on('start', () => {
|
||||||
console.log();
|
console.log();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -104,7 +106,7 @@ function UseCaseReporter(runner) {
|
||||||
console.log();
|
console.log();
|
||||||
console.log(err);
|
console.log(err);
|
||||||
console.log();
|
console.log();
|
||||||
console.log(`Snaphot of and info about the current page are in last-failed-e2e-test.*`);
|
console.log('Snaphot of and info about the current page are in last-failed-e2e-test.*');
|
||||||
});
|
});
|
||||||
|
|
||||||
runner.on('end', () => {
|
runner.on('end', () => {
|
||||||
|
@ -174,13 +176,9 @@ function useCase(name, asyncFn) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useCase.only = (name, asyncFn) => {
|
useCase.only = (name, asyncFn) => test.only('Use case: ' + name, () => useCaseExec(name, asyncFn));
|
||||||
return test.only('Use case: ' + name, () => useCaseExec(name, asyncFn));
|
|
||||||
};
|
|
||||||
|
|
||||||
useCase.skip = (name, asyncFn) => {
|
useCase.skip = (name, asyncFn) => test.skip('Use case: ' + name, () => useCaseExec(name, asyncFn));
|
||||||
return test.skip('Use case: ' + name, () => useCaseExec(name, asyncFn));
|
|
||||||
};
|
|
||||||
|
|
||||||
async function step(name, asyncFn) {
|
async function step(name, asyncFn) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const config = require('./config');
|
|
||||||
const webdriver = require('selenium-webdriver');
|
const webdriver = require('selenium-webdriver');
|
||||||
const By = webdriver.By;
|
const By = webdriver.By;
|
||||||
const until = webdriver.until;
|
const until = webdriver.until;
|
||||||
|
@ -33,7 +32,7 @@ module.exports = (...extras) => Object.assign({
|
||||||
return params;
|
return params;
|
||||||
},
|
},
|
||||||
|
|
||||||
async waitUntilVisible(selector) {
|
async waitUntilVisible() {
|
||||||
await driver.wait(until.elementLocated(By.css('body')), waitTimeout);
|
await driver.wait(until.elementLocated(By.css('body')), waitTimeout);
|
||||||
|
|
||||||
for (const elem of (this.elementsToWaitFor || [])) {
|
for (const elem of (this.elementsToWaitFor || [])) {
|
||||||
|
@ -45,9 +44,7 @@ module.exports = (...extras) => Object.assign({
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const text of (this.textsToWaitFor || [])) {
|
for (const text of (this.textsToWaitFor || [])) {
|
||||||
await driver.wait(new webdriver.Condition(`for text "${text}"`, async (driver) => {
|
await driver.wait(new webdriver.Condition(`for text "${text}"`, async () => await this.containsText(text)), waitTimeout);
|
||||||
return await this.containsText(text);
|
|
||||||
}), waitTimeout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.url) {
|
if (this.url) {
|
||||||
|
@ -57,13 +54,13 @@ module.exports = (...extras) => Object.assign({
|
||||||
await driver.executeScript('document.mailTrainRefreshAcknowledged = true;');
|
await driver.executeScript('document.mailTrainRefreshAcknowledged = true;');
|
||||||
},
|
},
|
||||||
|
|
||||||
async waitUntilVisibleAfterRefresh(selector) {
|
async waitUntilVisibleAfterRefresh() {
|
||||||
await driver.wait(new webdriver.Condition('for refresh', async (driver) => {
|
await driver.wait(new webdriver.Condition('for refresh', async driver => {
|
||||||
const val = await driver.executeScript('return document.mailTrainRefreshAcknowledged;');
|
const val = await driver.executeScript('return document.mailTrainRefreshAcknowledged;');
|
||||||
return !val;
|
return !val;
|
||||||
}), waitTimeout);
|
}), waitTimeout);
|
||||||
|
|
||||||
await this.waitUntilVisible(selector);
|
await this.waitUntilVisible();
|
||||||
},
|
},
|
||||||
|
|
||||||
async click(key) {
|
async click(key) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ module.exports = (...extras) => page({
|
||||||
path = pathOrParams;
|
path = pathOrParams;
|
||||||
} else {
|
} else {
|
||||||
const urlPattern = new UrlPattern(this.requestUrl || this.url);
|
const urlPattern = new UrlPattern(this.requestUrl || this.url);
|
||||||
path = urlPattern.stringify(pathOrParams)
|
path = urlPattern.stringify(pathOrParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsedUrl = url.parse(path);
|
const parsedUrl = url.parse(path);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const Promise = require('bluebird');
|
const Promise = require('bluebird');
|
||||||
|
|
||||||
class Semaphore {
|
class WorkerCounter {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.counter = 0;
|
this.counter = 0;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ class Semaphore {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
function wait(resolve) {
|
function wait(resolve) {
|
||||||
if (self.counter == 0) {
|
if (self.counter === 0) {
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
setTimeout(wait, 500, resolve);
|
setTimeout(wait, 500, resolve);
|
||||||
|
@ -28,8 +28,8 @@ class Semaphore {
|
||||||
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
setTimeout(wait, 500, resolve);
|
setTimeout(wait, 500, resolve);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Semaphore;
|
module.exports = WorkerCounter;
|
|
@ -88,7 +88,7 @@ module.exports = list => ({
|
||||||
form: `form[action="/subscription/${list.cid}/manage-address"]`,
|
form: `form[action="/subscription/${list.cid}/manage-address"]`,
|
||||||
emailInput: '#main-form input[name="email"]',
|
emailInput: '#main-form input[name="email"]',
|
||||||
emailNewInput: '#main-form input[name="email-new"]',
|
emailNewInput: '#main-form input[name="email-new"]',
|
||||||
submitButton: 'a[href="#submit"]',
|
submitButton: 'a[href="#submit"]'
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -102,12 +102,12 @@ module.exports = list => ({
|
||||||
|
|
||||||
webUpdatedNotice: web({
|
webUpdatedNotice: web({
|
||||||
url: `/subscription/${list.cid}/updated-notice`,
|
url: `/subscription/${list.cid}/updated-notice`,
|
||||||
textsToWaitFor: ['Profile Updated'],
|
textsToWaitFor: ['Profile Updated']
|
||||||
}),
|
}),
|
||||||
|
|
||||||
webUnsubscribedNotice: web({
|
webUnsubscribedNotice: web({
|
||||||
url: `/subscription/${list.cid}/unsubscribed-notice`,
|
url: `/subscription/${list.cid}/unsubscribed-notice`,
|
||||||
textsToWaitFor: ['Unsubscribe Successful'],
|
textsToWaitFor: ['Unsubscribe Successful']
|
||||||
}),
|
}),
|
||||||
|
|
||||||
mailUnsubscriptionConfirmed: mail({
|
mailUnsubscriptionConfirmed: mail({
|
||||||
|
@ -116,17 +116,6 @@ module.exports = list => ({
|
||||||
elements: {
|
elements: {
|
||||||
resubscribeLink: `a[href^="${config.settings['service-url']}subscription/${list.cid}"]`
|
resubscribeLink: `a[href^="${config.settings['service-url']}subscription/${list.cid}"]`
|
||||||
}
|
}
|
||||||
}),
|
})
|
||||||
|
|
||||||
/*
|
|
||||||
webUnsubscribe: web({ // FIXME
|
|
||||||
elementsToWaitFor: ['submitButton'],
|
|
||||||
elements: {
|
|
||||||
submitButton: 'a[href="#submit"]'
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@ module.exports = {
|
||||||
url: '/users/account',
|
url: '/users/account',
|
||||||
elementsToWaitFor: ['form'],
|
elementsToWaitFor: ['form'],
|
||||||
elements: {
|
elements: {
|
||||||
form: `form[action="/users/account"]`,
|
form: 'form[action="/users/account"]',
|
||||||
emailInput: 'form[action="/users/account"] input[name="email"]'
|
emailInput: 'form[action="/users/account"] input[name="email"]'
|
||||||
}
|
}
|
||||||
}),
|
})
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/* eslint-disable prefer-arrow-callback */
|
||||||
|
|
||||||
const config = require('../lib/config');
|
const config = require('../lib/config');
|
||||||
const { useCase, step, driver } = require('../lib/mocha-e2e');
|
const { useCase, step, driver } = require('../lib/mocha-e2e');
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/* eslint-disable prefer-arrow-callback */
|
||||||
|
|
||||||
const config = require('../lib/config');
|
const config = require('../lib/config');
|
||||||
const { useCase, step, precondition, driver } = require('../lib/mocha-e2e');
|
const { useCase, step, precondition, driver } = require('../lib/mocha-e2e');
|
||||||
const shortid = require('shortid');
|
const shortid = require('shortid');
|
||||||
|
|
Loading…
Reference in a new issue