Remaining e2e subscription tests
@bures, I’m not too happy with switchToList(). Suggestions? If we keep it, it should probably be added to every useCase.
This commit is contained in:
parent
2c930c60d2
commit
19a563bc6a
4 changed files with 410 additions and 27 deletions
|
@ -13,15 +13,46 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
lists: {
|
||||
one: {
|
||||
l1: {
|
||||
id: 1,
|
||||
cid: 'Hkj1vCoJb',
|
||||
publicSubscribe: 1,
|
||||
unsubscriptionMode: 0
|
||||
unsubscriptionMode: 0, // (one-step, no form)
|
||||
},
|
||||
l2: {
|
||||
id: 2,
|
||||
cid: 'SktV4HDZ-',
|
||||
publicSubscribe: 1,
|
||||
unsubscriptionMode: 1, // (one-step, with form)
|
||||
},
|
||||
l3: {
|
||||
id: 3,
|
||||
cid: 'BkdvNBw-W',
|
||||
publicSubscribe: 1,
|
||||
unsubscriptionMode: 2, // (two-step, no form)
|
||||
},
|
||||
l4: {
|
||||
id: 4,
|
||||
cid: 'rJMKVrDZ-',
|
||||
publicSubscribe: 1,
|
||||
unsubscriptionMode: 3, // (two-step, with form)
|
||||
},
|
||||
l5: {
|
||||
id: 5,
|
||||
cid: 'SJgoNSw-W',
|
||||
publicSubscribe: 1,
|
||||
unsubscriptionMode: 4, // (manual unsubscribe)
|
||||
},
|
||||
l6: {
|
||||
id: 6,
|
||||
cid: 'HyveEPvWW',
|
||||
publicSubscribe: 0,
|
||||
unsubscriptionMode: 0, // (one-step, no form)
|
||||
}
|
||||
},
|
||||
settings: {
|
||||
'service-url' : 'http://localhost:' + config.www.port + '/',
|
||||
'service-url': 'http://localhost:' + config.www.port + '/',
|
||||
'admin-email': 'admin@example.com',
|
||||
'default-homepage': 'https://mailtrain.org',
|
||||
'smtp-hostname': config.testserver.host,
|
||||
'smtp-port': config.testserver.port,
|
||||
|
|
|
@ -19,6 +19,11 @@ module.exports = list => ({
|
|||
}
|
||||
}),
|
||||
|
||||
webSubscribeNonPublic: web({
|
||||
url: `/subscription/${list.cid}`,
|
||||
textsToWaitFor: ['The list does not allow public subscriptions'],
|
||||
}),
|
||||
|
||||
webConfirmSubscriptionNotice: web({
|
||||
url: `/subscription/${list.cid}/confirm-subscription-notice`,
|
||||
textsToWaitFor: ['We need to confirm your email address']
|
||||
|
@ -118,15 +123,34 @@ module.exports = list => ({
|
|||
}
|
||||
}),
|
||||
|
||||
/*
|
||||
webUnsubscribe: web({ // FIXME
|
||||
webUnsubscribe: web({
|
||||
elementsToWaitFor: ['submitButton'],
|
||||
textsToWaitFor: ['Unsubscribe'],
|
||||
elements: {
|
||||
submitButton: 'a[href="#submit"]'
|
||||
}
|
||||
}),
|
||||
|
||||
*/
|
||||
webConfirmUnsubscriptionNotice: web({
|
||||
url: `/subscription/${list.cid}/confirm-unsubscription-notice`,
|
||||
textsToWaitFor: ['We need to confirm your email address']
|
||||
}),
|
||||
|
||||
mailConfirmUnsubscription: mail({
|
||||
elementsToWaitFor: ['confirmLink'],
|
||||
textsToWaitFor: ['Please Confirm Unsubscription'],
|
||||
elements: {
|
||||
confirmLink: `a[href^="${config.settings['service-url']}subscription/confirm/unsubscribe/"]`
|
||||
}
|
||||
}),
|
||||
|
||||
webManualUnsubscribeNotice: web({
|
||||
url: `/subscription/${list.cid}/manual-unsubscribe-notice`,
|
||||
elementsToWaitFor: ['contactLink'],
|
||||
textsToWaitFor: ['Online Unsubscription Is Not Possible', config.settings['admin-email']],
|
||||
elements: {
|
||||
contactLink: `a[href^="mailto:${config.settings['admin-email']}"]`
|
||||
}
|
||||
}),
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -4,8 +4,13 @@ const config = require('../lib/config');
|
|||
const { useCase, step, precondition, driver } = require('../lib/mocha-e2e');
|
||||
const shortid = require('shortid');
|
||||
const expect = require('chai').expect;
|
||||
const createPage = require('../page-objects/subscription');
|
||||
|
||||
const page = require('../page-objects/subscription')(config.lists.one);
|
||||
let page = createPage(config.lists.l1);
|
||||
|
||||
function switchToList(list) {
|
||||
page = createPage(config.lists[list]);
|
||||
}
|
||||
|
||||
function generateEmail() {
|
||||
return 'keep.' + shortid.generate() + '@mailtrain.org';
|
||||
|
@ -116,9 +121,17 @@ suite('Subscription use-cases', () => {
|
|||
|
||||
});
|
||||
|
||||
useCase('Subscription to a non-public list');
|
||||
useCase('Subscription to a non-public list', async () => {
|
||||
switchToList('l6');
|
||||
|
||||
await step('User navigates to list subscription page and sees message that this list does not allow public subscriptions.', async () => {
|
||||
await page.webSubscribeNonPublic.navigate();
|
||||
});
|
||||
});
|
||||
|
||||
useCase('Change profile info', async () => {
|
||||
switchToList('l1');
|
||||
|
||||
const subscription = await subscriptionExistsPrecondition({
|
||||
email: generateEmail(),
|
||||
firstName: 'John',
|
||||
|
@ -236,13 +249,181 @@ suite('Subscription use-cases', () => {
|
|||
});
|
||||
});
|
||||
|
||||
useCase('Unsubscription from list #2 (one-step, with form).');
|
||||
useCase('Unsubscription from list #2 (one-step, with form).', async () => {
|
||||
switchToList('l2');
|
||||
|
||||
useCase('Unsubscription from list #3 (two-step, no form).');
|
||||
const subscription = await subscriptionExistsPrecondition({
|
||||
email: generateEmail()
|
||||
});
|
||||
|
||||
useCase('Unsubscription from list #4 (two-step, with form).');
|
||||
await step('User clicks the unsubscribe button.', async () => {
|
||||
await page.mailSubscriptionConfirmed.click('unsubscribeLink');
|
||||
});
|
||||
|
||||
useCase('Unsubscription from list #5 (manual unsubscribe).');
|
||||
await step('Systems shows a form to unsubscribe.', async () => {
|
||||
await page.webUnsubscribe.waitUntilVisibleAfterRefresh();
|
||||
});
|
||||
|
||||
await step('User confirms unsubscribe and clicks the unsubscribe button.', async () => {
|
||||
await page.webUnsubscribe.submit();
|
||||
});
|
||||
|
||||
await step('System shows a notice that confirms unsubscription.', async () => {
|
||||
await page.webUnsubscribedNotice.waitUntilVisibleAfterRefresh();
|
||||
});
|
||||
|
||||
await step('System sends an email that confirms unsubscription.', async () => {
|
||||
await page.mailUnsubscriptionConfirmed.fetchMail(subscription.email);
|
||||
});
|
||||
});
|
||||
|
||||
useCase('Unsubscription from list #3 (two-step, no form).', async () => {
|
||||
switchToList('l3');
|
||||
|
||||
const subscription = await subscriptionExistsPrecondition({
|
||||
email: generateEmail()
|
||||
});
|
||||
|
||||
await step('User clicks the unsubscribe button.', async () => {
|
||||
await page.mailSubscriptionConfirmed.click('unsubscribeLink');
|
||||
});
|
||||
|
||||
await step('System shows a notice that further instructions are in the email.', async () => {
|
||||
await page.webConfirmUnsubscriptionNotice.waitUntilVisibleAfterRefresh();
|
||||
});
|
||||
|
||||
await step('System sends an email with a link to confirm unsubscription.', async () => {
|
||||
await page.mailConfirmUnsubscription.fetchMail(subscription.email);
|
||||
});
|
||||
|
||||
await step('User clicks the confirm unsubscribe button in the email.', async () => {
|
||||
await page.mailConfirmUnsubscription.click('confirmLink');
|
||||
});
|
||||
|
||||
await step('System shows a notice that confirms unsubscription.', async () => {
|
||||
await page.webUnsubscribedNotice.waitUntilVisibleAfterRefresh();
|
||||
});
|
||||
|
||||
await step('System sends an email that confirms unsubscription.', async () => {
|
||||
await page.mailUnsubscriptionConfirmed.fetchMail(subscription.email);
|
||||
});
|
||||
});
|
||||
|
||||
useCase('Unsubscription from list #4 (two-step, with form).', async () => {
|
||||
switchToList('l4');
|
||||
|
||||
const subscription = await subscriptionExistsPrecondition({
|
||||
email: generateEmail()
|
||||
});
|
||||
|
||||
await step('User clicks the unsubscribe button.', async () => {
|
||||
await page.mailSubscriptionConfirmed.click('unsubscribeLink');
|
||||
});
|
||||
|
||||
await step('Systems shows a form to unsubscribe.', async () => {
|
||||
await page.webUnsubscribe.waitUntilVisibleAfterRefresh();
|
||||
});
|
||||
|
||||
await step('User confirms unsubscribe and clicks the unsubscribe button.', async () => {
|
||||
await page.webUnsubscribe.submit();
|
||||
});
|
||||
|
||||
await step('System shows a notice that further instructions are in the email.', async () => {
|
||||
await page.webConfirmUnsubscriptionNotice.waitUntilVisibleAfterRefresh();
|
||||
});
|
||||
|
||||
await step('System sends an email with a link to confirm unsubscription.', async () => {
|
||||
await page.mailConfirmUnsubscription.fetchMail(subscription.email);
|
||||
});
|
||||
|
||||
await step('User clicks the confirm unsubscribe button in the email.', async () => {
|
||||
await page.mailConfirmUnsubscription.click('confirmLink');
|
||||
});
|
||||
|
||||
await step('System shows a notice that confirms unsubscription.', async () => {
|
||||
await page.webUnsubscribedNotice.waitUntilVisibleAfterRefresh();
|
||||
});
|
||||
|
||||
await step('System sends an email that confirms unsubscription.', async () => {
|
||||
await page.mailUnsubscriptionConfirmed.fetchMail(subscription.email);
|
||||
});
|
||||
});
|
||||
|
||||
useCase('Unsubscription from list #5 (manual unsubscribe).', async () => {
|
||||
switchToList('l5');
|
||||
|
||||
await subscriptionExistsPrecondition({
|
||||
email: generateEmail()
|
||||
});
|
||||
|
||||
await step('User clicks the unsubscribe button.', async () => {
|
||||
await page.mailSubscriptionConfirmed.click('unsubscribeLink');
|
||||
});
|
||||
|
||||
await step('Systems shows a notice that online unsubscription is not possible.', async () => {
|
||||
await page.webManualUnsubscribeNotice.waitUntilVisibleAfterRefresh();
|
||||
});
|
||||
});
|
||||
|
||||
useCase('Resubscription.', async () => {
|
||||
switchToList('l1');
|
||||
|
||||
const subscription = await subscriptionExistsPrecondition({
|
||||
email: generateEmail(),
|
||||
firstName: 'John',
|
||||
lastName: 'Doe'
|
||||
});
|
||||
|
||||
await step('User clicks the unsubscribe button.', async () => {
|
||||
await page.mailSubscriptionConfirmed.click('unsubscribeLink');
|
||||
});
|
||||
|
||||
await step('System shows a notice that confirms unsubscription.', async () => {
|
||||
await page.webUnsubscribedNotice.waitUntilVisibleAfterRefresh();
|
||||
});
|
||||
|
||||
await step('System sends an email that confirms unsubscription.', async () => {
|
||||
await page.mailUnsubscriptionConfirmed.fetchMail(subscription.email);
|
||||
});
|
||||
|
||||
await step('User clicks the resubscribe button.', async () => {
|
||||
await page.mailUnsubscriptionConfirmed.click('resubscribeLink');
|
||||
});
|
||||
|
||||
await step('Systems shows the subscription form. The form contains data entered during initial subscription.', async () => {
|
||||
await page.webSubscribe.waitUntilVisibleAfterRefresh();
|
||||
expect(await page.webSubscribe.getValue('emailInput')).to.equal(subscription.email);
|
||||
expect(await page.webSubscribe.getValue('firstNameInput')).to.equal(subscription.firstName);
|
||||
expect(await page.webSubscribe.getValue('lastNameInput')).to.equal(subscription.lastName);
|
||||
});
|
||||
|
||||
await step('User submits the subscription form.', async () => {
|
||||
await page.webSubscribe.submit();
|
||||
});
|
||||
|
||||
await step('System shows a notice that further instructions are in the email.', async () => {
|
||||
await page.webConfirmSubscriptionNotice.waitUntilVisibleAfterRefresh();
|
||||
});
|
||||
|
||||
await step('System sends an email with a link to confirm the subscription.', async () => {
|
||||
await page.mailConfirmSubscription.fetchMail(subscription.email);
|
||||
});
|
||||
|
||||
await step('User clicks confirm subscription in the email', async () => {
|
||||
await page.mailConfirmSubscription.click('confirmLink');
|
||||
});
|
||||
|
||||
await step('System shows a notice that subscription has been confirmed.', async () => {
|
||||
await page.webSubscribedNotice.waitUntilVisibleAfterRefresh();
|
||||
});
|
||||
|
||||
await step('System sends an email with subscription confirmation. The manage and unsubscribe links are identical with the initial subscription.', async () => {
|
||||
await page.mailSubscriptionConfirmed.fetchMail(subscription.email);
|
||||
const unsubscribeLink = await page.mailSubscriptionConfirmed.getHref('unsubscribeLink');
|
||||
const manageLink = await page.mailSubscriptionConfirmed.getHref('manageLink');
|
||||
expect(subscription.unsubscribeLink).to.equal(unsubscribeLink);
|
||||
expect(subscription.manageLink).to.equal(manageLink);
|
||||
});
|
||||
});
|
||||
|
||||
useCase('Resubscription.'); // This one is supposed to check that values pre-filled in resubscription (i.e. the re-subscribe link in unsubscription confirmation) are the same as the ones used before.
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue