e2e tests (draft)
This commit is contained in:
parent
408db13fd4
commit
6c35046ab2
26 changed files with 1659 additions and 29 deletions
57
test/e2e/tests/login.js
Normal file
57
test/e2e/tests/login.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
'use strict';
|
||||
|
||||
const config = require('../helpers/config');
|
||||
const expect = require('chai').expect;
|
||||
const driver = require('../helpers/driver');
|
||||
const home = require('../page-objects/home')(driver);
|
||||
const flash = require('../page-objects/flash')(driver);
|
||||
const {
|
||||
login,
|
||||
account
|
||||
} = require('../page-objects/users')(driver);
|
||||
|
||||
describe('login', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
before(() => driver.manage().deleteAllCookies());
|
||||
|
||||
it('can access home page', async () => {
|
||||
await home.navigate();
|
||||
});
|
||||
|
||||
it('can not access restricted content', async () => {
|
||||
driver.navigate().to(config.baseUrl + '/settings');
|
||||
flash.waitUntilVisible();
|
||||
expect(await flash.getText()).to.contain('Need to be logged in to access restricted content');
|
||||
await flash.clear();
|
||||
});
|
||||
|
||||
it('can not login with false credentials', async () => {
|
||||
login.enterUsername(config.users.admin.username);
|
||||
login.enterPassword('invalid');
|
||||
login.submit();
|
||||
flash.waitUntilVisible();
|
||||
expect(await flash.getText()).to.contain('Incorrect username or password');
|
||||
await flash.clear();
|
||||
});
|
||||
|
||||
it('can login as admin', async () => {
|
||||
login.enterUsername(config.users.admin.username);
|
||||
login.enterPassword(config.users.admin.password);
|
||||
login.submit();
|
||||
flash.waitUntilVisible();
|
||||
expect(await flash.getText()).to.contain('Logged in as admin');
|
||||
});
|
||||
|
||||
it('can access account page as admin', async () => {
|
||||
await account.navigate();
|
||||
});
|
||||
|
||||
it('can logout', async () => {
|
||||
driver.navigate().to(config.baseUrl + '/users/logout');
|
||||
flash.waitUntilVisible();
|
||||
expect(await flash.getText()).to.contain('logged out');
|
||||
});
|
||||
|
||||
after(() => driver.quit());
|
||||
});
|
101
test/e2e/tests/subscription.js
Normal file
101
test/e2e/tests/subscription.js
Normal file
|
@ -0,0 +1,101 @@
|
|||
'use strict';
|
||||
|
||||
const config = require('../helpers/config');
|
||||
const shortid = require('shortid');
|
||||
const expect = require('chai').expect;
|
||||
const driver = require('../helpers/driver');
|
||||
const Page = require('../page-objects/page');
|
||||
|
||||
const page = new Page(driver);
|
||||
const flash = require('../page-objects/flash')(driver);
|
||||
const {
|
||||
webSubscribe,
|
||||
webConfirmSubscriptionNotice,
|
||||
mailConfirmSubscription,
|
||||
webSubscribedNotice,
|
||||
mailSubscriptionConfirmed,
|
||||
webUnsubscribe,
|
||||
webUnsubscribedNotice,
|
||||
mailUnsubscriptionConfirmed
|
||||
} = require('../page-objects/subscription')(driver, config.lists.one);
|
||||
|
||||
const testuser = {
|
||||
email: 'keep.' + shortid.generate() + '@mailtrain.org'
|
||||
};
|
||||
|
||||
// console.log(testuser.email);
|
||||
|
||||
describe('subscribe (list one)', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
before(() => driver.manage().deleteAllCookies());
|
||||
|
||||
it('visits web-subscribe', async () => {
|
||||
await webSubscribe.navigate();
|
||||
});
|
||||
|
||||
it('submits invalid email (error)', async () => {
|
||||
webSubscribe.enterEmail('foo@bar.nope');
|
||||
webSubscribe.submit();
|
||||
flash.waitUntilVisible();
|
||||
expect(await flash.getText()).to.contain('Invalid email address');
|
||||
});
|
||||
|
||||
it('submits valid email', async () => {
|
||||
webSubscribe.enterEmail(testuser.email);
|
||||
await webSubscribe.submit();
|
||||
});
|
||||
|
||||
it('sees web-confirm-subscription-notice', async () => {
|
||||
webConfirmSubscriptionNotice.waitUntilVisible();
|
||||
expect(await page.containsText('Almost Finished')).to.be.true;
|
||||
});
|
||||
|
||||
it('receives mail-confirm-subscription', async () => {
|
||||
mailConfirmSubscription.navigate(testuser.email);
|
||||
expect(await page.containsText('Please Confirm Subscription')).to.be.true;
|
||||
});
|
||||
|
||||
it('clicks confirm subscription', async () => {
|
||||
await mailConfirmSubscription.click('confirmLink');
|
||||
});
|
||||
|
||||
it('sees web-subscribed-notice', async () => {
|
||||
webSubscribedNotice.waitUntilVisible();
|
||||
expect(await page.containsText('Subscription Confirmed')).to.be.true;
|
||||
});
|
||||
|
||||
it('receives mail-subscription-confirmed', async () => {
|
||||
mailSubscriptionConfirmed.navigate(testuser.email);
|
||||
expect(await page.containsText('Subscription Confirmed')).to.be.true;
|
||||
});
|
||||
});
|
||||
|
||||
describe('unsubscribe (list one)', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
it('clicks unsubscribe', async () => {
|
||||
await mailSubscriptionConfirmed.click('unsubscribeLink');
|
||||
});
|
||||
|
||||
it('sees web-unsubscribe', async () => {
|
||||
webUnsubscribe.waitUntilVisible();
|
||||
expect(await page.containsText('Unsubscribe')).to.be.true;
|
||||
});
|
||||
|
||||
it('clicks confirm unsubscription', async () => {
|
||||
await webUnsubscribe.submit();
|
||||
});
|
||||
|
||||
it('sees web-unsubscribed-notice', async () => {
|
||||
webUnsubscribedNotice.waitUntilVisible();
|
||||
expect(await page.containsText('Unsubscribe Successful')).to.be.true;
|
||||
});
|
||||
|
||||
it('receives mail-unsubscription-confirmed', async () => {
|
||||
mailUnsubscriptionConfirmed.navigate(testuser.email);
|
||||
expect(await page.containsText('You Are Now Unsubscribed')).to.be.true;
|
||||
});
|
||||
|
||||
after(() => driver.quit());
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue