2020-09-21 20:14:57 +03:00
|
|
|
import ctrlOrCmd from 'ghost-admin/utils/ctrl-or-cmd';
|
2017-05-29 21:50:03 +03:00
|
|
|
import moment from 'moment';
|
Scheduler UI
refs TryGhost/Ghost#6413 and TryGhost/Ghost#6870
needs TryGhost/Ghost#6861
- **Post Settings Menu (PSM)**:'Publish Date' input accepts a date from now, min. 2 minutes to allow scheduler processing on the server. Also, there will always be some delay between typing the date and clicking on the 'Schedule Post' button. If the user types a future date for an already published post, the date will be reseted and he sees the message, that the post needs to be unpublished first. Once, the date is accepted, the label will change to 'Scheduled Date'.
- adds a CP 'timeScheduled' to post model, which will return `true` if the publish time is currently in the future.
- **Changes to the button flow in editor**:
- if the the CP `timeScheduled` returns true, a different drop-down-menu will be shown: 'Schedule Post' replaces 'Publish Now' and 'Unschedule' replaces 'Unpublish'.
- Covering the _edge cases_, especially when a scheduled post is about to be published, while the user is in the editor.
- First, a new CP `scheduleCountdown` will return the remaining time, when the estimated publish time is 15 minutes from now. A notification with this live-ticker is shown next to the save button. Once, we reach a 2 minutes limit, another CP `statusFreeze` will return true and causes the save button to only show `Unschedule` in a red state, until we reach the publish time
- Once the publish time is reached, a CP `scheduledWillPublish` causes the buttons and the existing code to pretend we're already dealing with a publish post. At the moment, there's no way to make a background-fetch of the now serverside-scheduled post model from the server, so Ember doesn't know about the changed state at that time.
- Changes in the editor, which are done during this 'status freeze'-process will be saved back correctly, once the user hits 'Update Post' after the buttons changed back. A click on 'Unpublish' will change the status back to a draft.
- The user will get a regular 'toaster' notification that the post has been published.
- adds CP `isScheduled` for scheduled posts
- adds CP `offset` to component `gh-posts-list-item` and helper `gh-format-time-scheduled` to show schedule date in content overview.
- sets timeout in `gh-spin-button` to 10ms for `Ember.testing`
- changes error message in `gh-editor-base-controller` to be in one line, seperated with a `:`
TODOs:
- [x] new sort order for posts (1. scheduled, 2. draft, 3. published) (refs TryGhost/Ghost#6932)
- [ ] Move posts sorting from posts controller to model and refactor to use `Ember.comparable` mixin
- [x] Flows for draft -> scheduled -> published like described in TryGhost/Ghost#6870 incl. edge cases and button behaviour
- [x] Tests
- [x] new PSM behaviour for time/date in future
- [x] display publishedAt date with timezone offset on posts overview
2016-02-02 10:04:40 +03:00
|
|
|
import sinon from 'sinon';
|
2022-03-08 14:32:01 +03:00
|
|
|
import {Response} from 'miragejs';
|
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, currentRouteName, currentURL, fillIn, find, findAll, triggerEvent} from '@ember/test-helpers';
|
|
|
|
import {datepickerSelect} from 'ember-power-datepicker/test-support';
|
2022-04-21 16:48:25 +03:00
|
|
|
import {enableMailgun} from '../helpers/mailgun';
|
|
|
|
import {enableNewsletters} from '../helpers/newsletters';
|
2017-05-29 21:50:03 +03:00
|
|
|
import {expect} from 'chai';
|
2019-01-02 12:58:55 +03:00
|
|
|
import {selectChoose} from 'ember-power-select/test-support';
|
|
|
|
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';
|
2022-04-21 16:48:25 +03:00
|
|
|
import { enableStripe } from '../helpers/stripe';
|
2017-04-05 20:45:35 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
// TODO: update ember-power-datepicker to expose modern test helpers
|
|
|
|
// https://github.com/cibernox/ember-power-datepicker/issues/30
|
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
|
|
|
describe('Acceptance: Editor', function () {
|
|
|
|
let hooks = setupApplicationTest();
|
|
|
|
setupMirage(hooks);
|
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-19 16:21:37 +03:00
|
|
|
it('redirects to signin when not authenticated', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
let author = this.server.create('user'); // necesary for post-author association
|
|
|
|
this.server.create('post', {authors: [author]});
|
2016-06-30 17:45:02 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await invalidateSession();
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit('/editor/post/1');
|
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-19 16:21:37 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/signin');
|
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-02-22 12:43:35 +03:00
|
|
|
it('does not redirect 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'});
|
|
|
|
let author = this.server.create('user', {roles: [role], slug: 'test-user'});
|
|
|
|
this.server.create('post', {authors: [author]});
|
2018-02-07 12:42:46 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await authenticateSession();
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit('/editor/post/1');
|
2018-02-07 12:42:46 +03:00
|
|
|
|
2019-02-22 06:17:33 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/editor/post/1');
|
2018-02-07 12:42:46 +03:00
|
|
|
});
|
|
|
|
|
2019-02-22 12:43:35 +03:00
|
|
|
it('does not redirect 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'});
|
|
|
|
let author = this.server.create('user', {roles: [role], slug: 'test-user'});
|
|
|
|
this.server.create('post', {authors: [author]});
|
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 authenticateSession();
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit('/editor/post/1');
|
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-02-22 06:17:33 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/editor/post/1');
|
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-02-22 12:43:35 +03:00
|
|
|
it('does not redirect 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'});
|
|
|
|
let author = this.server.create('user', {roles: [role], slug: 'test-user'});
|
|
|
|
this.server.create('post', {authors: [author]});
|
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 authenticateSession();
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit('/editor/post/1');
|
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-02-22 06:17:33 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/editor/post/1');
|
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-19 16:21:37 +03:00
|
|
|
it('displays 404 when post does not exist', 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-06-30 17:45:02 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
await authenticateSession();
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit('/editor/post/1');
|
2016-06-30 17:45:02 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(currentRouteName()).to.equal('error404');
|
2019-02-22 06:17:33 +03:00
|
|
|
expect(currentURL()).to.equal('/editor/post/1');
|
2016-06-30 17:45:02 +03:00
|
|
|
});
|
|
|
|
|
2018-03-19 12:53:17 +03:00
|
|
|
it('when logged in as a contributor, renders a save button instead of a publish menu & hides tags input', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
let role = this.server.create('role', {name: 'Contributor'});
|
|
|
|
let author = this.server.create('user', {roles: [role]});
|
|
|
|
this.server.createList('post', 2, {authors: [author]});
|
|
|
|
this.server.loadFixtures('settings');
|
|
|
|
await authenticateSession();
|
2018-02-07 12:42:46 +03:00
|
|
|
|
2018-03-19 12:53:17 +03:00
|
|
|
// post id 1 is a draft, checking for draft behaviour now
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit('/editor/post/1');
|
2018-02-07 12:42:46 +03:00
|
|
|
|
2019-02-22 06:17:33 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/editor/post/1');
|
2018-02-07 12:42:46 +03:00
|
|
|
|
2018-03-19 12:53:17 +03:00
|
|
|
// Expect publish menu to not exist
|
|
|
|
expect(
|
|
|
|
find('[data-test-publishmenu-trigger]'),
|
|
|
|
'publish menu trigger'
|
|
|
|
).to.not.exist;
|
2018-02-07 12:42:46 +03:00
|
|
|
|
2018-03-19 12:53:17 +03:00
|
|
|
// Open post settings menu
|
|
|
|
await click('[data-test-psm-trigger]');
|
2018-02-07 12:42:46 +03:00
|
|
|
|
2018-03-19 12:53:17 +03:00
|
|
|
// Check to make sure that tags input doesn't exist
|
|
|
|
expect(
|
|
|
|
find('[data-test-token-input]'),
|
|
|
|
'tags input'
|
|
|
|
).to.not.exist;
|
2018-02-07 12:42:46 +03:00
|
|
|
|
2018-03-19 12:53:17 +03:00
|
|
|
// post id 2 is published, we should be redirected to index
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit('/editor/post/2');
|
2018-02-07 12:42:46 +03:00
|
|
|
|
2019-03-21 12:33:14 +03:00
|
|
|
expect(currentURL(), 'currentURL').to.equal('/posts');
|
2018-02-07 12:42:46 +03:00
|
|
|
});
|
|
|
|
|
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
|
|
|
describe('when logged in', function () {
|
2018-03-19 12:53:17 +03:00
|
|
|
let author;
|
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
beforeEach(async function () {
|
|
|
|
let role = this.server.create('role', {name: 'Administrator'});
|
|
|
|
author = this.server.create('user', {roles: [role]});
|
|
|
|
this.server.loadFixtures('settings');
|
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
|
|
|
return await authenticateSession();
|
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
|
|
|
});
|
|
|
|
|
2021-10-07 14:10:20 +03:00
|
|
|
it('renders the editor correctly, PSM Publish Date and Save Button', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
let [post1] = this.server.createList('post', 2, {authors: [author]});
|
2017-04-11 17:48:20 +03:00
|
|
|
let futureTime = moment().tz('Etc/UTC').add(10, 'minutes');
|
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
|
|
|
|
|
|
|
// post id 1 is a draft, checking for draft behaviour now
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit('/editor/post/1');
|
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-19 16:21:37 +03:00
|
|
|
expect(currentURL(), 'currentURL')
|
2019-02-22 06:17:33 +03:00
|
|
|
.to.equal('/editor/post/1');
|
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-11 16:39:45 +03:00
|
|
|
// open post settings menu
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-psm-trigger]');
|
2017-04-11 16:39:45 +03:00
|
|
|
|
|
|
|
// should error, if the publish time is in the wrong format
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-date-time-picker-time-input]', 'foo');
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-date-time-picker-time-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
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-date-time-picker-error]').textContent.trim(), 'inline error response for invalid time')
|
2017-04-19 16:21:37 +03:00
|
|
|
.to.equal('Must be in format: "15:00"');
|
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-11 16:39:45 +03:00
|
|
|
// should error, if the publish time is in the future
|
2017-04-24 10:29:41 +03:00
|
|
|
// NOTE: date must be selected first, changing the time first will save
|
|
|
|
// with the new time
|
2022-02-01 12:34:03 +03:00
|
|
|
await fillIn('[data-test-date-time-picker-datepicker] input', moment.tz('Etc/UTC').add(1, 'day').format('YYYY-MM-DD'));
|
|
|
|
await blur('[data-test-date-time-picker-datepicker] input');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-date-time-picker-time-input]', futureTime.format('HH:mm'));
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-date-time-picker-time-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
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-date-time-picker-error]').textContent.trim(), 'inline error response for future time')
|
2017-04-19 16:21:37 +03:00
|
|
|
.to.equal('Must be in the past');
|
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 10:29:41 +03:00
|
|
|
// closing the PSM will reset the invalid date/time
|
2021-07-02 21:57:58 +03:00
|
|
|
await click('[data-test-psm-trigger]');
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-psm-trigger]');
|
2017-04-24 10:29:41 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-date-time-picker-error]'),
|
2017-04-24 10:29:41 +03:00
|
|
|
'date picker error after closing PSM'
|
2019-01-02 12:58:55 +03:00
|
|
|
).to.not.exist;
|
2017-04-24 10:29:41 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-date-time-picker-date-input]').value,
|
2017-04-24 10:29:41 +03:00
|
|
|
'PSM date value after closing with invalid date'
|
2019-06-24 11:06:39 +03:00
|
|
|
).to.equal(moment(post1.publishedAt).tz('Etc/UTC').format('YYYY-MM-DD'));
|
2017-04-24 10:29:41 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-date-time-picker-time-input]').value,
|
2017-04-24 10:29:41 +03:00
|
|
|
'PSM time value after closing with invalid date'
|
2017-09-07 14:17:36 +03:00
|
|
|
).to.equal(moment(post1.publishedAt).tz('Etc/UTC').format('HH:mm'));
|
2017-04-24 10:29:41 +03:00
|
|
|
|
2017-04-11 16:39:45 +03:00
|
|
|
// saves the post with the new date
|
2017-09-07 14:17:36 +03:00
|
|
|
let validTime = moment('2017-04-09 12:00').tz('Etc/UTC');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-date-time-picker-time-input]', validTime.format('HH:mm'));
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-date-time-picker-time-input]');
|
|
|
|
await datepickerSelect('[data-test-date-time-picker-datepicker]', validTime.toDate());
|
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-11 16:39:45 +03:00
|
|
|
// hide psm
|
2021-07-02 21:57:58 +03:00
|
|
|
await click('[data-test-psm-trigger]');
|
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
|
|
|
|
|
|
|
// checking the flow of the saving button for a draft
|
2017-04-19 16:21:37 +03:00
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-trigger]').textContent.trim(),
|
2017-04-19 16:21:37 +03:00
|
|
|
'draft publish button text'
|
|
|
|
).to.equal('Publish');
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-editor-post-status]').textContent.trim(),
|
2017-04-19 16:21:37 +03:00
|
|
|
'draft status text'
|
2021-08-31 12:11:40 +03:00
|
|
|
).to.match(/Draft\s+- Saved/);
|
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
|
|
|
|
|
|
|
// click on publish now
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-trigger]');
|
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-19 16:21:37 +03:00
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-publishmenu-draft]'),
|
2017-04-19 16:21:37 +03:00
|
|
|
'draft publish menu is shown'
|
|
|
|
).to.exist;
|
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 click('[data-test-publishmenu-scheduled-option]');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-save]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'draft post schedule button text'
|
|
|
|
).to.equal('Schedule');
|
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-published-option]');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-save]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'draft post publish button text'
|
2021-10-21 15:16:20 +03:00
|
|
|
).to.equal('Publish');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
2021-12-07 03:18:13 +03:00
|
|
|
// Publish the post and re-open publish menu
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-save]');
|
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-06-15 20:35:23 +03:00
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-save]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'publish menu save button updated after draft is published'
|
2020-04-23 23:11:04 +03:00
|
|
|
).to.equal('Update');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
2017-04-19 16:21:37 +03:00
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-publishmenu-published]'),
|
2017-04-19 16:21:37 +03:00
|
|
|
'publish menu is shown after draft published'
|
|
|
|
).to.exist;
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-editor-post-status]').textContent.trim(),
|
2017-04-19 16:21:37 +03:00
|
|
|
'post status updated after draft published'
|
2019-11-08 12:01:40 +03:00
|
|
|
).to.equal('Published');
|
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 click('[data-test-publishmenu-cancel]');
|
|
|
|
await click('[data-test-publishmenu-trigger]');
|
|
|
|
await click('[data-test-publishmenu-unpublished-option]');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-save]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'published post unpublish button text'
|
2017-07-20 13:46:31 +03:00
|
|
|
).to.equal('Unpublish');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
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
|
|
|
// post id 2 is a published post, checking for published post behaviour now
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit('/editor/post/2');
|
|
|
|
expect(currentURL(), 'currentURL').to.equal('/editor/post/2');
|
2021-07-02 21:57:58 +03:00
|
|
|
|
|
|
|
await click('[data-test-psm-trigger]');
|
2019-06-24 11:06:39 +03:00
|
|
|
expect(find('[data-test-date-time-picker-date-input]').value).to.equal('2015-12-19');
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-date-time-picker-time-input]').value).to.equal('16:25');
|
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
|
|
|
|
|
|
|
// saves the post with a new date
|
2019-01-02 12:58:55 +03:00
|
|
|
await datepickerSelect('[data-test-date-time-picker-datepicker]', moment('2016-05-10 10:00').toDate());
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-date-time-picker-time-input]', '10:00');
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-date-time-picker-time-input]');
|
2021-07-02 21:57:58 +03:00
|
|
|
|
|
|
|
await click('[data-test-psm-trigger]');
|
|
|
|
|
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
|
|
|
// saving
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-trigger]');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-save]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'published button text'
|
|
|
|
).to.equal('Update');
|
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-save]');
|
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-06-15 20:35:23 +03:00
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-save]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'publish menu save button updated after published post is updated'
|
2020-04-23 23:11:04 +03:00
|
|
|
).to.equal('Update');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
Scheduler UI
refs TryGhost/Ghost#6413 and TryGhost/Ghost#6870
needs TryGhost/Ghost#6861
- **Post Settings Menu (PSM)**:'Publish Date' input accepts a date from now, min. 2 minutes to allow scheduler processing on the server. Also, there will always be some delay between typing the date and clicking on the 'Schedule Post' button. If the user types a future date for an already published post, the date will be reseted and he sees the message, that the post needs to be unpublished first. Once, the date is accepted, the label will change to 'Scheduled Date'.
- adds a CP 'timeScheduled' to post model, which will return `true` if the publish time is currently in the future.
- **Changes to the button flow in editor**:
- if the the CP `timeScheduled` returns true, a different drop-down-menu will be shown: 'Schedule Post' replaces 'Publish Now' and 'Unschedule' replaces 'Unpublish'.
- Covering the _edge cases_, especially when a scheduled post is about to be published, while the user is in the editor.
- First, a new CP `scheduleCountdown` will return the remaining time, when the estimated publish time is 15 minutes from now. A notification with this live-ticker is shown next to the save button. Once, we reach a 2 minutes limit, another CP `statusFreeze` will return true and causes the save button to only show `Unschedule` in a red state, until we reach the publish time
- Once the publish time is reached, a CP `scheduledWillPublish` causes the buttons and the existing code to pretend we're already dealing with a publish post. At the moment, there's no way to make a background-fetch of the now serverside-scheduled post model from the server, so Ember doesn't know about the changed state at that time.
- Changes in the editor, which are done during this 'status freeze'-process will be saved back correctly, once the user hits 'Update Post' after the buttons changed back. A click on 'Unpublish' will change the status back to a draft.
- The user will get a regular 'toaster' notification that the post has been published.
- adds CP `isScheduled` for scheduled posts
- adds CP `offset` to component `gh-posts-list-item` and helper `gh-format-time-scheduled` to show schedule date in content overview.
- sets timeout in `gh-spin-button` to 10ms for `Ember.testing`
- changes error message in `gh-editor-base-controller` to be in one line, seperated with a `:`
TODOs:
- [x] new sort order for posts (1. scheduled, 2. draft, 3. published) (refs TryGhost/Ghost#6932)
- [ ] Move posts sorting from posts controller to model and refactor to use `Ember.comparable` mixin
- [x] Flows for draft -> scheduled -> published like described in TryGhost/Ghost#6870 incl. edge cases and button behaviour
- [x] Tests
- [x] new PSM behaviour for time/date in future
- [x] display publishedAt date with timezone offset on posts overview
2016-02-02 10:04:40 +03:00
|
|
|
// go to settings to change the timezone
|
2017-04-19 16:21:37 +03:00
|
|
|
await visit('/settings/general');
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-toggle-timezone]');
|
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-19 16:21:37 +03:00
|
|
|
expect(currentURL(), 'currentURL for settings')
|
|
|
|
.to.equal('/settings/general');
|
2020-06-24 17:34:59 +03:00
|
|
|
expect(find('#timezone option:checked').textContent.trim(), 'default timezone')
|
2017-04-19 16:21:37 +03:00
|
|
|
.to.equal('(GMT) UTC');
|
Scheduler UI
refs TryGhost/Ghost#6413 and TryGhost/Ghost#6870
needs TryGhost/Ghost#6861
- **Post Settings Menu (PSM)**:'Publish Date' input accepts a date from now, min. 2 minutes to allow scheduler processing on the server. Also, there will always be some delay between typing the date and clicking on the 'Schedule Post' button. If the user types a future date for an already published post, the date will be reseted and he sees the message, that the post needs to be unpublished first. Once, the date is accepted, the label will change to 'Scheduled Date'.
- adds a CP 'timeScheduled' to post model, which will return `true` if the publish time is currently in the future.
- **Changes to the button flow in editor**:
- if the the CP `timeScheduled` returns true, a different drop-down-menu will be shown: 'Schedule Post' replaces 'Publish Now' and 'Unschedule' replaces 'Unpublish'.
- Covering the _edge cases_, especially when a scheduled post is about to be published, while the user is in the editor.
- First, a new CP `scheduleCountdown` will return the remaining time, when the estimated publish time is 15 minutes from now. A notification with this live-ticker is shown next to the save button. Once, we reach a 2 minutes limit, another CP `statusFreeze` will return true and causes the save button to only show `Unschedule` in a red state, until we reach the publish time
- Once the publish time is reached, a CP `scheduledWillPublish` causes the buttons and the existing code to pretend we're already dealing with a publish post. At the moment, there's no way to make a background-fetch of the now serverside-scheduled post model from the server, so Ember doesn't know about the changed state at that time.
- Changes in the editor, which are done during this 'status freeze'-process will be saved back correctly, once the user hits 'Update Post' after the buttons changed back. A click on 'Unpublish' will change the status back to a draft.
- The user will get a regular 'toaster' notification that the post has been published.
- adds CP `isScheduled` for scheduled posts
- adds CP `offset` to component `gh-posts-list-item` and helper `gh-format-time-scheduled` to show schedule date in content overview.
- sets timeout in `gh-spin-button` to 10ms for `Ember.testing`
- changes error message in `gh-editor-base-controller` to be in one line, seperated with a `:`
TODOs:
- [x] new sort order for posts (1. scheduled, 2. draft, 3. published) (refs TryGhost/Ghost#6932)
- [ ] Move posts sorting from posts controller to model and refactor to use `Ember.comparable` mixin
- [x] Flows for draft -> scheduled -> published like described in TryGhost/Ghost#6870 incl. edge cases and button behaviour
- [x] Tests
- [x] new PSM behaviour for time/date in future
- [x] display publishedAt date with timezone offset on posts overview
2016-02-02 10:04:40 +03:00
|
|
|
|
2017-04-19 16:21:37 +03:00
|
|
|
// select a new timezone
|
2020-06-24 17:34:59 +03:00
|
|
|
find('#timezone option[value="Pacific/Kwajalein"]').selected = true;
|
2017-04-19 16:21:37 +03:00
|
|
|
|
2020-06-24 17:34:59 +03:00
|
|
|
await triggerEvent('#timezone', 'change');
|
Scheduler UI
refs TryGhost/Ghost#6413 and TryGhost/Ghost#6870
needs TryGhost/Ghost#6861
- **Post Settings Menu (PSM)**:'Publish Date' input accepts a date from now, min. 2 minutes to allow scheduler processing on the server. Also, there will always be some delay between typing the date and clicking on the 'Schedule Post' button. If the user types a future date for an already published post, the date will be reseted and he sees the message, that the post needs to be unpublished first. Once, the date is accepted, the label will change to 'Scheduled Date'.
- adds a CP 'timeScheduled' to post model, which will return `true` if the publish time is currently in the future.
- **Changes to the button flow in editor**:
- if the the CP `timeScheduled` returns true, a different drop-down-menu will be shown: 'Schedule Post' replaces 'Publish Now' and 'Unschedule' replaces 'Unpublish'.
- Covering the _edge cases_, especially when a scheduled post is about to be published, while the user is in the editor.
- First, a new CP `scheduleCountdown` will return the remaining time, when the estimated publish time is 15 minutes from now. A notification with this live-ticker is shown next to the save button. Once, we reach a 2 minutes limit, another CP `statusFreeze` will return true and causes the save button to only show `Unschedule` in a red state, until we reach the publish time
- Once the publish time is reached, a CP `scheduledWillPublish` causes the buttons and the existing code to pretend we're already dealing with a publish post. At the moment, there's no way to make a background-fetch of the now serverside-scheduled post model from the server, so Ember doesn't know about the changed state at that time.
- Changes in the editor, which are done during this 'status freeze'-process will be saved back correctly, once the user hits 'Update Post' after the buttons changed back. A click on 'Unpublish' will change the status back to a draft.
- The user will get a regular 'toaster' notification that the post has been published.
- adds CP `isScheduled` for scheduled posts
- adds CP `offset` to component `gh-posts-list-item` and helper `gh-format-time-scheduled` to show schedule date in content overview.
- sets timeout in `gh-spin-button` to 10ms for `Ember.testing`
- changes error message in `gh-editor-base-controller` to be in one line, seperated with a `:`
TODOs:
- [x] new sort order for posts (1. scheduled, 2. draft, 3. published) (refs TryGhost/Ghost#6932)
- [ ] Move posts sorting from posts controller to model and refactor to use `Ember.comparable` mixin
- [x] Flows for draft -> scheduled -> published like described in TryGhost/Ghost#6870 incl. edge cases and button behaviour
- [x] Tests
- [x] new PSM behaviour for time/date in future
- [x] display publishedAt date with timezone offset on posts overview
2016-02-02 10:04:40 +03:00
|
|
|
// save the settings
|
2021-02-09 00:56:18 +03:00
|
|
|
await click('[data-test-button="save"]');
|
Scheduler UI
refs TryGhost/Ghost#6413 and TryGhost/Ghost#6870
needs TryGhost/Ghost#6861
- **Post Settings Menu (PSM)**:'Publish Date' input accepts a date from now, min. 2 minutes to allow scheduler processing on the server. Also, there will always be some delay between typing the date and clicking on the 'Schedule Post' button. If the user types a future date for an already published post, the date will be reseted and he sees the message, that the post needs to be unpublished first. Once, the date is accepted, the label will change to 'Scheduled Date'.
- adds a CP 'timeScheduled' to post model, which will return `true` if the publish time is currently in the future.
- **Changes to the button flow in editor**:
- if the the CP `timeScheduled` returns true, a different drop-down-menu will be shown: 'Schedule Post' replaces 'Publish Now' and 'Unschedule' replaces 'Unpublish'.
- Covering the _edge cases_, especially when a scheduled post is about to be published, while the user is in the editor.
- First, a new CP `scheduleCountdown` will return the remaining time, when the estimated publish time is 15 minutes from now. A notification with this live-ticker is shown next to the save button. Once, we reach a 2 minutes limit, another CP `statusFreeze` will return true and causes the save button to only show `Unschedule` in a red state, until we reach the publish time
- Once the publish time is reached, a CP `scheduledWillPublish` causes the buttons and the existing code to pretend we're already dealing with a publish post. At the moment, there's no way to make a background-fetch of the now serverside-scheduled post model from the server, so Ember doesn't know about the changed state at that time.
- Changes in the editor, which are done during this 'status freeze'-process will be saved back correctly, once the user hits 'Update Post' after the buttons changed back. A click on 'Unpublish' will change the status back to a draft.
- The user will get a regular 'toaster' notification that the post has been published.
- adds CP `isScheduled` for scheduled posts
- adds CP `offset` to component `gh-posts-list-item` and helper `gh-format-time-scheduled` to show schedule date in content overview.
- sets timeout in `gh-spin-button` to 10ms for `Ember.testing`
- changes error message in `gh-editor-base-controller` to be in one line, seperated with a `:`
TODOs:
- [x] new sort order for posts (1. scheduled, 2. draft, 3. published) (refs TryGhost/Ghost#6932)
- [ ] Move posts sorting from posts controller to model and refactor to use `Ember.comparable` mixin
- [x] Flows for draft -> scheduled -> published like described in TryGhost/Ghost#6870 incl. edge cases and button behaviour
- [x] Tests
- [x] new PSM behaviour for time/date in future
- [x] display publishedAt date with timezone offset on posts overview
2016-02-02 10:04:40 +03:00
|
|
|
|
2020-06-24 17:34:59 +03:00
|
|
|
expect(find('#timezone option:checked').textContent.trim(), 'new timezone after saving')
|
2017-04-19 16:21:37 +03:00
|
|
|
.to.equal('(GMT +12:00) International Date Line West');
|
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
|
|
|
|
Scheduler UI
refs TryGhost/Ghost#6413 and TryGhost/Ghost#6870
needs TryGhost/Ghost#6861
- **Post Settings Menu (PSM)**:'Publish Date' input accepts a date from now, min. 2 minutes to allow scheduler processing on the server. Also, there will always be some delay between typing the date and clicking on the 'Schedule Post' button. If the user types a future date for an already published post, the date will be reseted and he sees the message, that the post needs to be unpublished first. Once, the date is accepted, the label will change to 'Scheduled Date'.
- adds a CP 'timeScheduled' to post model, which will return `true` if the publish time is currently in the future.
- **Changes to the button flow in editor**:
- if the the CP `timeScheduled` returns true, a different drop-down-menu will be shown: 'Schedule Post' replaces 'Publish Now' and 'Unschedule' replaces 'Unpublish'.
- Covering the _edge cases_, especially when a scheduled post is about to be published, while the user is in the editor.
- First, a new CP `scheduleCountdown` will return the remaining time, when the estimated publish time is 15 minutes from now. A notification with this live-ticker is shown next to the save button. Once, we reach a 2 minutes limit, another CP `statusFreeze` will return true and causes the save button to only show `Unschedule` in a red state, until we reach the publish time
- Once the publish time is reached, a CP `scheduledWillPublish` causes the buttons and the existing code to pretend we're already dealing with a publish post. At the moment, there's no way to make a background-fetch of the now serverside-scheduled post model from the server, so Ember doesn't know about the changed state at that time.
- Changes in the editor, which are done during this 'status freeze'-process will be saved back correctly, once the user hits 'Update Post' after the buttons changed back. A click on 'Unpublish' will change the status back to a draft.
- The user will get a regular 'toaster' notification that the post has been published.
- adds CP `isScheduled` for scheduled posts
- adds CP `offset` to component `gh-posts-list-item` and helper `gh-format-time-scheduled` to show schedule date in content overview.
- sets timeout in `gh-spin-button` to 10ms for `Ember.testing`
- changes error message in `gh-editor-base-controller` to be in one line, seperated with a `:`
TODOs:
- [x] new sort order for posts (1. scheduled, 2. draft, 3. published) (refs TryGhost/Ghost#6932)
- [ ] Move posts sorting from posts controller to model and refactor to use `Ember.comparable` mixin
- [x] Flows for draft -> scheduled -> published like described in TryGhost/Ghost#6870 incl. edge cases and button behaviour
- [x] Tests
- [x] new PSM behaviour for time/date in future
- [x] display publishedAt date with timezone offset on posts overview
2016-02-02 10:04:40 +03:00
|
|
|
// and now go back to the editor
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit('/editor/post/2');
|
Scheduler UI
refs TryGhost/Ghost#6413 and TryGhost/Ghost#6870
needs TryGhost/Ghost#6861
- **Post Settings Menu (PSM)**:'Publish Date' input accepts a date from now, min. 2 minutes to allow scheduler processing on the server. Also, there will always be some delay between typing the date and clicking on the 'Schedule Post' button. If the user types a future date for an already published post, the date will be reseted and he sees the message, that the post needs to be unpublished first. Once, the date is accepted, the label will change to 'Scheduled Date'.
- adds a CP 'timeScheduled' to post model, which will return `true` if the publish time is currently in the future.
- **Changes to the button flow in editor**:
- if the the CP `timeScheduled` returns true, a different drop-down-menu will be shown: 'Schedule Post' replaces 'Publish Now' and 'Unschedule' replaces 'Unpublish'.
- Covering the _edge cases_, especially when a scheduled post is about to be published, while the user is in the editor.
- First, a new CP `scheduleCountdown` will return the remaining time, when the estimated publish time is 15 minutes from now. A notification with this live-ticker is shown next to the save button. Once, we reach a 2 minutes limit, another CP `statusFreeze` will return true and causes the save button to only show `Unschedule` in a red state, until we reach the publish time
- Once the publish time is reached, a CP `scheduledWillPublish` causes the buttons and the existing code to pretend we're already dealing with a publish post. At the moment, there's no way to make a background-fetch of the now serverside-scheduled post model from the server, so Ember doesn't know about the changed state at that time.
- Changes in the editor, which are done during this 'status freeze'-process will be saved back correctly, once the user hits 'Update Post' after the buttons changed back. A click on 'Unpublish' will change the status back to a draft.
- The user will get a regular 'toaster' notification that the post has been published.
- adds CP `isScheduled` for scheduled posts
- adds CP `offset` to component `gh-posts-list-item` and helper `gh-format-time-scheduled` to show schedule date in content overview.
- sets timeout in `gh-spin-button` to 10ms for `Ember.testing`
- changes error message in `gh-editor-base-controller` to be in one line, seperated with a `:`
TODOs:
- [x] new sort order for posts (1. scheduled, 2. draft, 3. published) (refs TryGhost/Ghost#6932)
- [ ] Move posts sorting from posts controller to model and refactor to use `Ember.comparable` mixin
- [x] Flows for draft -> scheduled -> published like described in TryGhost/Ghost#6870 incl. edge cases and button behaviour
- [x] Tests
- [x] new PSM behaviour for time/date in future
- [x] display publishedAt date with timezone offset on posts overview
2016-02-02 10:04:40 +03:00
|
|
|
|
2017-04-19 16:21:37 +03:00
|
|
|
expect(currentURL(), 'currentURL in editor')
|
2019-02-22 06:17:33 +03:00
|
|
|
.to.equal('/editor/post/2');
|
2017-04-19 16:21:37 +03:00
|
|
|
|
2021-07-02 21:57:58 +03:00
|
|
|
await click('[data-test-psm-trigger]');
|
2017-04-19 16:21:37 +03:00
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-date-time-picker-date-input]').value,
|
2017-04-19 16:21:37 +03:00
|
|
|
'date after timezone change'
|
2019-06-24 11:06:39 +03:00
|
|
|
).to.equal('2016-05-10');
|
2017-04-19 16:21:37 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-date-time-picker-time-input]').value,
|
2017-04-19 16:21:37 +03:00
|
|
|
'time after timezone change'
|
|
|
|
).to.equal('22:00');
|
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-11 16:39:45 +03:00
|
|
|
// unpublish
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-trigger]');
|
|
|
|
await click('[data-test-publishmenu-unpublished-option]');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-save]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'published post unpublish button text'
|
2017-07-20 13:46:31 +03:00
|
|
|
).to.equal('Unpublish');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-save]');
|
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-06-15 20:35:23 +03:00
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-save]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'publish menu save button updated after published post is unpublished'
|
2021-10-21 15:16:20 +03:00
|
|
|
).to.equal('Publish');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
2017-04-19 16:21:37 +03:00
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-publishmenu-draft]'),
|
2017-04-19 16:21:37 +03:00
|
|
|
'draft menu is shown after unpublished'
|
|
|
|
).to.exist;
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-editor-post-status]').textContent.trim(),
|
2017-04-19 16:21:37 +03:00
|
|
|
'post status updated after unpublished'
|
2021-08-31 12:11:40 +03:00
|
|
|
).to.match(/Draft\s+- Saved/);
|
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-11 16:39:45 +03:00
|
|
|
// schedule post
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-cancel]');
|
|
|
|
await click('[data-test-publishmenu-trigger]');
|
|
|
|
await click('[data-test-publishmenu-scheduled-option]');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-save]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'draft post, schedule button text'
|
|
|
|
).to.equal('Schedule');
|
|
|
|
|
2022-01-06 16:02:09 +03:00
|
|
|
// get time in current timezone and select the current date
|
|
|
|
// will result in the default +5mins schedule time
|
|
|
|
let newFutureTime = moment.tz('Pacific/Kwajalein');
|
2019-01-02 12:58:55 +03:00
|
|
|
await datepickerSelect('[data-test-publishmenu-draft] [data-test-date-time-picker-datepicker]', new Date(newFutureTime.format().replace(/\+.*$/, '')));
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-save]');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-save]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'publish menu save button updated after draft is scheduled'
|
2020-04-23 23:11:04 +03:00
|
|
|
).to.equal('Reschedule');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-cancel]');
|
2017-04-19 16:21:37 +03:00
|
|
|
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-publishmenu-scheduled]'),
|
2017-04-19 16:21:37 +03:00
|
|
|
'publish menu is not shown after closed'
|
|
|
|
).to.not.exist;
|
|
|
|
|
2019-11-13 19:10:29 +03:00
|
|
|
// expect countdown to show warning that post is scheduled to be published
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-schedule-countdown]').textContent.trim(), 'notification countdown')
|
2021-06-11 14:10:28 +03:00
|
|
|
.to.match(/Will be published\s+in (4|5) minutes/);
|
2017-06-15 20:35:23 +03:00
|
|
|
|
2017-04-19 16:21:37 +03:00
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-trigger]').textContent.trim(),
|
2017-04-19 16:21:37 +03:00
|
|
|
'scheduled publish button text'
|
|
|
|
).to.equal('Scheduled');
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-editor-post-status]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'scheduled post status'
|
2021-06-11 14:10:28 +03:00
|
|
|
).to.match(/Will be published\s+in (4|5) minutes/);
|
Scheduler UI
refs TryGhost/Ghost#6413 and TryGhost/Ghost#6870
needs TryGhost/Ghost#6861
- **Post Settings Menu (PSM)**:'Publish Date' input accepts a date from now, min. 2 minutes to allow scheduler processing on the server. Also, there will always be some delay between typing the date and clicking on the 'Schedule Post' button. If the user types a future date for an already published post, the date will be reseted and he sees the message, that the post needs to be unpublished first. Once, the date is accepted, the label will change to 'Scheduled Date'.
- adds a CP 'timeScheduled' to post model, which will return `true` if the publish time is currently in the future.
- **Changes to the button flow in editor**:
- if the the CP `timeScheduled` returns true, a different drop-down-menu will be shown: 'Schedule Post' replaces 'Publish Now' and 'Unschedule' replaces 'Unpublish'.
- Covering the _edge cases_, especially when a scheduled post is about to be published, while the user is in the editor.
- First, a new CP `scheduleCountdown` will return the remaining time, when the estimated publish time is 15 minutes from now. A notification with this live-ticker is shown next to the save button. Once, we reach a 2 minutes limit, another CP `statusFreeze` will return true and causes the save button to only show `Unschedule` in a red state, until we reach the publish time
- Once the publish time is reached, a CP `scheduledWillPublish` causes the buttons and the existing code to pretend we're already dealing with a publish post. At the moment, there's no way to make a background-fetch of the now serverside-scheduled post model from the server, so Ember doesn't know about the changed state at that time.
- Changes in the editor, which are done during this 'status freeze'-process will be saved back correctly, once the user hits 'Update Post' after the buttons changed back. A click on 'Unpublish' will change the status back to a draft.
- The user will get a regular 'toaster' notification that the post has been published.
- adds CP `isScheduled` for scheduled posts
- adds CP `offset` to component `gh-posts-list-item` and helper `gh-format-time-scheduled` to show schedule date in content overview.
- sets timeout in `gh-spin-button` to 10ms for `Ember.testing`
- changes error message in `gh-editor-base-controller` to be in one line, seperated with a `:`
TODOs:
- [x] new sort order for posts (1. scheduled, 2. draft, 3. published) (refs TryGhost/Ghost#6932)
- [ ] Move posts sorting from posts controller to model and refactor to use `Ember.comparable` mixin
- [x] Flows for draft -> scheduled -> published like described in TryGhost/Ghost#6870 incl. edge cases and button behaviour
- [x] Tests
- [x] new PSM behaviour for time/date in future
- [x] display publishedAt date with timezone offset on posts overview
2016-02-02 10:04:40 +03:00
|
|
|
|
2017-06-15 20:35:23 +03:00
|
|
|
// Re-schedule
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-trigger]');
|
|
|
|
await click('[data-test-publishmenu-scheduled-option]');
|
2017-06-15 20:35:23 +03:00
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-save]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'scheduled post button reschedule text'
|
2017-07-20 13:46:31 +03:00
|
|
|
).to.equal('Reschedule');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-save]');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-save]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'publish menu save button text for a rescheduled post'
|
2020-04-23 23:11:04 +03:00
|
|
|
).to.equal('Reschedule');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-cancel]');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-publishmenu-scheduled]'),
|
2017-06-15 20:35:23 +03:00
|
|
|
'publish menu is not shown after closed'
|
|
|
|
).to.not.exist;
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-editor-post-status]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'scheduled status text'
|
2021-06-11 14:10:28 +03:00
|
|
|
).to.match(/Will be published\s+in (4|5) minutes/);
|
Scheduler UI
refs TryGhost/Ghost#6413 and TryGhost/Ghost#6870
needs TryGhost/Ghost#6861
- **Post Settings Menu (PSM)**:'Publish Date' input accepts a date from now, min. 2 minutes to allow scheduler processing on the server. Also, there will always be some delay between typing the date and clicking on the 'Schedule Post' button. If the user types a future date for an already published post, the date will be reseted and he sees the message, that the post needs to be unpublished first. Once, the date is accepted, the label will change to 'Scheduled Date'.
- adds a CP 'timeScheduled' to post model, which will return `true` if the publish time is currently in the future.
- **Changes to the button flow in editor**:
- if the the CP `timeScheduled` returns true, a different drop-down-menu will be shown: 'Schedule Post' replaces 'Publish Now' and 'Unschedule' replaces 'Unpublish'.
- Covering the _edge cases_, especially when a scheduled post is about to be published, while the user is in the editor.
- First, a new CP `scheduleCountdown` will return the remaining time, when the estimated publish time is 15 minutes from now. A notification with this live-ticker is shown next to the save button. Once, we reach a 2 minutes limit, another CP `statusFreeze` will return true and causes the save button to only show `Unschedule` in a red state, until we reach the publish time
- Once the publish time is reached, a CP `scheduledWillPublish` causes the buttons and the existing code to pretend we're already dealing with a publish post. At the moment, there's no way to make a background-fetch of the now serverside-scheduled post model from the server, so Ember doesn't know about the changed state at that time.
- Changes in the editor, which are done during this 'status freeze'-process will be saved back correctly, once the user hits 'Update Post' after the buttons changed back. A click on 'Unpublish' will change the status back to a draft.
- The user will get a regular 'toaster' notification that the post has been published.
- adds CP `isScheduled` for scheduled posts
- adds CP `offset` to component `gh-posts-list-item` and helper `gh-format-time-scheduled` to show schedule date in content overview.
- sets timeout in `gh-spin-button` to 10ms for `Ember.testing`
- changes error message in `gh-editor-base-controller` to be in one line, seperated with a `:`
TODOs:
- [x] new sort order for posts (1. scheduled, 2. draft, 3. published) (refs TryGhost/Ghost#6932)
- [ ] Move posts sorting from posts controller to model and refactor to use `Ember.comparable` mixin
- [x] Flows for draft -> scheduled -> published like described in TryGhost/Ghost#6870 incl. edge cases and button behaviour
- [x] Tests
- [x] new PSM behaviour for time/date in future
- [x] display publishedAt date with timezone offset on posts overview
2016-02-02 10:04:40 +03:00
|
|
|
|
2017-04-11 16:39:45 +03:00
|
|
|
// unschedule
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-trigger]');
|
|
|
|
await click('[data-test-publishmenu-draft-option]');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-save]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'publish menu save button updated after scheduled post is unscheduled'
|
2017-07-20 13:46:31 +03:00
|
|
|
).to.equal('Unschedule');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-save]');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-save]').textContent.trim(),
|
2017-06-15 20:35:23 +03:00
|
|
|
'publish menu save button updated after scheduled post is unscheduled'
|
2021-10-21 15:16:20 +03:00
|
|
|
).to.equal('Publish');
|
2017-06-15 20:35:23 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-cancel]');
|
2017-04-19 16:21:37 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-publishmenu-trigger]').textContent.trim(),
|
2017-04-19 16:21:37 +03:00
|
|
|
'publish button text after unschedule'
|
|
|
|
).to.equal('Publish');
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-editor-post-status]').textContent.trim(),
|
2017-04-19 16:21:37 +03:00
|
|
|
'status text after unschedule'
|
2021-08-31 12:11:40 +03:00
|
|
|
).to.match(/Draft\s+- Saved/);
|
2017-04-19 16:21:37 +03:00
|
|
|
|
|
|
|
expect(
|
2017-08-11 18:28:05 +03:00
|
|
|
find('[data-test-schedule-countdown]'),
|
2017-04-19 16:21:37 +03:00
|
|
|
'scheduled countdown after unschedule'
|
|
|
|
).to.not.exist;
|
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
|
|
|
});
|
Scheduler UI
refs TryGhost/Ghost#6413 and TryGhost/Ghost#6870
needs TryGhost/Ghost#6861
- **Post Settings Menu (PSM)**:'Publish Date' input accepts a date from now, min. 2 minutes to allow scheduler processing on the server. Also, there will always be some delay between typing the date and clicking on the 'Schedule Post' button. If the user types a future date for an already published post, the date will be reseted and he sees the message, that the post needs to be unpublished first. Once, the date is accepted, the label will change to 'Scheduled Date'.
- adds a CP 'timeScheduled' to post model, which will return `true` if the publish time is currently in the future.
- **Changes to the button flow in editor**:
- if the the CP `timeScheduled` returns true, a different drop-down-menu will be shown: 'Schedule Post' replaces 'Publish Now' and 'Unschedule' replaces 'Unpublish'.
- Covering the _edge cases_, especially when a scheduled post is about to be published, while the user is in the editor.
- First, a new CP `scheduleCountdown` will return the remaining time, when the estimated publish time is 15 minutes from now. A notification with this live-ticker is shown next to the save button. Once, we reach a 2 minutes limit, another CP `statusFreeze` will return true and causes the save button to only show `Unschedule` in a red state, until we reach the publish time
- Once the publish time is reached, a CP `scheduledWillPublish` causes the buttons and the existing code to pretend we're already dealing with a publish post. At the moment, there's no way to make a background-fetch of the now serverside-scheduled post model from the server, so Ember doesn't know about the changed state at that time.
- Changes in the editor, which are done during this 'status freeze'-process will be saved back correctly, once the user hits 'Update Post' after the buttons changed back. A click on 'Unpublish' will change the status back to a draft.
- The user will get a regular 'toaster' notification that the post has been published.
- adds CP `isScheduled` for scheduled posts
- adds CP `offset` to component `gh-posts-list-item` and helper `gh-format-time-scheduled` to show schedule date in content overview.
- sets timeout in `gh-spin-button` to 10ms for `Ember.testing`
- changes error message in `gh-editor-base-controller` to be in one line, seperated with a `:`
TODOs:
- [x] new sort order for posts (1. scheduled, 2. draft, 3. published) (refs TryGhost/Ghost#6932)
- [ ] Move posts sorting from posts controller to model and refactor to use `Ember.comparable` mixin
- [x] Flows for draft -> scheduled -> published like described in TryGhost/Ghost#6870 incl. edge cases and button behaviour
- [x] Tests
- [x] new PSM behaviour for time/date in future
- [x] display publishedAt date with timezone offset on posts overview
2016-02-02 10:04:40 +03:00
|
|
|
|
2017-04-19 16:21:37 +03:00
|
|
|
it('handles validation errors when scheduling', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.put('/posts/:id/', function () {
|
2022-03-08 14:32:01 +03:00
|
|
|
return new Response(422, {}, {
|
2017-04-11 16:39:45 +03:00
|
|
|
errors: [{
|
2019-03-25 14:29:14 +03:00
|
|
|
type: 'ValidationError',
|
2017-04-11 16:39:45 +03:00
|
|
|
message: 'Error test'
|
|
|
|
}]
|
|
|
|
});
|
2016-07-19 02:23:43 +03:00
|
|
|
});
|
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
let post = this.server.create('post', 1, {authors: [author], status: 'draft'});
|
2017-04-11 16:39:45 +03:00
|
|
|
let plusTenMin = moment().utc().add(10, 'minutes');
|
2016-07-19 02:23:43 +03:00
|
|
|
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit(`/editor/post/${post.id}`);
|
2016-07-19 02:23:43 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-trigger]');
|
|
|
|
await click('[data-test-publishmenu-scheduled-option]');
|
2019-01-02 12:58:55 +03:00
|
|
|
await datepickerSelect('[data-test-publishmenu-draft] [data-test-date-time-picker-datepicker]', plusTenMin.toDate());
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-publishmenu-draft] [data-test-date-time-picker-time-input]', plusTenMin.format('HH:mm'));
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-publishmenu-draft] [data-test-date-time-picker-time-input]');
|
2018-03-27 20:06:55 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-publishmenu-save]');
|
2016-07-19 02:23:43 +03:00
|
|
|
|
2017-04-19 16:21:37 +03:00
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
findAll('.gh-alert').length,
|
2017-04-19 16:21:37 +03:00
|
|
|
'number of alerts after failed schedule'
|
|
|
|
).to.equal(1);
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('.gh-alert').textContent,
|
2017-04-19 16:21:37 +03:00
|
|
|
'alert text after failed schedule'
|
2019-03-12 20:49:15 +03:00
|
|
|
).to.match(/Error test/);
|
2016-07-19 02:23:43 +03:00
|
|
|
});
|
|
|
|
|
2017-04-19 16:21:37 +03:00
|
|
|
it('handles title validation errors correctly', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.create('post', {authors: [author]});
|
2016-07-22 12:14:32 +03:00
|
|
|
|
|
|
|
// post id 1 is a draft, checking for draft behaviour now
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit('/editor/post/1');
|
2016-07-22 12:14:32 +03:00
|
|
|
|
2017-04-19 16:21:37 +03:00
|
|
|
expect(currentURL(), 'currentURL')
|
2019-02-22 06:17:33 +03:00
|
|
|
.to.equal('/editor/post/1');
|
2016-07-22 12:14:32 +03:00
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-editor-title-input]', Array(260).join('a'));
|
|
|
|
await click('[data-test-publishmenu-trigger]');
|
|
|
|
await click('[data-test-publishmenu-save]');
|
2016-07-22 12:14:32 +03:00
|
|
|
|
2017-04-19 16:21:37 +03:00
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
findAll('.gh-alert').length,
|
2017-04-19 16:21:37 +03:00
|
|
|
'number of alerts after invalid title'
|
|
|
|
).to.equal(1);
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('.gh-alert').textContent,
|
2017-04-19 16:21:37 +03:00
|
|
|
'alert text after invalid title'
|
2017-05-15 14:58:32 +03:00
|
|
|
).to.match(/Title cannot be longer than 255 characters/);
|
2016-07-22 12:14:32 +03:00
|
|
|
});
|
|
|
|
|
2017-05-08 13:35:42 +03:00
|
|
|
// NOTE: these tests are specific to the mobiledoc editor
|
|
|
|
// it('inserts a placeholder if the title is blank', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
// this.server.createList('post', 1);
|
2017-05-08 13:35:42 +03:00
|
|
|
//
|
|
|
|
// // post id 1 is a draft, checking for draft behaviour now
|
2019-02-22 06:17:33 +03:00
|
|
|
// await visit('/editor/post/1');
|
2017-05-08 13:35:42 +03:00
|
|
|
//
|
|
|
|
// expect(currentURL(), 'currentURL')
|
2019-02-22 06:17:33 +03:00
|
|
|
// .to.equal('/editor/post/1');
|
2017-05-08 13:35:42 +03:00
|
|
|
//
|
2017-05-10 02:15:04 +03:00
|
|
|
// await titleRendered();
|
2017-05-08 13:35:42 +03:00
|
|
|
//
|
|
|
|
// let title = find('#koenig-title-input div');
|
|
|
|
// expect(title.data('placeholder')).to.equal('Your Post Title');
|
|
|
|
// expect(title.hasClass('no-content')).to.be.false;
|
|
|
|
//
|
2017-05-10 02:15:04 +03:00
|
|
|
// await replaceTitleHTML('');
|
2017-05-08 13:35:42 +03:00
|
|
|
// expect(title.hasClass('no-content')).to.be.true;
|
|
|
|
//
|
2017-05-10 02:15:04 +03:00
|
|
|
// await replaceTitleHTML('test');
|
2017-05-08 13:35:42 +03:00
|
|
|
// expect(title.hasClass('no-content')).to.be.false;
|
|
|
|
// });
|
|
|
|
//
|
|
|
|
// it('removes HTML from the title.', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
// this.server.createList('post', 1);
|
2017-05-08 13:35:42 +03:00
|
|
|
//
|
|
|
|
// // post id 1 is a draft, checking for draft behaviour now
|
2019-02-22 06:17:33 +03:00
|
|
|
// await visit('/editor/post/1');
|
2017-05-08 13:35:42 +03:00
|
|
|
//
|
|
|
|
// expect(currentURL(), 'currentURL')
|
2019-02-22 06:17:33 +03:00
|
|
|
// .to.equal('/editor/post/1');
|
2017-05-08 13:35:42 +03:00
|
|
|
//
|
2017-05-10 02:15:04 +03:00
|
|
|
// await titleRendered();
|
2017-05-08 13:35:42 +03:00
|
|
|
//
|
|
|
|
// let title = find('#koenig-title-input div');
|
|
|
|
// await replaceTitleHTML('<div>TITLE 	    TEST</div> ');
|
|
|
|
// expect(title.html()).to.equal('TITLE TEST ');
|
|
|
|
// });
|
2017-04-24 14:37:30 +03:00
|
|
|
|
2017-04-19 16:21:37 +03:00
|
|
|
it('renders first countdown notification before scheduled time', async function () {
|
Scheduler UI
refs TryGhost/Ghost#6413 and TryGhost/Ghost#6870
needs TryGhost/Ghost#6861
- **Post Settings Menu (PSM)**:'Publish Date' input accepts a date from now, min. 2 minutes to allow scheduler processing on the server. Also, there will always be some delay between typing the date and clicking on the 'Schedule Post' button. If the user types a future date for an already published post, the date will be reseted and he sees the message, that the post needs to be unpublished first. Once, the date is accepted, the label will change to 'Scheduled Date'.
- adds a CP 'timeScheduled' to post model, which will return `true` if the publish time is currently in the future.
- **Changes to the button flow in editor**:
- if the the CP `timeScheduled` returns true, a different drop-down-menu will be shown: 'Schedule Post' replaces 'Publish Now' and 'Unschedule' replaces 'Unpublish'.
- Covering the _edge cases_, especially when a scheduled post is about to be published, while the user is in the editor.
- First, a new CP `scheduleCountdown` will return the remaining time, when the estimated publish time is 15 minutes from now. A notification with this live-ticker is shown next to the save button. Once, we reach a 2 minutes limit, another CP `statusFreeze` will return true and causes the save button to only show `Unschedule` in a red state, until we reach the publish time
- Once the publish time is reached, a CP `scheduledWillPublish` causes the buttons and the existing code to pretend we're already dealing with a publish post. At the moment, there's no way to make a background-fetch of the now serverside-scheduled post model from the server, so Ember doesn't know about the changed state at that time.
- Changes in the editor, which are done during this 'status freeze'-process will be saved back correctly, once the user hits 'Update Post' after the buttons changed back. A click on 'Unpublish' will change the status back to a draft.
- The user will get a regular 'toaster' notification that the post has been published.
- adds CP `isScheduled` for scheduled posts
- adds CP `offset` to component `gh-posts-list-item` and helper `gh-format-time-scheduled` to show schedule date in content overview.
- sets timeout in `gh-spin-button` to 10ms for `Ember.testing`
- changes error message in `gh-editor-base-controller` to be in one line, seperated with a `:`
TODOs:
- [x] new sort order for posts (1. scheduled, 2. draft, 3. published) (refs TryGhost/Ghost#6932)
- [ ] Move posts sorting from posts controller to model and refactor to use `Ember.comparable` mixin
- [x] Flows for draft -> scheduled -> published like described in TryGhost/Ghost#6870 incl. edge cases and button behaviour
- [x] Tests
- [x] new PSM behaviour for time/date in future
- [x] display publishedAt date with timezone offset on posts overview
2016-02-02 10:04:40 +03:00
|
|
|
let clock = sinon.useFakeTimers(moment().valueOf());
|
2017-04-11 16:39:45 +03:00
|
|
|
let compareDate = moment().tz('Etc/UTC').add(4, 'minutes');
|
2019-06-24 11:06:39 +03:00
|
|
|
let compareDateString = compareDate.format('YYYY-MM-DD');
|
2017-04-11 16:39:45 +03:00
|
|
|
let compareTimeString = compareDate.format('HH:mm');
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.create('post', {publishedAt: moment.utc().add(4, 'minutes'), status: 'scheduled', authors: [author]});
|
2020-06-24 17:34:59 +03:00
|
|
|
this.server.create('setting', {timezone: 'Europe/Dublin'});
|
2016-12-09 20:58:55 +03:00
|
|
|
clock.restore();
|
Scheduler UI
refs TryGhost/Ghost#6413 and TryGhost/Ghost#6870
needs TryGhost/Ghost#6861
- **Post Settings Menu (PSM)**:'Publish Date' input accepts a date from now, min. 2 minutes to allow scheduler processing on the server. Also, there will always be some delay between typing the date and clicking on the 'Schedule Post' button. If the user types a future date for an already published post, the date will be reseted and he sees the message, that the post needs to be unpublished first. Once, the date is accepted, the label will change to 'Scheduled Date'.
- adds a CP 'timeScheduled' to post model, which will return `true` if the publish time is currently in the future.
- **Changes to the button flow in editor**:
- if the the CP `timeScheduled` returns true, a different drop-down-menu will be shown: 'Schedule Post' replaces 'Publish Now' and 'Unschedule' replaces 'Unpublish'.
- Covering the _edge cases_, especially when a scheduled post is about to be published, while the user is in the editor.
- First, a new CP `scheduleCountdown` will return the remaining time, when the estimated publish time is 15 minutes from now. A notification with this live-ticker is shown next to the save button. Once, we reach a 2 minutes limit, another CP `statusFreeze` will return true and causes the save button to only show `Unschedule` in a red state, until we reach the publish time
- Once the publish time is reached, a CP `scheduledWillPublish` causes the buttons and the existing code to pretend we're already dealing with a publish post. At the moment, there's no way to make a background-fetch of the now serverside-scheduled post model from the server, so Ember doesn't know about the changed state at that time.
- Changes in the editor, which are done during this 'status freeze'-process will be saved back correctly, once the user hits 'Update Post' after the buttons changed back. A click on 'Unpublish' will change the status back to a draft.
- The user will get a regular 'toaster' notification that the post has been published.
- adds CP `isScheduled` for scheduled posts
- adds CP `offset` to component `gh-posts-list-item` and helper `gh-format-time-scheduled` to show schedule date in content overview.
- sets timeout in `gh-spin-button` to 10ms for `Ember.testing`
- changes error message in `gh-editor-base-controller` to be in one line, seperated with a `:`
TODOs:
- [x] new sort order for posts (1. scheduled, 2. draft, 3. published) (refs TryGhost/Ghost#6932)
- [ ] Move posts sorting from posts controller to model and refactor to use `Ember.comparable` mixin
- [x] Flows for draft -> scheduled -> published like described in TryGhost/Ghost#6870 incl. edge cases and button behaviour
- [x] Tests
- [x] new PSM behaviour for time/date in future
- [x] display publishedAt date with timezone offset on posts overview
2016-02-02 10:04:40 +03:00
|
|
|
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit('/editor/post/1');
|
2017-04-19 16:21:37 +03:00
|
|
|
|
|
|
|
expect(currentURL(), 'currentURL')
|
2019-02-22 06:17:33 +03:00
|
|
|
.to.equal('/editor/post/1');
|
2021-07-02 21:57:58 +03:00
|
|
|
|
|
|
|
await click('[data-test-psm-trigger]');
|
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-date-time-picker-date-input]').value, 'scheduled date')
|
2017-04-19 16:21:37 +03:00
|
|
|
.to.equal(compareDateString);
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-date-time-picker-time-input]').value, 'scheduled time')
|
2017-04-19 16:21:37 +03:00
|
|
|
.to.equal(compareTimeString);
|
|
|
|
// Dropdown menu should be 'Update Post' and 'Unschedule'
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-publishmenu-trigger]').textContent.trim(), 'text in save button for scheduled post')
|
2017-04-19 16:21:37 +03:00
|
|
|
.to.equal('Scheduled');
|
2019-11-13 19:10:29 +03:00
|
|
|
// expect countdown to show warning, that post is scheduled to be published
|
2019-01-02 12:58:55 +03:00
|
|
|
expect(find('[data-test-schedule-countdown]').textContent.trim(), 'notification countdown')
|
2021-06-11 14:10:28 +03:00
|
|
|
.to.match(/Will be published\s+in (4|5) minutes/);
|
Scheduler UI
refs TryGhost/Ghost#6413 and TryGhost/Ghost#6870
needs TryGhost/Ghost#6861
- **Post Settings Menu (PSM)**:'Publish Date' input accepts a date from now, min. 2 minutes to allow scheduler processing on the server. Also, there will always be some delay between typing the date and clicking on the 'Schedule Post' button. If the user types a future date for an already published post, the date will be reseted and he sees the message, that the post needs to be unpublished first. Once, the date is accepted, the label will change to 'Scheduled Date'.
- adds a CP 'timeScheduled' to post model, which will return `true` if the publish time is currently in the future.
- **Changes to the button flow in editor**:
- if the the CP `timeScheduled` returns true, a different drop-down-menu will be shown: 'Schedule Post' replaces 'Publish Now' and 'Unschedule' replaces 'Unpublish'.
- Covering the _edge cases_, especially when a scheduled post is about to be published, while the user is in the editor.
- First, a new CP `scheduleCountdown` will return the remaining time, when the estimated publish time is 15 minutes from now. A notification with this live-ticker is shown next to the save button. Once, we reach a 2 minutes limit, another CP `statusFreeze` will return true and causes the save button to only show `Unschedule` in a red state, until we reach the publish time
- Once the publish time is reached, a CP `scheduledWillPublish` causes the buttons and the existing code to pretend we're already dealing with a publish post. At the moment, there's no way to make a background-fetch of the now serverside-scheduled post model from the server, so Ember doesn't know about the changed state at that time.
- Changes in the editor, which are done during this 'status freeze'-process will be saved back correctly, once the user hits 'Update Post' after the buttons changed back. A click on 'Unpublish' will change the status back to a draft.
- The user will get a regular 'toaster' notification that the post has been published.
- adds CP `isScheduled` for scheduled posts
- adds CP `offset` to component `gh-posts-list-item` and helper `gh-format-time-scheduled` to show schedule date in content overview.
- sets timeout in `gh-spin-button` to 10ms for `Ember.testing`
- changes error message in `gh-editor-base-controller` to be in one line, seperated with a `:`
TODOs:
- [x] new sort order for posts (1. scheduled, 2. draft, 3. published) (refs TryGhost/Ghost#6932)
- [ ] Move posts sorting from posts controller to model and refactor to use `Ember.comparable` mixin
- [x] Flows for draft -> scheduled -> published like described in TryGhost/Ghost#6870 incl. edge cases and button behaviour
- [x] Tests
- [x] new PSM behaviour for time/date in future
- [x] display publishedAt date with timezone offset on posts overview
2016-02-02 10:04:40 +03:00
|
|
|
});
|
|
|
|
|
2018-03-13 14:17:29 +03:00
|
|
|
it('shows author token input and allows changing of authors in PSM', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
let adminRole = this.server.create('role', {name: 'Adminstrator'});
|
|
|
|
let authorRole = this.server.create('role', {name: 'Author'});
|
|
|
|
let user1 = this.server.create('user', {name: 'Primary', roles: [adminRole]});
|
|
|
|
this.server.create('user', {name: 'Waldo', roles: [authorRole]});
|
|
|
|
this.server.create('post', {authors: [user1]});
|
2017-03-14 06:27:57 +03:00
|
|
|
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit('/editor/post/1');
|
2017-03-14 06:27:57 +03:00
|
|
|
|
2017-04-19 16:21:37 +03:00
|
|
|
expect(currentURL(), 'currentURL')
|
2019-02-22 06:17:33 +03:00
|
|
|
.to.equal('/editor/post/1');
|
2017-03-14 06:27:57 +03:00
|
|
|
|
2021-07-02 21:57:58 +03:00
|
|
|
await click('[data-test-psm-trigger]');
|
2017-03-14 06:27:57 +03:00
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
let tokens = findAll('[data-test-input="authors"] .ember-power-select-multiple-option');
|
2017-03-14 06:27:57 +03:00
|
|
|
|
2018-03-13 14:17:29 +03:00
|
|
|
expect(tokens.length).to.equal(1);
|
|
|
|
expect(tokens[0].textContent.trim()).to.have.string('Primary');
|
2017-03-14 06:27:57 +03:00
|
|
|
|
2018-03-13 14:17:29 +03:00
|
|
|
await selectChoose('[data-test-input="authors"]', 'Waldo');
|
|
|
|
|
2019-01-02 12:58:55 +03:00
|
|
|
let savedAuthors = this.server.schema.posts.find('1').authors.models;
|
2018-03-13 14:17:29 +03:00
|
|
|
|
|
|
|
expect(savedAuthors.length).to.equal(2);
|
|
|
|
expect(savedAuthors[0].name).to.equal('Primary');
|
|
|
|
expect(savedAuthors[1].name).to.equal('Waldo');
|
2017-03-14 06:27:57 +03:00
|
|
|
});
|
2017-07-10 14:33:05 +03:00
|
|
|
|
2017-08-01 11:24:46 +03:00
|
|
|
it('saves post settings fields', async function () {
|
2019-01-02 12:58:55 +03:00
|
|
|
let post = this.server.create('post', {authors: [author]});
|
2017-08-01 11:24:46 +03:00
|
|
|
|
2019-02-22 06:17:33 +03:00
|
|
|
await visit(`/editor/post/${post.id}`);
|
2017-08-01 11:24:46 +03:00
|
|
|
|
|
|
|
// TODO: implement tests for other fields
|
|
|
|
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-psm-trigger]');
|
2017-08-01 11:24:46 +03:00
|
|
|
|
|
|
|
// excerpt has validation
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-field="custom-excerpt"]', Array(302).join('a'));
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-field="custom-excerpt"]');
|
2017-08-01 11:24:46 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-error="custom-excerpt"]').textContent.trim(),
|
2017-08-01 11:24:46 +03:00
|
|
|
'excerpt too long error'
|
|
|
|
).to.match(/cannot be longer than 300/);
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.db.posts.find(post.id).customExcerpt,
|
2017-08-01 11:24:46 +03:00
|
|
|
'saved excerpt after validation error'
|
2018-03-26 13:41:45 +03:00
|
|
|
).to.be.null;
|
2017-08-02 12:32:51 +03:00
|
|
|
|
|
|
|
// changing custom excerpt auto-saves
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-field="custom-excerpt"]', 'Testing excerpt');
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-field="custom-excerpt"]');
|
2017-08-02 12:32:51 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.db.posts.find(post.id).customExcerpt,
|
2017-08-02 12:32:51 +03:00
|
|
|
'saved excerpt'
|
2017-08-01 11:24:46 +03:00
|
|
|
).to.equal('Testing excerpt');
|
2017-08-02 12:32:51 +03:00
|
|
|
|
|
|
|
// -------
|
|
|
|
|
|
|
|
// open code injection subview
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-button="codeinjection"]');
|
2017-08-02 12:32:51 +03:00
|
|
|
|
|
|
|
// header injection has validation
|
2019-01-02 12:58:55 +03:00
|
|
|
let headerCM = find('[data-test-field="codeinjection-head"] .CodeMirror').CodeMirror;
|
2017-08-02 12:32:51 +03:00
|
|
|
await headerCM.setValue(Array(65540).join('a'));
|
2019-01-02 12:58:55 +03:00
|
|
|
await click(headerCM.getInputField());
|
|
|
|
await blur(headerCM.getInputField());
|
2017-08-02 12:32:51 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-error="codeinjection-head"]').textContent.trim(),
|
2017-08-02 12:32:51 +03:00
|
|
|
'header injection too long error'
|
|
|
|
).to.match(/cannot be longer than 65535/);
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.db.posts.find(post.id).codeinjectionHead,
|
2017-08-02 12:32:51 +03:00
|
|
|
'saved header injection after validation error'
|
2018-03-26 13:41:45 +03:00
|
|
|
).to.be.null;
|
2017-08-02 12:32:51 +03:00
|
|
|
|
|
|
|
// changing header injection auto-saves
|
|
|
|
await headerCM.setValue('<script src="http://example.com/inject-head.js"></script>');
|
2019-01-02 12:58:55 +03:00
|
|
|
await click(headerCM.getInputField());
|
|
|
|
await blur(headerCM.getInputField());
|
2017-08-02 12:32:51 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.db.posts.find(post.id).codeinjectionHead,
|
2017-08-02 12:32:51 +03:00
|
|
|
'saved header injection'
|
|
|
|
).to.equal('<script src="http://example.com/inject-head.js"></script>');
|
|
|
|
|
|
|
|
// footer injection has validation
|
2019-01-02 12:58:55 +03:00
|
|
|
let footerCM = find('[data-test-field="codeinjection-foot"] .CodeMirror').CodeMirror;
|
2017-08-02 12:32:51 +03:00
|
|
|
await footerCM.setValue(Array(65540).join('a'));
|
2019-01-02 12:58:55 +03:00
|
|
|
await click(footerCM.getInputField());
|
|
|
|
await blur(footerCM.getInputField());
|
2017-08-02 12:32:51 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-error="codeinjection-foot"]').textContent.trim(),
|
2017-08-02 12:32:51 +03:00
|
|
|
'footer injection too long error'
|
|
|
|
).to.match(/cannot be longer than 65535/);
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.db.posts.find(post.id).codeinjectionFoot,
|
2017-08-02 12:32:51 +03:00
|
|
|
'saved footer injection after validation error'
|
2018-03-26 13:41:45 +03:00
|
|
|
).to.be.null;
|
2017-08-02 12:32:51 +03:00
|
|
|
|
|
|
|
// changing footer injection auto-saves
|
|
|
|
await footerCM.setValue('<script src="http://example.com/inject-foot.js"></script>');
|
2019-01-02 12:58:55 +03:00
|
|
|
await click(footerCM.getInputField());
|
|
|
|
await blur(footerCM.getInputField());
|
2017-08-02 12:32:51 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.db.posts.find(post.id).codeinjectionFoot,
|
2017-08-02 12:32:51 +03:00
|
|
|
'saved footer injection'
|
|
|
|
).to.equal('<script src="http://example.com/inject-foot.js"></script>');
|
|
|
|
|
|
|
|
// closing subview switches back to main PSM view
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-button="close-psm-subview"]');
|
2017-08-02 12:32:51 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
findAll('[data-test-field="codeinjection-head"]').length,
|
2017-08-02 12:32:51 +03:00
|
|
|
'header injection not present after closing subview'
|
|
|
|
).to.equal(0);
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
// -------
|
|
|
|
|
|
|
|
// open twitter data subview
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-button="twitter-data"]');
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
// twitter title has validation
|
2019-01-02 12:58:55 +03:00
|
|
|
await click('[data-test-field="twitter-title"]');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-field="twitter-title"]', Array(302).join('a'));
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-field="twitter-title"]');
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-error="twitter-title"]').textContent.trim(),
|
2017-08-03 14:45:14 +03:00
|
|
|
'twitter title too long error'
|
|
|
|
).to.match(/cannot be longer than 300/);
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.db.posts.find(post.id).twitterTitle,
|
2017-08-03 14:45:14 +03:00
|
|
|
'saved twitter title after validation error'
|
2018-03-26 13:41:45 +03:00
|
|
|
).to.be.null;
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
// changing twitter title auto-saves
|
|
|
|
// twitter title has validation
|
2019-01-02 12:58:55 +03:00
|
|
|
await click('[data-test-field="twitter-title"]');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-field="twitter-title"]', 'Test Twitter Title');
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-field="twitter-title"]');
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.db.posts.find(post.id).twitterTitle,
|
2017-08-03 14:45:14 +03:00
|
|
|
'saved twitter title'
|
|
|
|
).to.equal('Test Twitter Title');
|
|
|
|
|
|
|
|
// twitter description has validation
|
2019-01-02 12:58:55 +03:00
|
|
|
await click('[data-test-field="twitter-description"]');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-field="twitter-description"]', Array(505).join('a'));
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-field="twitter-description"]');
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-error="twitter-description"]').textContent.trim(),
|
2017-08-03 14:45:14 +03:00
|
|
|
'twitter description too long error'
|
|
|
|
).to.match(/cannot be longer than 500/);
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.db.posts.find(post.id).twitterDescription,
|
2017-08-03 14:45:14 +03:00
|
|
|
'saved twitter description after validation error'
|
2018-03-26 13:41:45 +03:00
|
|
|
).to.be.null;
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
// changing twitter description auto-saves
|
|
|
|
// twitter description has validation
|
2019-01-02 12:58:55 +03:00
|
|
|
await click('[data-test-field="twitter-description"]');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-field="twitter-description"]', 'Test Twitter Description');
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-field="twitter-description"]');
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.db.posts.find(post.id).twitterDescription,
|
2017-08-03 14:45:14 +03:00
|
|
|
'saved twitter description'
|
|
|
|
).to.equal('Test Twitter Description');
|
|
|
|
|
|
|
|
// closing subview switches back to main PSM view
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-button="close-psm-subview"]');
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
findAll('[data-test-field="twitter-title"]').length,
|
2017-08-03 14:45:14 +03:00
|
|
|
'twitter title not present after closing subview'
|
|
|
|
).to.equal(0);
|
|
|
|
|
|
|
|
// -------
|
|
|
|
|
|
|
|
// open facebook data subview
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-button="facebook-data"]');
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
// facebook title has validation
|
2019-01-02 12:58:55 +03:00
|
|
|
await click('[data-test-field="og-title"]');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-field="og-title"]', Array(302).join('a'));
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-field="og-title"]');
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-error="og-title"]').textContent.trim(),
|
2017-08-03 14:45:14 +03:00
|
|
|
'facebook title too long error'
|
|
|
|
).to.match(/cannot be longer than 300/);
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.db.posts.find(post.id).ogTitle,
|
2017-08-03 14:45:14 +03:00
|
|
|
'saved facebook title after validation error'
|
2018-03-26 13:41:45 +03:00
|
|
|
).to.be.null;
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
// changing facebook title auto-saves
|
|
|
|
// facebook title has validation
|
2019-01-02 12:58:55 +03:00
|
|
|
await click('[data-test-field="og-title"]');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-field="og-title"]', 'Test Facebook Title');
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-field="og-title"]');
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.db.posts.find(post.id).ogTitle,
|
2017-08-03 14:45:14 +03:00
|
|
|
'saved facebook title'
|
|
|
|
).to.equal('Test Facebook Title');
|
|
|
|
|
|
|
|
// facebook description has validation
|
2019-01-02 12:58:55 +03:00
|
|
|
await click('[data-test-field="og-description"]');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-field="og-description"]', Array(505).join('a'));
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-field="og-description"]');
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
find('[data-test-error="og-description"]').textContent.trim(),
|
2017-08-03 14:45:14 +03:00
|
|
|
'facebook description too long error'
|
|
|
|
).to.match(/cannot be longer than 500/);
|
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.db.posts.find(post.id).ogDescription,
|
2017-08-03 14:45:14 +03:00
|
|
|
'saved facebook description after validation error'
|
2018-03-26 13:41:45 +03:00
|
|
|
).to.be.null;
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
// changing facebook description auto-saves
|
|
|
|
// facebook description has validation
|
2019-01-02 12:58:55 +03:00
|
|
|
await click('[data-test-field="og-description"]');
|
2017-08-11 18:28:05 +03:00
|
|
|
await fillIn('[data-test-field="og-description"]', 'Test Facebook Description');
|
2019-01-02 12:58:55 +03:00
|
|
|
await blur('[data-test-field="og-description"]');
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
this.server.db.posts.find(post.id).ogDescription,
|
2017-08-03 14:45:14 +03:00
|
|
|
'saved facebook description'
|
|
|
|
).to.equal('Test Facebook Description');
|
|
|
|
|
|
|
|
// closing subview switches back to main PSM view
|
2017-08-11 18:28:05 +03:00
|
|
|
await click('[data-test-button="close-psm-subview"]');
|
2017-08-03 14:45:14 +03:00
|
|
|
|
|
|
|
expect(
|
2019-01-02 12:58:55 +03:00
|
|
|
findAll('[data-test-field="og-title"]').length,
|
2017-08-03 14:45:14 +03:00
|
|
|
'facebook title not present after closing subview'
|
|
|
|
).to.equal(0);
|
2017-08-01 11:24:46 +03:00
|
|
|
});
|
2020-09-21 20:14:57 +03:00
|
|
|
|
|
|
|
// https://github.com/TryGhost/Ghost/issues/11786
|
|
|
|
it('save shortcut works when tags/authors field is focused', async function () {
|
|
|
|
let post = this.server.create('post', {authors: [author]});
|
|
|
|
|
|
|
|
await visit(`/editor/post/${post.id}`);
|
|
|
|
await fillIn('[data-test-editor-title-input]', 'CMD-S Test');
|
|
|
|
|
|
|
|
await click('[data-test-psm-trigger]');
|
|
|
|
await click('[data-test-token-input]');
|
|
|
|
|
|
|
|
await triggerEvent('[data-test-token-input]', 'keydown', {
|
|
|
|
keyCode: 83, // s
|
|
|
|
metaKey: ctrlOrCmd === 'command',
|
|
|
|
ctrlKey: ctrlOrCmd === 'ctrl'
|
|
|
|
});
|
|
|
|
|
|
|
|
// Check if save request has been sent correctly.
|
|
|
|
let [lastRequest] = this.server.pretender.handledRequests.slice(-1);
|
|
|
|
let body = JSON.parse(lastRequest.requestBody);
|
|
|
|
expect(body.posts[0].title).to.equal('CMD-S 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
|
|
|
});
|
2022-03-11 13:13:08 +03:00
|
|
|
|
|
|
|
describe('regressions', function () {
|
|
|
|
let user;
|
|
|
|
|
|
|
|
beforeEach(async function () {
|
|
|
|
const role = this.server.create('role', {name: 'Administrator'});
|
|
|
|
user = this.server.create('user', {roles: [role]});
|
2022-04-21 16:48:25 +03:00
|
|
|
this.server.loadFixtures('settings');
|
2022-03-11 13:13:08 +03:00
|
|
|
return await authenticateSession();
|
|
|
|
});
|
|
|
|
|
|
|
|
// BUG: opening the publish menu and selecting a scheduled time then
|
|
|
|
// closing prevents scheduling with a "Must be in the past" error
|
|
|
|
// when re-opening the menu
|
|
|
|
// https://github.com/TryGhost/Team/issues/1399
|
|
|
|
it('can close publish menu after selecting schedule then re-open, schedule, and publish without error', async function () {
|
|
|
|
const post = this.server.create('post', {status: 'draft', authors: [user]});
|
|
|
|
|
|
|
|
await visit(`/editor/post/${post.id}`);
|
|
|
|
await click('[data-test-publishmenu-trigger]');
|
|
|
|
await click('[data-test-publishmenu-scheduled-option]');
|
|
|
|
await click('[data-test-publishmenu-cancel]');
|
|
|
|
await click('[data-test-publishmenu-trigger]');
|
|
|
|
await click('[data-test-publishmenu-scheduled-option]');
|
|
|
|
await click('[data-test-publishmenu-save]');
|
|
|
|
|
2022-03-31 19:10:49 +03:00
|
|
|
expect(post.attrs.status).to.equal('scheduled');
|
|
|
|
});
|
|
|
|
|
|
|
|
// BUG: re-scheduling a send-only post unexpectedly switched to publish+send
|
|
|
|
// https://github.com/TryGhost/Ghost/issues/14354
|
|
|
|
it('can re-schedule an email-only post', async function () {
|
2022-04-21 16:48:25 +03:00
|
|
|
// Enable newsletters (extra confirmation step)
|
|
|
|
enableMailgun(this.server);
|
|
|
|
enableNewsletters(this.server, true);
|
2022-03-31 19:10:49 +03:00
|
|
|
|
2022-04-21 16:48:25 +03:00
|
|
|
// Enable stripe to also show paid members breakdown
|
|
|
|
enableStripe(this.server);
|
2022-03-31 19:10:49 +03:00
|
|
|
|
2022-04-21 16:48:25 +03:00
|
|
|
const newsletter = this.server.create('newsletter', {status: 'active'});
|
|
|
|
this.server.createList('member', 4, {status: 'free', newsletters: [newsletter]});
|
|
|
|
this.server.createList('member', 2, {status: 'paid', newsletters: [newsletter]});
|
2022-03-31 19:10:49 +03:00
|
|
|
|
|
|
|
const post = this.server.create('post', {status: 'draft', authors: [user]});
|
|
|
|
|
|
|
|
const scheduledTime = moment().add(2, 'hours');
|
|
|
|
|
|
|
|
await visit(`/editor/post/${post.id}`);
|
|
|
|
await click('[data-test-publishmenu-trigger]');
|
|
|
|
await selectChoose('[data-test-distribution-action-select]', 'send');
|
|
|
|
await click('[data-test-publishmenu-scheduled-option]');
|
|
|
|
await datepickerSelect('[data-test-publishmenu-draft] [data-test-date-time-picker-datepicker]', new Date(scheduledTime.format().replace(/\+.*$/, '')));
|
2022-04-21 16:48:25 +03:00
|
|
|
|
|
|
|
// Expect 4 free and 2 paid recipients here
|
|
|
|
expect(find('[data-test-email-count="free-members"]')).to.contain.text('4');
|
|
|
|
expect(find('[data-test-email-count="paid-members"]')).to.contain.text('2');
|
|
|
|
|
2022-03-31 19:10:49 +03:00
|
|
|
await click('[data-test-publishmenu-save]');
|
|
|
|
await click('[data-test-button="confirm-schedule"]');
|
|
|
|
|
|
|
|
expect(post.attrs.emailOnly).to.be.true;
|
|
|
|
|
|
|
|
await click('[data-test-publishmenu-trigger]');
|
|
|
|
|
|
|
|
expect(find('[data-test-publishmenu-header]')).to.contain.text('Will be sent');
|
|
|
|
|
|
|
|
await datepickerSelect('[data-test-publishmenu-scheduled] [data-test-date-time-picker-datepicker]', new Date(scheduledTime.add(1, 'day').format().replace(/\+.*$/, '')));
|
|
|
|
await click('[data-test-publishmenu-save]');
|
|
|
|
|
|
|
|
expect(post.attrs.emailOnly).to.be.true;
|
2022-03-11 13:13:08 +03:00
|
|
|
});
|
|
|
|
});
|
2016-10-24 13:55:55 +03:00
|
|
|
});
|