2017-05-29 21:50:03 +03:00
|
|
|
import moment from 'moment';
|
2017-01-02 21:50:36 +03:00
|
|
|
import {Response} from 'ember-cli-mirage';
|
2019-01-02 12:58:55 +03:00
|
|
|
import {authenticateSession, invalidateSession} from 'ember-simple-auth/test-support';
|
|
|
|
import {beforeEach, describe, it} from 'mocha';
|
|
|
|
import {blur, click, currentURL, fillIn, find, findAll} from '@ember/test-helpers';
|
2017-05-29 21:50:03 +03:00
|
|
|
import {expect} from 'chai';
|
2019-01-02 12:58:55 +03:00
|
|
|
import {setupApplicationTest} from 'ember-mocha';
|
2019-05-27 11:37:05 +03:00
|
|
|
import {setupMirage} from 'ember-cli-mirage/test-support';
|
2019-01-02 12:58:55 +03:00
|
|
|
import {visit} from '../helpers/visit';
|
2015-11-26 13:39:37 +03:00
|
|
|
|
|
|
|
describe('Acceptance: Setup', function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
let hooks = setupApplicationTest();
|
|
|
|
setupMirage(hooks);
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
it('redirects if already authenticated', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
let role = this.server.create('role', {name: 'Author'});
|
|
|
|
this.server.create('user', {roles: [role], slug: 'test-user'});
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await authenticateSession();
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
await visit('/setup/one');
|
2019-03-21 12:33:14 +03:00
|
|
|
expect(currentURL()).to.equal('/site');
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
await visit('/setup/two');
|
2019-03-21 12:33:14 +03:00
|
|
|
expect(currentURL()).to.equal('/site');
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
await visit('/setup/three');
|
2019-03-21 12:33:14 +03:00
|
|
|
expect(currentURL()).to.equal('/site');
|
2015-11-26 13:39:37 +03:00
|
|
|
});
|
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
it('redirects to signin if already set up', async function () {
|
2015-11-26 13:39:37 +03:00
|
|
|
// mimick an already setup blog
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.get('/authentication/setup/', function () {
|
2015-11-26 13:39:37 +03:00
|
|
|
return {
|
|
|
|
setup: [
|
|
|
|
{status: true}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await invalidateSession();
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
await visit('/setup');
|
|
|
|
expect(currentURL()).to.equal('/signin');
|
2015-11-26 13:39:37 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('with a new blog', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
// mimick a new blog
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.get('/authentication/setup/', function () {
|
2015-11-26 13:39:37 +03:00
|
|
|
return {
|
|
|
|
setup: [
|
|
|
|
{status: false}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
it('has a successful happy path', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
await invalidateSession();
|
|
|
|
this.server.loadFixtures('roles');
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
await visit('/setup');
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// it redirects to step one
|
|
|
|
expect(currentURL(), 'url after accessing /setup')
|
|
|
|
.to.equal('/setup/one');
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// it highlights first step
|
2019-01-02 12:58:55 +03:00
|
|
|
let stepIcons = findAll('.gh-flow-nav .step');
|
|
|
|
expect(stepIcons.length, 'sanity check: three steps').to.equal(3);
|
|
|
|
expect(stepIcons[0], 'first step').to.have.class('active');
|
|
|
|
expect(stepIcons[1], 'second step').to.not.have.class('active');
|
|
|
|
expect(stepIcons[2], 'third step').to.not.have.class('active');
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// it displays download count (count increments for each ajax call
|
|
|
|
// and polling is disabled in testing so our count should be "1"
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('.gh-flow-content em').textContent.trim()).to.equal('1');
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
await click('.gh-btn-green');
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// it transitions to step two
|
|
|
|
expect(currentURL(), 'url after clicking "Create your account"')
|
|
|
|
.to.equal('/setup/two');
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// email field is focused by default
|
|
|
|
// NOTE: $('x').is(':focus') doesn't work in phantomjs CLI runner
|
|
|
|
// https://github.com/ariya/phantomjs/issues/10427
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(findAll('[data-test-blog-title-input]')[0] === document.activeElement, 'blog title has focus')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.be.true;
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
await click('.gh-btn-green');
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// it marks fields as invalid
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(findAll('.form-group.error').length, 'number of invalid fields')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal(4);
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// it displays error messages
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(findAll('.error .response').length, 'number of in-line validation messages')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal(4);
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// it displays main error
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(findAll('.main-error').length, 'main error is displayed')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal(1);
|
2015-11-26 13:39:37 +03:00
|
|
|
|
|
|
|
// enter valid details and submit
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-email-input]', 'test@example.com');
|
|
|
|
await fillIn('[data-test-name-input]', 'Test User');
|
2017-10-26 13:02:17 +03:00
|
|
|
await fillIn('[data-test-password-input]', 'thisissupersafe');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-blog-title-input]', 'Blog Title');
|
2017-04-24 15:29:48 +03:00
|
|
|
await click('.gh-btn-green');
|
|
|
|
|
|
|
|
// it transitions to step 3
|
|
|
|
expect(currentURL(), 'url after submitting step two')
|
|
|
|
.to.equal('/setup/three');
|
|
|
|
|
|
|
|
// submit button is "disabled"
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('button[type="submit"]').classList.contains('gh-btn-green'), 'invite button with no emails is white')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.be.false;
|
2015-11-26 13:39:37 +03:00
|
|
|
|
|
|
|
// fill in a valid email
|
2017-04-24 15:29:48 +03:00
|
|
|
await fillIn('[name="users"]', 'new-user@example.com');
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// submit button is "enabled"
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('button[type="submit"]').classList.contains('gh-btn-green'), 'invite button is green with valid email address')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.be.true;
|
2015-11-26 13:39:37 +03:00
|
|
|
|
|
|
|
// submit the invite form
|
2017-04-24 15:29:48 +03:00
|
|
|
await click('button[type="submit"]');
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// it redirects to the home / "content" screen
|
|
|
|
expect(currentURL(), 'url after submitting invites')
|
2019-03-21 12:33:14 +03:00
|
|
|
.to.equal('/site');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// it displays success alert
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(findAll('.gh-alert-green').length, 'number of success alerts')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal(1);
|
2015-11-26 13:39:37 +03:00
|
|
|
});
|
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
it('handles validation errors in step 2', async function () {
|
2016-01-05 20:01:42 +03:00
|
|
|
let postCount = 0;
|
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await invalidateSession();
|
|
|
|
this.server.loadFixtures('roles');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.post('/authentication/setup', function () {
|
2018-01-05 18:38:23 +03:00
|
|
|
postCount += 1;
|
2016-01-05 20:01:42 +03:00
|
|
|
|
|
|
|
// validation error
|
|
|
|
if (postCount === 1) {
|
2017-01-02 21:50:36 +03:00
|
|
|
return new Response(422, {}, {
|
2016-01-05 20:01:42 +03:00
|
|
|
errors: [
|
|
|
|
{
|
2019-03-25 14:29:14 +03:00
|
|
|
type: 'ValidationError',
|
2016-01-05 20:01:42 +03:00
|
|
|
message: 'Server response message'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// server error
|
|
|
|
if (postCount === 2) {
|
2017-01-02 21:50:36 +03:00
|
|
|
return new Response(500, {}, null);
|
2016-01-05 20:01:42 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
await visit('/setup/two');
|
|
|
|
await click('.gh-btn-green');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// non-server validation
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('.main-error').textContent.trim(), 'error text')
|
2018-03-26 13:41:45 +03:00
|
|
|
.to.not.be.empty;
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-email-input]', 'test@example.com');
|
|
|
|
await fillIn('[data-test-name-input]', 'Test User');
|
2017-10-26 13:02:17 +03:00
|
|
|
await fillIn('[data-test-password-input]', 'thisissupersafe');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-blog-title-input]', 'Blog Title');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
|
|
|
// first post - simulated validation error
|
2017-04-24 15:29:48 +03:00
|
|
|
await click('.gh-btn-green');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('.main-error').textContent.trim(), 'error text')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('Server response message');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
|
|
|
// second post - simulated server error
|
2017-04-24 15:29:48 +03:00
|
|
|
await click('.gh-btn-green');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('.main-error').textContent.trim(), 'error text')
|
2018-03-26 13:41:45 +03:00
|
|
|
.to.be.empty;
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(findAll('.gh-alert-red').length, 'number of alerts')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal(1);
|
2016-01-05 20:01:42 +03:00
|
|
|
});
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
it('handles invalid origin error on step 2', async function () {
|
2015-11-26 13:39:37 +03:00
|
|
|
// mimick the API response for an invalid origin
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.post('/session', function () {
|
2017-01-02 21:50:36 +03:00
|
|
|
return new Response(401, {}, {
|
2015-11-26 13:39:37 +03:00
|
|
|
errors: [
|
|
|
|
{
|
2019-03-25 14:29:14 +03:00
|
|
|
type: 'UnauthorizedError',
|
2015-11-26 13:39:37 +03:00
|
|
|
message: 'Access Denied from url: unknown.com. Please use the url configured in config.js.'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await invalidateSession();
|
|
|
|
this.server.loadFixtures('roles');
|
2015-11-26 13:39:37 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
await visit('/setup/two');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-email-input]', 'test@example.com');
|
|
|
|
await fillIn('[data-test-name-input]', 'Test User');
|
2017-10-26 13:02:17 +03:00
|
|
|
await fillIn('[data-test-password-input]', 'thisissupersafe');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-blog-title-input]', 'Blog Title');
|
2017-04-24 15:29:48 +03:00
|
|
|
await click('.gh-btn-green');
|
|
|
|
|
|
|
|
// button should not be spinning
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(findAll('.gh-btn-green .spinner').length, 'button has spinner')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal(0);
|
|
|
|
// we should show an error message
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('.main-error').textContent, 'error text')
|
2018-02-07 12:30:04 +03:00
|
|
|
.to.have.string('Access Denied from url: unknown.com. Please use the url configured in config.js.');
|
2015-11-26 13:39:37 +03:00
|
|
|
});
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
it('handles validation errors in step 3', async function () {
|
2016-01-05 20:01:42 +03:00
|
|
|
let input = '[name="users"]';
|
|
|
|
let postCount = 0;
|
2017-01-02 21:50:36 +03:00
|
|
|
let button, formGroup;
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await invalidateSession();
|
|
|
|
this.server.loadFixtures('roles');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.post('/invites/', function ({invites}) {
|
2017-09-28 05:33:00 +03:00
|
|
|
let attrs = this.normalizedRequestAttrs();
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2018-01-05 18:38:23 +03:00
|
|
|
postCount += 1;
|
2016-01-05 20:01:42 +03:00
|
|
|
|
|
|
|
// invalid
|
|
|
|
if (postCount === 1) {
|
2017-01-02 21:50:36 +03:00
|
|
|
return new Response(422, {}, {
|
2016-01-05 20:01:42 +03:00
|
|
|
errors: [
|
|
|
|
{
|
2019-03-25 14:29:14 +03:00
|
|
|
type: 'ValidationError',
|
2016-01-05 20:01:42 +03:00
|
|
|
message: 'Dummy validation error'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-09-26 19:03:53 +03:00
|
|
|
// TODO: duplicated from mirage/config/invites - extract method?
|
2017-09-28 05:33:00 +03:00
|
|
|
attrs.token = `${invites.all().models.length}-token`;
|
|
|
|
attrs.expires = moment.utc().add(1, 'day').valueOf();
|
|
|
|
attrs.createdAt = moment.utc().format();
|
|
|
|
attrs.createdBy = 1;
|
|
|
|
attrs.updatedAt = moment.utc().format();
|
|
|
|
attrs.updatedBy = 1;
|
|
|
|
attrs.status = 'sent';
|
|
|
|
|
|
|
|
return invites.create(attrs);
|
2016-01-05 20:01:42 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
// complete step 2 so we can access step 3
|
2017-04-24 15:29:48 +03:00
|
|
|
await visit('/setup/two');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-email-input]', 'test@example.com');
|
|
|
|
await fillIn('[data-test-name-input]', 'Test User');
|
2017-10-26 13:02:17 +03:00
|
|
|
await fillIn('[data-test-password-input]', 'thisissupersafe');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-blog-title-input]', 'Blog Title');
|
2017-04-24 15:29:48 +03:00
|
|
|
await click('.gh-btn-green');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
|
|
|
// default field/button state
|
2017-04-24 15:29:48 +03:00
|
|
|
formGroup = find('.gh-flow-invite .form-group');
|
|
|
|
button = find('.gh-flow-invite button[type="submit"]');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(formGroup, 'default field has error class')
|
|
|
|
.to.not.have.class('error');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(button.textContent, 'default button text')
|
|
|
|
.to.have.string('Invite some users');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(button, 'default button is disabled')
|
|
|
|
.to.have.class('gh-btn-minor');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
|
|
|
// no users submitted state
|
2017-04-24 15:29:48 +03:00
|
|
|
await click('.gh-flow-invite button[type="submit"]');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(formGroup, 'no users submitted field has error class')
|
|
|
|
.to.have.class('error');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(button.textContent, 'no users submitted button text')
|
|
|
|
.to.have.string('No users to invite');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(button, 'no users submitted button is disabled')
|
|
|
|
.to.have.class('gh-btn-minor');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
|
|
|
// single invalid email
|
2017-04-24 15:29:48 +03:00
|
|
|
await fillIn(input, 'invalid email');
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur(input);
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(formGroup, 'invalid field has error class')
|
|
|
|
.to.have.class('error');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(button.textContent, 'single invalid button text')
|
|
|
|
.to.have.string('1 invalid email address');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(button, 'invalid email button is disabled')
|
|
|
|
.to.have.class('gh-btn-minor');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
|
|
|
// multiple invalid emails
|
2017-04-24 15:29:48 +03:00
|
|
|
await fillIn(input, 'invalid email\nanother invalid address');
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur(input);
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(button.textContent, 'multiple invalid button text')
|
|
|
|
.to.have.string('2 invalid email addresses');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
|
|
|
// single valid email
|
2017-04-24 15:29:48 +03:00
|
|
|
await fillIn(input, 'invited@example.com');
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur(input);
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(formGroup, 'valid field has error class')
|
|
|
|
.to.not.have.class('error');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(button.textContent, 'single valid button text')
|
|
|
|
.to.have.string('Invite 1 user');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(button, 'valid email button is enabled')
|
|
|
|
.to.have.class('gh-btn-green');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
|
|
|
// multiple valid emails
|
2017-04-24 15:29:48 +03:00
|
|
|
await fillIn(input, 'invited1@example.com\ninvited2@example.com');
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur(input);
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(button.textContent, 'multiple valid button text')
|
|
|
|
.to.have.string('Invite 2 users');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
|
|
|
// submit invitations with simulated failure on 1 invite
|
2017-04-24 15:29:48 +03:00
|
|
|
await click('.gh-btn-green');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// it redirects to the home / "content" screen
|
|
|
|
expect(currentURL(), 'url after submitting invites')
|
2019-03-21 12:33:14 +03:00
|
|
|
.to.equal('/site');
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// it displays success alert
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(findAll('.gh-alert-green').length, 'number of success alerts')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal(1);
|
2016-01-05 20:01:42 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// it displays failure alert
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(findAll('.gh-alert-red').length, 'number of failure alerts')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal(1);
|
2016-01-05 20:01:42 +03:00
|
|
|
});
|
2015-11-26 13:39:37 +03:00
|
|
|
});
|
|
|
|
});
|