2016-02-11 15:06:29 +03:00
|
|
|
/* jshint expr:true */
|
2016-06-30 13:21:47 +03:00
|
|
|
import $ from 'jquery';
|
2017-05-18 13:48:37 +03:00
|
|
|
import ctrlOrCmd from 'ghost-admin/utils/ctrl-or-cmd';
|
2017-05-29 21:50:03 +03:00
|
|
|
import destroyApp from '../../helpers/destroy-app';
|
2017-05-23 11:50:04 +03:00
|
|
|
import mockUploads from '../../../mirage/config/uploads';
|
2017-05-29 21:50:03 +03:00
|
|
|
import run from 'ember-runloop';
|
|
|
|
import startApp from '../../helpers/start-app';
|
|
|
|
import wait from 'ember-test-helpers/wait';
|
|
|
|
import {afterEach, beforeEach, describe, it} from 'mocha';
|
|
|
|
import {authenticateSession, invalidateSession} from 'ghost-admin/tests/helpers/ember-simple-auth';
|
|
|
|
import {expect} from 'chai';
|
2016-02-11 15:06:29 +03:00
|
|
|
|
|
|
|
describe('Acceptance: Settings - General', function () {
|
|
|
|
let application;
|
|
|
|
|
2017-01-26 14:17:34 +03:00
|
|
|
beforeEach(function () {
|
2016-02-11 15:06:29 +03:00
|
|
|
application = startApp();
|
|
|
|
});
|
|
|
|
|
2017-01-26 14:17:34 +03:00
|
|
|
afterEach(function () {
|
2016-02-11 15:06:29 +03:00
|
|
|
destroyApp(application);
|
|
|
|
});
|
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
it('redirects to signin when not authenticated', async function () {
|
2016-02-11 15:06:29 +03:00
|
|
|
invalidateSession(application);
|
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
|
|
|
});
|
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
it('redirects to team page when authenticated as author', async function () {
|
2016-02-11 15:06:29 +03:00
|
|
|
let role = server.create('role', {name: 'Author'});
|
2016-11-14 16:16:51 +03:00
|
|
|
server.create('user', {roles: [role], slug: 'test-user'});
|
2016-02-11 15:06:29 +03:00
|
|
|
|
|
|
|
authenticateSession(application);
|
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('/team/test-user');
|
2016-02-11 15:06:29 +03:00
|
|
|
});
|
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
it('redirects to team page when authenticated as editor', async function () {
|
2016-02-11 15:06:29 +03:00
|
|
|
let role = server.create('role', {name: 'Editor'});
|
2016-11-14 16:16:51 +03:00
|
|
|
server.create('user', {roles: [role], slug: 'test-user'});
|
2016-02-11 15:06:29 +03:00
|
|
|
|
|
|
|
authenticateSession(application);
|
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('/team');
|
2016-02-11 15:06:29 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('when logged in', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
let role = server.create('role', {name: 'Administrator'});
|
2016-11-14 16:16:51 +03:00
|
|
|
server.create('user', {roles: [role]});
|
2016-02-11 15:06:29 +03:00
|
|
|
|
|
|
|
return authenticateSession(application);
|
|
|
|
});
|
|
|
|
|
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
|
|
|
|
expect($('.gh-nav-settings-general').hasClass('active'), 'highlights nav menu item')
|
|
|
|
.to.be.true;
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-05-23 11:50:04 +03:00
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-save-button]').text().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-05-23 11:50:04 +03:00
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-dated-permalinks-checkbox]').prop('checked'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'date permalinks checkbox'
|
|
|
|
).to.be.false;
|
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');
|
|
|
|
await click('[data-test-save-button]');
|
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-23 11:50:04 +03:00
|
|
|
// blog icon upload
|
|
|
|
// -------------------------------------------------------------- //
|
2016-05-16 03:41:28 +03:00
|
|
|
|
2017-05-23 11:50:04 +03:00
|
|
|
// has fixture icon
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-icon-img]').attr('src'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'initial icon src'
|
|
|
|
).to.equal('/content/images/2014/Feb/favicon.ico');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-05-23 11:50:04 +03:00
|
|
|
// delete removes icon + shows button
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-delete-image="icon"]');
|
2017-05-23 11:50:04 +03:00
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-icon-img]'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'icon img after removal'
|
|
|
|
).to.not.exist;
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-image-upload-btn="icon"]'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'icon upload button after removal'
|
|
|
|
).to.exist;
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-05-23 11:50:04 +03:00
|
|
|
// select file
|
|
|
|
fileUpload(
|
2017-08-11 18:28:05 +03:00
|
|
|
'[data-test-file-input="icon"]',
|
2017-05-23 11:50:04 +03:00
|
|
|
['test'],
|
|
|
|
{name: 'pub-icon.ico', type: 'image/x-icon'}
|
|
|
|
);
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-05-23 11:50:04 +03:00
|
|
|
// check progress bar exists during upload
|
|
|
|
run.later(() => {
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-setting="icon"] [data-test-progress-bar]'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'icon upload progress bar'
|
|
|
|
).to.exist;
|
|
|
|
}, 50);
|
2017-01-26 14:17:34 +03:00
|
|
|
|
2017-05-23 11:50:04 +03:00
|
|
|
// wait for upload to finish and check image is shown
|
|
|
|
await wait();
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-icon-img]').attr('src'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'icon img after upload'
|
|
|
|
).to.match(/pub-icon\.ico$/);
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-image-upload-btn="icon"]'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'icon upload button after upload'
|
|
|
|
).to.not.exist;
|
2017-01-26 14:17:34 +03:00
|
|
|
|
2017-05-23 11:50:04 +03:00
|
|
|
// failed upload shows error
|
|
|
|
server.post('/uploads/icon/', function () {
|
|
|
|
return {
|
|
|
|
errors: [{
|
|
|
|
errorType: 'ValidationError',
|
|
|
|
message: 'Wrong icon size'
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
}, 422);
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-delete-image="icon"]');
|
2017-05-23 11:50:04 +03:00
|
|
|
await fileUpload(
|
2017-08-11 18:28:05 +03:00
|
|
|
'[data-test-file-input="icon"]',
|
2017-05-23 11:50:04 +03:00
|
|
|
['test'],
|
|
|
|
{name: 'pub-icon.ico', type: 'image/x-icon'}
|
|
|
|
);
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-error="icon"]').text().trim(),
|
2017-05-23 11:50:04 +03:00
|
|
|
'failed icon upload message'
|
|
|
|
).to.equal('Wrong icon size');
|
2017-01-26 14:17:34 +03:00
|
|
|
|
2017-05-23 11:50:04 +03:00
|
|
|
// reset upload endpoints
|
|
|
|
mockUploads(server);
|
|
|
|
|
|
|
|
// blog logo upload
|
|
|
|
// -------------------------------------------------------------- //
|
|
|
|
|
|
|
|
// has fixture icon
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-logo-img]').attr('src'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'initial logo src'
|
|
|
|
).to.equal('/content/images/2013/Nov/logo.png');
|
|
|
|
|
|
|
|
// delete removes logo + shows button
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-delete-image="logo"]');
|
2017-05-23 11:50:04 +03:00
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-logo-img]'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'logo img after removal'
|
|
|
|
).to.not.exist;
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-image-upload-btn="logo"]'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'logo upload button after removal'
|
|
|
|
).to.exist;
|
|
|
|
|
|
|
|
// select file
|
|
|
|
fileUpload(
|
2017-08-11 18:28:05 +03:00
|
|
|
'[data-test-file-input="logo"]',
|
2017-05-23 11:50:04 +03:00
|
|
|
['test'],
|
|
|
|
{name: 'pub-logo.png', type: 'image/png'}
|
|
|
|
);
|
|
|
|
|
|
|
|
// check progress bar exists during upload
|
|
|
|
run.later(() => {
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-setting="logo"] [data-test-progress-bar]'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'logo upload progress bar'
|
|
|
|
).to.exist;
|
|
|
|
}, 50);
|
|
|
|
|
|
|
|
// wait for upload to finish and check image is shown
|
|
|
|
await wait();
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-logo-img]').attr('src'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'logo img after upload'
|
|
|
|
).to.match(/pub-logo\.png$/);
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-image-upload-btn="logo"]'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'logo upload button after upload'
|
|
|
|
).to.not.exist;
|
|
|
|
|
|
|
|
// failed upload shows error
|
|
|
|
server.post('/uploads/', function () {
|
|
|
|
return {
|
|
|
|
errors: [{
|
|
|
|
errorType: 'ValidationError',
|
|
|
|
message: 'Wrong logo size'
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
}, 422);
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-delete-image="logo"]');
|
2017-05-23 11:50:04 +03:00
|
|
|
await fileUpload(
|
2017-08-11 18:28:05 +03:00
|
|
|
'[data-test-file-input="logo"]',
|
2017-05-23 11:50:04 +03:00
|
|
|
['test'],
|
|
|
|
{name: 'pub-logo.png', type: 'image/png'}
|
|
|
|
);
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-error="logo"]').text().trim(),
|
2017-05-23 11:50:04 +03:00
|
|
|
'failed logo upload message'
|
|
|
|
).to.equal('Wrong logo size');
|
|
|
|
|
|
|
|
// reset upload endpoints
|
|
|
|
mockUploads(server);
|
|
|
|
|
|
|
|
// blog cover upload
|
|
|
|
// -------------------------------------------------------------- //
|
|
|
|
|
|
|
|
// has fixture icon
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-cover-img]').attr('src'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'initial coverImage src'
|
|
|
|
).to.equal('/content/images/2014/Feb/cover.jpg');
|
|
|
|
|
|
|
|
// delete removes coverImage + shows button
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-delete-image="coverImage"]');
|
2017-05-23 11:50:04 +03:00
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-coverImage-img]'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'coverImage img after removal'
|
|
|
|
).to.not.exist;
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-image-upload-btn="coverImage"]'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'coverImage upload button after removal'
|
|
|
|
).to.exist;
|
|
|
|
|
|
|
|
// select file
|
|
|
|
fileUpload(
|
2017-08-11 18:28:05 +03:00
|
|
|
'[data-test-file-input="coverImage"]',
|
2017-05-23 11:50:04 +03:00
|
|
|
['test'],
|
|
|
|
{name: 'pub-coverImage.png', type: 'image/png'}
|
|
|
|
);
|
|
|
|
|
|
|
|
// check progress bar exists during upload
|
|
|
|
run.later(() => {
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-setting="coverImage"] [data-test-progress-bar]'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'coverImage upload progress bar'
|
|
|
|
).to.exist;
|
|
|
|
}, 50);
|
|
|
|
|
|
|
|
// wait for upload to finish and check image is shown
|
|
|
|
await wait();
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-cover-img]').attr('src'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'coverImage img after upload'
|
|
|
|
).to.match(/pub-coverImage\.png$/);
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-image-upload-btn="coverImage"]'),
|
2017-05-23 11:50:04 +03:00
|
|
|
'coverImage upload button after upload'
|
|
|
|
).to.not.exist;
|
|
|
|
|
|
|
|
// failed upload shows error
|
|
|
|
server.post('/uploads/', function () {
|
|
|
|
return {
|
|
|
|
errors: [{
|
|
|
|
errorType: 'ValidationError',
|
|
|
|
message: 'Wrong coverImage size'
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
}, 422);
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-delete-image="coverImage"]');
|
2017-05-23 11:50:04 +03:00
|
|
|
await fileUpload(
|
2017-08-11 18:28:05 +03:00
|
|
|
'[data-test-file-input="coverImage"]',
|
2017-05-23 11:50:04 +03:00
|
|
|
['test'],
|
|
|
|
{name: 'pub-coverImage.png', type: 'image/png'}
|
|
|
|
);
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-error="coverImage"]').text().trim(),
|
2017-05-23 11:50:04 +03:00
|
|
|
'failed coverImage upload message'
|
|
|
|
).to.equal('Wrong coverImage size');
|
|
|
|
|
|
|
|
// reset upload endpoints
|
|
|
|
mockUploads(server);
|
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
|
|
|
|
let [lastRequest] = server.pretender.handledRequests.slice(-1);
|
|
|
|
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
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
expect(find('#activeTimezone option').length, 'available timezones').to.equal(66);
|
|
|
|
expect(find('#activeTimezone option:selected').text().trim()).to.equal('(GMT) UTC');
|
|
|
|
find('#activeTimezone option[value="Africa/Cairo"]').prop('selected', true);
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-04-24 15:29:48 +03:00
|
|
|
await triggerEvent('#activeTimezone', 'change');
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-save-button]');
|
2017-04-24 15:29:48 +03:00
|
|
|
expect(find('#activeTimezone option:selected').text().trim()).to.equal('(GMT +2:00) Cairo, Egypt');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('handles private blog settings correctly', async function () {
|
|
|
|
await visit('/settings/general');
|
|
|
|
|
|
|
|
// handles private blog settings correctly
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-private-checkbox]').prop('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
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-private-checkbox]').prop('checked'), 'isPrivate checkbox').to.be.true;
|
|
|
|
expect(find('[data-test-password-input]').length, 'password input').to.equal(1);
|
|
|
|
expect(find('[data-test-password-input]').val(), '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]', '');
|
|
|
|
await triggerEvent('[data-test-password-input]', 'blur');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-password-error]').text().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');
|
|
|
|
await triggerEvent('[data-test-password-input]', 'blur');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-password-error]').text().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 () {
|
|
|
|
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
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-facebook-input]').val(), '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
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await triggerEvent('[data-test-facebook-input]', 'focus');
|
|
|
|
await triggerEvent('[data-test-facebook-input]', 'blur');
|
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
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-facebook-input]').val(), '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-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-facebook-input]', 'facebook.com/username');
|
|
|
|
await triggerEvent('[data-test-facebook-input]', 'blur');
|
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-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-facebook-input]').val()).to.be.equal('https://www.facebook.com/username');
|
|
|
|
expect(find('[data-test-facebook-error]').text().trim(), 'inline validation response')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-facebook-input]', 'facebook.com/pages/some-facebook-page/857469375913?ref=ts');
|
|
|
|
await triggerEvent('[data-test-facebook-input]', 'blur');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-facebook-input]').val()).to.be.equal('https://www.facebook.com/pages/some-facebook-page/857469375913?ref=ts');
|
|
|
|
expect(find('[data-test-facebook-error]').text().trim(), 'inline validation response')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-facebook-input]', '*(&*(%%))');
|
|
|
|
await triggerEvent('[data-test-facebook-input]', 'blur');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-facebook-error]').text().trim(), 'inline validation response')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('The URL must be in a format like https://www.facebook.com/yourPage');
|
2016-02-11 15:06:29 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-facebook-input]', 'http://github.com/username');
|
|
|
|
await triggerEvent('[data-test-facebook-input]', 'blur');
|
2016-03-03 11:52:27 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-facebook-input]').val()).to.be.equal('https://www.facebook.com/username');
|
|
|
|
expect(find('[data-test-facebook-error]').text().trim(), 'inline validation response')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('');
|
2016-03-03 11:52:27 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-facebook-input]', 'http://github.com/pages/username');
|
|
|
|
await triggerEvent('[data-test-facebook-input]', 'blur');
|
2016-03-03 11:52:27 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-facebook-input]').val()).to.be.equal('https://www.facebook.com/pages/username');
|
|
|
|
expect(find('[data-test-facebook-error]').text().trim(), 'inline validation response')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('');
|
2016-05-17 21:14:14 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-facebook-input]', 'testuser');
|
|
|
|
await triggerEvent('[data-test-facebook-input]', 'blur');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-facebook-input]').val()).to.be.equal('https://www.facebook.com/testuser');
|
|
|
|
expect(find('[data-test-facebook-error]').text().trim(), 'inline validation response')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('');
|
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-facebook-input]', 'ab99');
|
|
|
|
await triggerEvent('[data-test-facebook-input]', 'blur');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-facebook-input]').val()).to.be.equal('https://www.facebook.com/ab99');
|
|
|
|
expect(find('[data-test-facebook-error]').text().trim(), 'inline validation response')
|
2017-05-15 21:26:34 +03:00
|
|
|
.to.equal('');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-facebook-input]', 'page/ab99');
|
|
|
|
await triggerEvent('[data-test-facebook-input]', 'blur');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-facebook-input]').val()).to.be.equal('https://www.facebook.com/page/ab99');
|
|
|
|
expect(find('[data-test-facebook-error]').text().trim(), 'inline validation response')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('');
|
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-facebook-input]', 'page/*(&*(%%))');
|
|
|
|
await triggerEvent('[data-test-facebook-input]', 'blur');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-facebook-input]').val()).to.be.equal('https://www.facebook.com/page/*(&*(%%))');
|
|
|
|
expect(find('[data-test-facebook-error]').text().trim(), 'inline validation response')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('');
|
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
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-twitter-input]').val(), 'initial twitter value')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('https://twitter.com/test');
|
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await triggerEvent('[data-test-twitter-input]', 'focus');
|
|
|
|
await triggerEvent('[data-test-twitter-input]', 'blur');
|
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
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-twitter-input]').val(), 'twitter value after blur with no change')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('https://twitter.com/test');
|
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-twitter-input]', 'twitter.com/username');
|
|
|
|
await triggerEvent('[data-test-twitter-input]', 'blur');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-twitter-input]').val()).to.be.equal('https://twitter.com/username');
|
|
|
|
expect(find('[data-test-twitter-error]').text().trim(), 'inline validation response')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('');
|
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-twitter-input]', '*(&*(%%))');
|
|
|
|
await triggerEvent('[data-test-twitter-input]', 'blur');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-twitter-error]').text().trim(), 'inline validation response')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('The URL must be in a format like https://twitter.com/yourUsername');
|
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-twitter-input]', 'http://github.com/username');
|
|
|
|
await triggerEvent('[data-test-twitter-input]', 'blur');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-twitter-input]').val()).to.be.equal('https://twitter.com/username');
|
|
|
|
expect(find('[data-test-twitter-error]').text().trim(), 'inline validation response')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('');
|
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-twitter-input]', 'thisusernamehasmorethan15characters');
|
|
|
|
await triggerEvent('[data-test-twitter-input]', 'blur');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-twitter-error]').text().trim(), 'inline validation response')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('Your Username is not a valid Twitter Username');
|
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-twitter-input]', 'testuser');
|
|
|
|
await triggerEvent('[data-test-twitter-input]', 'blur');
|
2017-04-24 15:29:48 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
expect(find('[data-test-twitter-input]').val()).to.be.equal('https://twitter.com/testuser');
|
|
|
|
expect(find('[data-test-twitter-error]').text().trim(), 'inline validation response')
|
2017-04-24 15:29:48 +03:00
|
|
|
.to.equal('');
|
2016-02-11 15:06:29 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|