2017-05-18 13:48:37 +03:00
|
|
|
import ctrlOrCmd from 'ghost-admin/utils/ctrl-or-cmd';
|
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, focus, triggerEvent} 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';
|
2016-02-11 15:06:29 +03:00
|
|
|
|
|
|
|
describe('Acceptance: Settings - General', function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
let hooks = setupApplicationTest();
|
|
|
|
setupMirage(hooks);
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
it('redirects to signin when not authenticated', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
await invalidateSession();
|
2017-04-24 15:29:48 +03:00
|
|
|
await visit('/settings/general');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/signin');
|
2016-02-11 15:06:29 +03:00
|
|
|
});
|
|
|
|
|
2019-02-22 12:43:35 +03:00
|
|
|
it('redirects to staff page when authenticated as contributor', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
let role = this.server.create('role', {name: 'Contributor'});
|
|
|
|
this.server.create('user', {roles: [role], slug: 'test-user'});
|
2018-02-07 12:42:46 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await authenticateSession();
|
2018-02-07 12:42:46 +03:00
|
|
|
await visit('/settings/general');
|
|
|
|
|
2021-11-04 11:40:24 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
|
2018-02-07 12:42:46 +03:00
|
|
|
});
|
|
|
|
|
2019-02-22 12:43:35 +03:00
|
|
|
it('redirects to staff page when authenticated as author', 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'});
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await authenticateSession();
|
2017-04-24 15:29:48 +03:00
|
|
|
await visit('/settings/general');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2021-11-04 11:40:24 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/staff/test-user');
|
2016-02-11 15:06:29 +03:00
|
|
|
});
|
|
|
|
|
2019-02-22 12:43:35 +03:00
|
|
|
it('redirects to staff page when authenticated as editor', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
let role = this.server.create('role', {name: 'Editor'});
|
|
|
|
this.server.create('user', {roles: [role], slug: 'test-user'});
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await authenticateSession();
|
2017-04-24 15:29:48 +03:00
|
|
|
await visit('/settings/general');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2021-11-04 11:40:24 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/staff');
|
2016-02-11 15:06:29 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('when logged in', function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
beforeEach(async function () {
|
|
|
|
let role = this.server.create('role', {name: 'Administrator'});
|
|
|
|
this.server.create('user', {roles: [role]});
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
return await authenticateSession();
|
2016-02-11 15:06:29 +03:00
|
|
|
});
|
|
|
|
|
2017-05-23 11:50:04 +03:00
|
|
|
it('it renders, handles image uploads', async function () {
|
2017-04-24 15:29:48 +03:00
|
|
|
await visit('/settings/general');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// has correct url
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/general');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// has correct page title
|
|
|
|
expect(document.title, 'page title').to.equal('Settings - General - Test Blog');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// highlights nav menu
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-nav="settings"]'), 'highlights nav menu item')
|
|
|
|
.to.have.class('active');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-05-23 11:50:04 +03:00
|
|
|
expect(
|
2021-02-09 00:56:18 +03:00
|
|
|
find('[data-test-button="save"]').textContent.trim(),
|
2017-05-23 11:50:04 +03:00
|
|
|
'save button text'
|
|
|
|
).to.equal('Save settings');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-toggle-pub-info]');
|
|
|
|
await fillIn('[data-test-title-input]', 'New Blog Title');
|
2021-02-09 00:56:18 +03:00
|
|
|
await click('[data-test-button="save"]');
|
2017-04-24 15:29:48 +03:00
|
|
|
expect(document.title, 'page title').to.equal('Settings - General - New Blog Title');
|
2016-05-16 03:41:28 +03:00
|
|
|
|
2017-05-18 13:48:37 +03:00
|
|
|
// CMD-S shortcut works
|
2017-05-23 11:50:04 +03:00
|
|
|
// -------------------------------------------------------------- //
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-title-input]', 'CMD-S Test');
|
2017-05-18 13:48:37 +03:00
|
|
|
await triggerEvent('.gh-app', 'keydown', {
|
|
|
|
keyCode: 83, // s
|
|
|
|
metaKey: ctrlOrCmd === 'command',
|
|
|
|
ctrlKey: ctrlOrCmd === 'ctrl'
|
|
|
|
});
|
|
|
|
// we've already saved in this test so there's no on-screen indication
|
|
|
|
// that we've had another save, check the request was fired instead
|
2019-01-02 12:58:55 +03:00
|
|
|
let [lastRequest] = this.server.pretender.handledRequests.slice(-1);
|
2017-05-18 13:48:37 +03:00
|
|
|
let params = JSON.parse(lastRequest.requestBody);
|
|
|
|
expect(params.settings.findBy('key', 'title').value).to.equal('CMD-S Test');
|
2017-04-24 15:29:48 +03:00
|
|
|
});
|
2017-01-26 14:17:34 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
it('renders timezone selector correctly', async function () {
|
|
|
|
await visit('/settings/general');
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-toggle-timezone]');
|
2017-01-26 14:17:34 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/general');
|
2017-01-26 14:17:34 +03:00
|
|
|
|
2020-06-24 17:34:59 +03:00
|
|
|
expect(findAll('#timezone option').length, 'available timezones').to.equal(66);
|
|
|
|
expect(find('#timezone option:checked').textContent.trim()).to.equal('(GMT) UTC');
|
|
|
|
find('#timezone option[value="Africa/Cairo"]').selected = true;
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2020-06-24 17:34:59 +03:00
|
|
|
await triggerEvent('#timezone', 'change');
|
2021-02-09 00:56:18 +03:00
|
|
|
await click('[data-test-button="save"]');
|
2020-06-24 17:34:59 +03:00
|
|
|
expect(find('#timezone option:checked').textContent.trim()).to.equal('(GMT +2:00) Cairo, Egypt');
|
2017-04-24 15:29:48 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('handles private blog settings correctly', async function () {
|
|
|
|
await visit('/settings/general');
|
|
|
|
|
|
|
|
// handles private blog settings correctly
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-private-checkbox]').checked, 'isPrivate checkbox').to.be.false;
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-private-checkbox]');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-private-checkbox]').checked, 'isPrivate checkbox').to.be.true;
|
|
|
|
expect(findAll('[data-test-password-input]').length, 'password input').to.equal(1);
|
|
|
|
expect(find('[data-test-password-input]').value, 'password default value').to.not.equal('');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-password-input]', '');
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-password-input]');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-password-error]').textContent.trim(), 'empty password error')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('Password must be supplied');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-password-input]', 'asdfg');
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-password-input]');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-password-error]').textContent.trim(), 'present password error')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('');
|
Timezones: Always use the timezone of blog setting
closes TryGhost/Ghost#6406
follow-up PR of #2
- adds a `timeZone` Service to provide the offset (=timezone reg. moment-timezone) of the users blog settings
- `gh-datetime-input` will read the offset of the timezone now and adjust the `publishedAt` date with it. This is the date which will be shown in the PSM 'Publish Date' field. When the user writes a new date/time, the offset is considered and will be deducted again before saving it to the model. This way, we always work with a UTC publish date except for this input field.
- gets `availableTimezones` from `configuration/timezones` API endpoint
- adds a `moment-utc` transform on all date attr (`createdAt`, `updatedAt`, `publishedAt`, `unsubscribedAt` and `lastLogin`) to only work with UTC times on serverside
- when switching the timezone in the select box, the user will be shown the local time of the selected timezone
- `createdAt`-property in `gh-user-invited` returns now `moment(createdAt).fromNow()` as `createdAt` is a moment date already
- added clock service to show actual time ticking below select box
- default timezone is '(GMT) Greenwich Mean Time : Dublin, Edinburgh, London'
- if no timezone is saved in the settings yet, the default value will be used
- shows the local time in 'Publish Date' in PSM by default, until user overwrites it
- adds dependency `moment-timezone 0.5.4` to `bower.json`
---------
**Tests:**
- sets except for clock service in test env
- adds fixtures to mirage
- adds `service.ajax` and `service:ghostPaths` to navigation-test.js
- adds unit test for `gh-format-timeago` helper
- updates acceptance test `general-setting`
- adds acceptance test for `editor`
- adds integration tests for `services/config` and `services/time-zone`
---------
**Todos:**
- [ ] Integration tests: ~~`services/config`~~, ~~`services/time-zone`~~, `components/gh-datetime-input`
- [x] Acceptance test: `editor`
- [ ] Unit tests: `utils/date-formatting`
- [ ] write issue for renaming date properties (e. g. `createdAt` to `createdAtUTC`) and translate those for server side with serializers
2016-02-02 10:04:40 +03:00
|
|
|
});
|
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
it('handles social blog settings correctly', async function () {
|
2018-01-05 18:38:23 +03:00
|
|
|
let testSocialInput = async function (type, input, expectedValue, expectedError = '') {
|
2017-11-10 19:38:30 +03:00
|
|
|
await fillIn(`[data-test-${type}-input]`, input);
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur(`[data-test-${type}-input]`);
|
2017-11-10 19:38:30 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find(`[data-test-${type}-input]`).value,
|
2017-11-10 19:38:30 +03:00
|
|
|
`${type} value for ${input}`
|
|
|
|
).to.equal(expectedValue);
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find(`[data-test-${type}-error]`).textContent.trim(),
|
2017-11-10 19:38:30 +03:00
|
|
|
`${type} validation response for ${input}`
|
|
|
|
).to.equal(expectedError);
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find(`[data-test-${type}-input]`).closest('.form-group').classList.contains('error'),
|
2017-11-10 19:38:30 +03:00
|
|
|
`${type} input should be in error state with '${input}'`
|
|
|
|
).to.equal(!!expectedError);
|
|
|
|
};
|
|
|
|
|
|
|
|
let testFacebookValidation = async (...args) => testSocialInput('facebook', ...args);
|
|
|
|
let testTwitterValidation = async (...args) => testSocialInput('twitter', ...args);
|
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
await visit('/settings/general');
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-toggle-social]');
|
Timezones: Always use the timezone of blog setting
closes TryGhost/Ghost#6406
follow-up PR of #2
- adds a `timeZone` Service to provide the offset (=timezone reg. moment-timezone) of the users blog settings
- `gh-datetime-input` will read the offset of the timezone now and adjust the `publishedAt` date with it. This is the date which will be shown in the PSM 'Publish Date' field. When the user writes a new date/time, the offset is considered and will be deducted again before saving it to the model. This way, we always work with a UTC publish date except for this input field.
- gets `availableTimezones` from `configuration/timezones` API endpoint
- adds a `moment-utc` transform on all date attr (`createdAt`, `updatedAt`, `publishedAt`, `unsubscribedAt` and `lastLogin`) to only work with UTC times on serverside
- when switching the timezone in the select box, the user will be shown the local time of the selected timezone
- `createdAt`-property in `gh-user-invited` returns now `moment(createdAt).fromNow()` as `createdAt` is a moment date already
- added clock service to show actual time ticking below select box
- default timezone is '(GMT) Greenwich Mean Time : Dublin, Edinburgh, London'
- if no timezone is saved in the settings yet, the default value will be used
- shows the local time in 'Publish Date' in PSM by default, until user overwrites it
- adds dependency `moment-timezone 0.5.4` to `bower.json`
---------
**Tests:**
- sets except for clock service in test env
- adds fixtures to mirage
- adds `service.ajax` and `service:ghostPaths` to navigation-test.js
- adds unit test for `gh-format-timeago` helper
- updates acceptance test `general-setting`
- adds acceptance test for `editor`
- adds integration tests for `services/config` and `services/time-zone`
---------
**Todos:**
- [ ] Integration tests: ~~`services/config`~~, ~~`services/time-zone`~~, `components/gh-datetime-input`
- [x] Acceptance test: `editor`
- [ ] Unit tests: `utils/date-formatting`
- [ ] write issue for renaming date properties (e. g. `createdAt` to `createdAtUTC`) and translate those for server side with serializers
2016-02-02 10:04:40 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// validates a facebook url correctly
|
|
|
|
// loads fixtures and performs transform
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-facebook-input]').value, 'initial facebook value')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('https://www.facebook.com/test');
|
Timezones: Always use the timezone of blog setting
closes TryGhost/Ghost#6406
follow-up PR of #2
- adds a `timeZone` Service to provide the offset (=timezone reg. moment-timezone) of the users blog settings
- `gh-datetime-input` will read the offset of the timezone now and adjust the `publishedAt` date with it. This is the date which will be shown in the PSM 'Publish Date' field. When the user writes a new date/time, the offset is considered and will be deducted again before saving it to the model. This way, we always work with a UTC publish date except for this input field.
- gets `availableTimezones` from `configuration/timezones` API endpoint
- adds a `moment-utc` transform on all date attr (`createdAt`, `updatedAt`, `publishedAt`, `unsubscribedAt` and `lastLogin`) to only work with UTC times on serverside
- when switching the timezone in the select box, the user will be shown the local time of the selected timezone
- `createdAt`-property in `gh-user-invited` returns now `moment(createdAt).fromNow()` as `createdAt` is a moment date already
- added clock service to show actual time ticking below select box
- default timezone is '(GMT) Greenwich Mean Time : Dublin, Edinburgh, London'
- if no timezone is saved in the settings yet, the default value will be used
- shows the local time in 'Publish Date' in PSM by default, until user overwrites it
- adds dependency `moment-timezone 0.5.4` to `bower.json`
---------
**Tests:**
- sets except for clock service in test env
- adds fixtures to mirage
- adds `service.ajax` and `service:ghostPaths` to navigation-test.js
- adds unit test for `gh-format-timeago` helper
- updates acceptance test `general-setting`
- adds acceptance test for `editor`
- adds integration tests for `services/config` and `services/time-zone`
---------
**Todos:**
- [ ] Integration tests: ~~`services/config`~~, ~~`services/time-zone`~~, `components/gh-datetime-input`
- [x] Acceptance test: `editor`
- [ ] Unit tests: `utils/date-formatting`
- [ ] write issue for renaming date properties (e. g. `createdAt` to `createdAtUTC`) and translate those for server side with serializers
2016-02-02 10:04:40 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await focus('[data-test-facebook-input]');
|
|
|
|
await blur('[data-test-facebook-input]');
|
Timezones: Always use the timezone of blog setting
closes TryGhost/Ghost#6406
follow-up PR of #2
- adds a `timeZone` Service to provide the offset (=timezone reg. moment-timezone) of the users blog settings
- `gh-datetime-input` will read the offset of the timezone now and adjust the `publishedAt` date with it. This is the date which will be shown in the PSM 'Publish Date' field. When the user writes a new date/time, the offset is considered and will be deducted again before saving it to the model. This way, we always work with a UTC publish date except for this input field.
- gets `availableTimezones` from `configuration/timezones` API endpoint
- adds a `moment-utc` transform on all date attr (`createdAt`, `updatedAt`, `publishedAt`, `unsubscribedAt` and `lastLogin`) to only work with UTC times on serverside
- when switching the timezone in the select box, the user will be shown the local time of the selected timezone
- `createdAt`-property in `gh-user-invited` returns now `moment(createdAt).fromNow()` as `createdAt` is a moment date already
- added clock service to show actual time ticking below select box
- default timezone is '(GMT) Greenwich Mean Time : Dublin, Edinburgh, London'
- if no timezone is saved in the settings yet, the default value will be used
- shows the local time in 'Publish Date' in PSM by default, until user overwrites it
- adds dependency `moment-timezone 0.5.4` to `bower.json`
---------
**Tests:**
- sets except for clock service in test env
- adds fixtures to mirage
- adds `service.ajax` and `service:ghostPaths` to navigation-test.js
- adds unit test for `gh-format-timeago` helper
- updates acceptance test `general-setting`
- adds acceptance test for `editor`
- adds integration tests for `services/config` and `services/time-zone`
---------
**Todos:**
- [ ] Integration tests: ~~`services/config`~~, ~~`services/time-zone`~~, `components/gh-datetime-input`
- [x] Acceptance test: `editor`
- [ ] Unit tests: `utils/date-formatting`
- [ ] write issue for renaming date properties (e. g. `createdAt` to `createdAtUTC`) and translate those for server side with serializers
2016-02-02 10:04:40 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// regression test: we still have a value after the input is
|
|
|
|
// focused and then blurred without any changes
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-facebook-input]').value, 'facebook value after blur with no change')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('https://www.facebook.com/test');
|
Timezones: Always use the timezone of blog setting
closes TryGhost/Ghost#6406
follow-up PR of #2
- adds a `timeZone` Service to provide the offset (=timezone reg. moment-timezone) of the users blog settings
- `gh-datetime-input` will read the offset of the timezone now and adjust the `publishedAt` date with it. This is the date which will be shown in the PSM 'Publish Date' field. When the user writes a new date/time, the offset is considered and will be deducted again before saving it to the model. This way, we always work with a UTC publish date except for this input field.
- gets `availableTimezones` from `configuration/timezones` API endpoint
- adds a `moment-utc` transform on all date attr (`createdAt`, `updatedAt`, `publishedAt`, `unsubscribedAt` and `lastLogin`) to only work with UTC times on serverside
- when switching the timezone in the select box, the user will be shown the local time of the selected timezone
- `createdAt`-property in `gh-user-invited` returns now `moment(createdAt).fromNow()` as `createdAt` is a moment date already
- added clock service to show actual time ticking below select box
- default timezone is '(GMT) Greenwich Mean Time : Dublin, Edinburgh, London'
- if no timezone is saved in the settings yet, the default value will be used
- shows the local time in 'Publish Date' in PSM by default, until user overwrites it
- adds dependency `moment-timezone 0.5.4` to `bower.json`
---------
**Tests:**
- sets except for clock service in test env
- adds fixtures to mirage
- adds `service.ajax` and `service:ghostPaths` to navigation-test.js
- adds unit test for `gh-format-timeago` helper
- updates acceptance test `general-setting`
- adds acceptance test for `editor`
- adds integration tests for `services/config` and `services/time-zone`
---------
**Todos:**
- [ ] Integration tests: ~~`services/config`~~, ~~`services/time-zone`~~, `components/gh-datetime-input`
- [x] Acceptance test: `editor`
- [ ] Unit tests: `utils/date-formatting`
- [ ] write issue for renaming date properties (e. g. `createdAt` to `createdAtUTC`) and translate those for server side with serializers
2016-02-02 10:04:40 +03:00
|
|
|
|
2017-11-10 19:38:30 +03:00
|
|
|
await testFacebookValidation(
|
|
|
|
'facebook.com/username',
|
|
|
|
'https://www.facebook.com/username');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-11-10 19:38:30 +03:00
|
|
|
await testFacebookValidation(
|
|
|
|
'testuser',
|
|
|
|
'https://www.facebook.com/testuser');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-11-10 19:38:30 +03:00
|
|
|
await testFacebookValidation(
|
|
|
|
'ab99',
|
|
|
|
'https://www.facebook.com/ab99');
|
2016-03-03 11:52:27 +03:00
|
|
|
|
2017-11-10 19:38:30 +03:00
|
|
|
await testFacebookValidation(
|
|
|
|
'page/ab99',
|
|
|
|
'https://www.facebook.com/page/ab99');
|
2016-03-03 11:52:27 +03:00
|
|
|
|
2017-11-10 19:38:30 +03:00
|
|
|
await testFacebookValidation(
|
|
|
|
'page/*(&*(%%))',
|
|
|
|
'https://www.facebook.com/page/*(&*(%%))');
|
2016-03-03 11:52:27 +03:00
|
|
|
|
2017-11-10 19:38:30 +03:00
|
|
|
await testFacebookValidation(
|
|
|
|
'facebook.com/pages/some-facebook-page/857469375913?ref=ts',
|
|
|
|
'https://www.facebook.com/pages/some-facebook-page/857469375913?ref=ts');
|
2016-05-17 21:14:14 +03:00
|
|
|
|
2017-11-10 19:38:30 +03:00
|
|
|
await testFacebookValidation(
|
|
|
|
'https://www.facebook.com/groups/savethecrowninn',
|
|
|
|
'https://www.facebook.com/groups/savethecrowninn');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-11-10 19:38:30 +03:00
|
|
|
await testFacebookValidation(
|
|
|
|
'http://github.com/username',
|
|
|
|
'http://github.com/username',
|
|
|
|
'The URL must be in a format like https://www.facebook.com/yourPage');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-11-10 19:38:30 +03:00
|
|
|
await testFacebookValidation(
|
|
|
|
'http://github.com/pages/username',
|
|
|
|
'http://github.com/pages/username',
|
|
|
|
'The URL must be in a format like https://www.facebook.com/yourPage');
|
2016-05-16 21:16:40 +03:00
|
|
|
|
2016-03-03 11:52:27 +03:00
|
|
|
// validates a twitter url correctly
|
2016-05-17 21:14:14 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
// loads fixtures and performs transform
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-twitter-input]').value, 'initial twitter value')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('https://twitter.com/test');
|
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await focus('[data-test-twitter-input]');
|
|
|
|
await blur('[data-test-twitter-input]');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
|
|
|
// regression test: we still have a value after the input is
|
|
|
|
// focused and then blurred without any changes
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-twitter-input]').value, 'twitter value after blur with no change')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('https://twitter.com/test');
|
|
|
|
|
2017-11-10 19:38:30 +03:00
|
|
|
await testTwitterValidation(
|
|
|
|
'twitter.com/username',
|
|
|
|
'https://twitter.com/username');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-11-10 19:38:30 +03:00
|
|
|
await testTwitterValidation(
|
|
|
|
'testuser',
|
|
|
|
'https://twitter.com/testuser');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-11-10 19:38:30 +03:00
|
|
|
await testTwitterValidation(
|
|
|
|
'http://github.com/username',
|
|
|
|
'https://twitter.com/username');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-11-10 19:38:30 +03:00
|
|
|
await testTwitterValidation(
|
|
|
|
'*(&*(%%))',
|
|
|
|
'*(&*(%%))',
|
|
|
|
'The URL must be in a format like https://twitter.com/yourUsername');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-11-10 19:38:30 +03:00
|
|
|
await testTwitterValidation(
|
|
|
|
'thisusernamehasmorethan15characters',
|
|
|
|
'thisusernamehasmorethan15characters',
|
|
|
|
'Your Username is not a valid Twitter Username');
|
2016-02-11 15:06:29 +03:00
|
|
|
});
|
2017-10-04 13:49:30 +03:00
|
|
|
|
|
|
|
it('warns when leaving without saving', async function () {
|
|
|
|
await visit('/settings/general');
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-private-checkbox]').checked,
|
2018-08-08 19:00:46 +03:00
|
|
|
'private blog checkbox'
|
2017-10-04 13:49:30 +03:00
|
|
|
).to.be.false;
|
|
|
|
|
|
|
|
await click('[data-test-toggle-pub-info]');
|
|
|
|
await fillIn('[data-test-title-input]', 'New Blog Title');
|
|
|
|
|
2018-08-08 19:00:46 +03:00
|
|
|
await click('[data-test-private-checkbox]');
|
2017-10-04 13:49:30 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-private-checkbox]').checked,
|
2018-08-08 19:00:46 +03:00
|
|
|
'private blog checkbox'
|
2017-10-04 13:49:30 +03:00
|
|
|
).to.be.true;
|
|
|
|
|
2019-02-22 12:43:35 +03:00
|
|
|
await visit('/settings/staff');
|
2017-10-04 13:49:30 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(findAll('.fullscreen-modal').length, 'modal exists').to.equal(1);
|
2017-10-04 13:49:30 +03:00
|
|
|
|
|
|
|
// Leave without saving
|
2019-01-02 12:58:55 +03:00
|
|
|
await click('.fullscreen-modal [data-test-leave-button]');
|
2017-10-04 13:49:30 +03:00
|
|
|
|
2019-02-22 12:43:35 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/staff');
|
2017-10-04 13:49:30 +03:00
|
|
|
|
|
|
|
await visit('/settings/general');
|
|
|
|
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/settings/general');
|
|
|
|
|
|
|
|
// settings were not saved
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-private-checkbox]').checked,
|
2018-08-08 19:00:46 +03:00
|
|
|
'private blog checkbox'
|
2017-10-04 13:49:30 +03:00
|
|
|
).to.be.false;
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-title-input]').textContent.trim(),
|
2017-10-04 13:49:30 +03:00
|
|
|
'Blog title'
|
|
|
|
).to.equal('');
|
|
|
|
});
|
2016-02-11 15:06:29 +03:00
|
|
|
});
|
|
|
|
});
|