Half way in improving e2e test infrastructure and refactoring tests to the enhanced (un)subscription process
This commit is contained in:
parent
62cc881fd4
commit
328034bae0
16 changed files with 482 additions and 153 deletions
|
@ -1,84 +1,94 @@
|
|||
'use strict';
|
||||
|
||||
const config = require('../helpers/config');
|
||||
const page = require('./page');
|
||||
const webBase = require('./web');
|
||||
const mailBase = require('./mail');
|
||||
|
||||
const web = {
|
||||
enterEmail(value) {
|
||||
this.element('emailInput').clear();
|
||||
return this.element('emailInput').sendKeys(value);
|
||||
}
|
||||
module.exports = (driver, list) => {
|
||||
|
||||
const web = params => webBase(driver, {
|
||||
async enterEmail(value) {
|
||||
const emailInput = await this.element('emailInput');
|
||||
await emailInput.clear();
|
||||
await emailInput.sendKeys(value);
|
||||
},
|
||||
}, params);
|
||||
|
||||
const mail = params => mailBase(driver, params);
|
||||
|
||||
return {
|
||||
webSubscribe: web({
|
||||
url: `/subscription/${list.cid}`,
|
||||
elementToWaitFor: 'form',
|
||||
elements: {
|
||||
form: `form[action="/subscription/${list.cid}/subscribe"]`,
|
||||
emailInput: '#main-form input[name="email"]',
|
||||
submitButton: 'a[href="#submit"]'
|
||||
}
|
||||
}),
|
||||
|
||||
webConfirmSubscriptionNotice: web({
|
||||
url: `/subscription/${list.cid}/confirm-subscription-notice`,
|
||||
elementToWaitFor: 'homepageButton',
|
||||
elements: {
|
||||
homepageButton: `a[href="${config.settings['default-homepage']}"]`
|
||||
}
|
||||
}),
|
||||
|
||||
mailConfirmSubscription: mail({
|
||||
elementToWaitFor: 'confirmLink',
|
||||
elements: {
|
||||
confirmLink: `a[href^="${config.settings['service-url']}subscription/confirm/subscribe/"]`
|
||||
}
|
||||
}),
|
||||
|
||||
webSubscribedNotice: web({
|
||||
url: `/subscription/${list.cid}/subscribed-notice`,
|
||||
elementToWaitFor: 'homepageButton',
|
||||
elements: {
|
||||
homepageButton: `a[href="${config.settings['default-homepage']}"]`
|
||||
}
|
||||
}),
|
||||
|
||||
mailSubscriptionConfirmed: mail({
|
||||
elementToWaitFor: 'unsubscribeLink',
|
||||
elements: {
|
||||
unsubscribeLink: `a[href^="${config.settings['service-url']}subscription/${list.cid}/unsubscribe/"]`,
|
||||
manageLink: `a[href^="${config.settings['service-url']}subscription/${list.cid}/manage/"]`
|
||||
}
|
||||
}),
|
||||
|
||||
/*
|
||||
webUnsubscribe: web({ // FIXME
|
||||
elementToWaitFor: 'submitButton',
|
||||
elements: {
|
||||
submitButton: 'a[href="#submit"]'
|
||||
}
|
||||
}),
|
||||
*/
|
||||
|
||||
webUnsubscribedNotice: web({
|
||||
url: `/subscription/${list.cid}/unsubscribed-notice`,
|
||||
elementToWaitFor: 'homepageButton',
|
||||
elements: {
|
||||
homepageButton: `a[href="${config.settings['default-homepage']}"]`
|
||||
}
|
||||
}),
|
||||
|
||||
mailUnsubscriptionConfirmed: mail({
|
||||
elementToWaitFor: 'resubscribeLink',
|
||||
elements: {
|
||||
resubscribeLink: `a[href^="${config.settings['service-url']}subscription/${list.cid}"]`
|
||||
}
|
||||
}),
|
||||
/* TODO
|
||||
webManage: web({
|
||||
url: `/subscription/${list.cid}/manage`,
|
||||
elementToWaitFor: 'homepageButton',
|
||||
elements: {
|
||||
homepageButton: `a[href="${config.settings['default-homepage']}"]`
|
||||
}
|
||||
}),
|
||||
*/
|
||||
};
|
||||
};
|
||||
|
||||
const mail = {
|
||||
navigate(address) {
|
||||
this.driver.sleep(100);
|
||||
this.driver.navigate().to(`http://localhost:${config.app.testserver.mailboxserverport}/${address}`);
|
||||
return this.waitUntilVisible();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = (driver, list) => ({
|
||||
|
||||
webSubscribe: Object.assign(page(driver), web, {
|
||||
url: `/subscription/${list.cid}`,
|
||||
elementToWaitFor: 'form',
|
||||
elements: {
|
||||
form: `form[action="/subscription/${list.cid}/subscribe"]`,
|
||||
emailInput: '#main-form input[name="email"]',
|
||||
submitButton: 'a[href="#submit"]'
|
||||
}
|
||||
}),
|
||||
|
||||
webConfirmSubscriptionNotice: Object.assign(page(driver), web, {
|
||||
url: `/subscription/${list.cid}/confirm-notice`,
|
||||
elementToWaitFor: 'homepageButton',
|
||||
elements: {
|
||||
homepageButton: `a[href="${config.settings['default-homepage']}"]`
|
||||
}
|
||||
}),
|
||||
|
||||
mailConfirmSubscription: Object.assign(page(driver), mail, {
|
||||
elementToWaitFor: 'confirmLink',
|
||||
elements: {
|
||||
confirmLink: `a[href^="${config.settings['service-url']}subscription/subscribe/"]`
|
||||
}
|
||||
}),
|
||||
|
||||
webSubscribedNotice: Object.assign(page(driver), web, {
|
||||
elementToWaitFor: 'homepageButton',
|
||||
elements: {
|
||||
homepageButton: 'a[href^="https://mailtrain.org"]'
|
||||
}
|
||||
}),
|
||||
|
||||
mailSubscriptionConfirmed: Object.assign(page(driver), mail, {
|
||||
elementToWaitFor: 'unsubscribeLink',
|
||||
elements: {
|
||||
unsubscribeLink: 'a[href*="/unsubscribe/"]',
|
||||
manageLink: 'a[href*="/manage/"]'
|
||||
}
|
||||
}),
|
||||
|
||||
webUnsubscribe: Object.assign(page(driver), web, {
|
||||
elementToWaitFor: 'submitButton',
|
||||
elements: {
|
||||
submitButton: 'a[href="#submit"]'
|
||||
}
|
||||
}),
|
||||
|
||||
webUnsubscribedNotice: Object.assign(page(driver), web, {
|
||||
elementToWaitFor: 'homepageButton',
|
||||
elements: {
|
||||
homepageButton: 'a[href^="https://mailtrain.org"]'
|
||||
}
|
||||
}),
|
||||
|
||||
mailUnsubscriptionConfirmed: Object.assign(page(driver), mail, {
|
||||
elementToWaitFor: 'resubscribeLink',
|
||||
elements: {
|
||||
resubscribeLink: `a[href^="${config.settings['service-url']}subscription/${list.cid}"]`
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue