2018-10-07 17:36:02 +03:00
|
|
|
const url = require('url');
|
2019-09-20 18:02:45 +03:00
|
|
|
const testUtils = require('../../utils');
|
2021-05-13 15:19:33 +03:00
|
|
|
|
2022-03-03 08:20:03 +03:00
|
|
|
const API_URL = '/ghost/api/content/';
|
2018-10-07 17:36:02 +03:00
|
|
|
|
2018-12-17 18:14:36 +03:00
|
|
|
const expectedProperties = {
|
|
|
|
// API top level
|
|
|
|
posts: ['posts', 'meta'],
|
|
|
|
tags: ['tags', 'meta'],
|
|
|
|
authors: ['authors', 'meta'],
|
|
|
|
pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'],
|
2018-12-17 19:45:07 +03:00
|
|
|
|
2021-05-13 14:40:17 +03:00
|
|
|
post: [
|
|
|
|
'id',
|
|
|
|
'uuid',
|
|
|
|
'title',
|
|
|
|
'slug',
|
|
|
|
'html',
|
|
|
|
'comment_id',
|
|
|
|
'feature_image',
|
2021-06-10 22:35:56 +03:00
|
|
|
'feature_image_alt',
|
|
|
|
'feature_image_caption',
|
2021-05-13 14:40:17 +03:00
|
|
|
'featured',
|
|
|
|
'visibility',
|
Renamed newsletter_id and email_recipient_filter options (#14798)
refs https://github.com/TryGhost/Team/issues/1596
- Renamed `newsletter_id` to `newsletter` option, the `newsletter` option expects a slug instead of an id
- Renamed `email_recipient_filter` to `email_segment` option
- Default `email_segment` to `all`. Ignored if no newsletter is set
- `email_segment` is ignored if no newsletter is set
- When reverting a post to a draft, both `newsletter` and `email_segment` are reset to their default values (null, all)
- Removed legacy mapping from old email_recipient_filter values 'paid' and 'free' (already a migration in place)
- Dropped legacy throwing errors when email_recipient_filter is paid or free in transformEmailRecipientFilter
- Reorganized transformEmailRecipientFilter parameters for the now required newsletter parameter
- Fixed an issue where the newsletter filter wasn't working because it wasn't in permittedoptions
- Fixed an issue where you could send to an archived newsletter
- Added an extra protection when scheduling to an active, and later archiving the newsletter
- Dropped support for `send_email_when_published` in API
- When importing posts we currently don't have a system in place to set the newsletter_id to map the `send_email_when_published` behaviour. Since this was already the case, I won't include a fix in this PR.
- Stripped `email_recipient_filter`/`email_segment` from Content API (https://ghost.slack.com/archives/C02G9E68C/p1652363211841359?thread_ts=1650623650.233229&cid=C02G9E68C)
- Updated `admin-api-schema` to 3.2.0, which includes the new email_segment property
- Contains a temporary fix for https://github.com/TryGhost/Team/issues/1626, where the `.related('newsletter').fetch` call fails when the newsletter relation is already loaded, because of the overridden `formatOnWrite` method.
Since the `email_recipient_filter` is no longer used without a newsletter, the `none` value is no longer used. A migration transforms all those values to `all`. This should be safe, because we only send an email now when newsletter_id is not null (scheduled posts should already have a newsletter_id, even if at the time of scheduling they didn't add the newsletter_id option, because at that time, we defaulted to the default newsletter).
Admin changes to make this work: https://github.com/TryGhost/Admin/pull/2380
2022-05-16 11:18:04 +03:00
|
|
|
'email_segment',
|
2021-05-13 14:40:17 +03:00
|
|
|
'created_at',
|
|
|
|
'updated_at',
|
|
|
|
'published_at',
|
|
|
|
'custom_excerpt',
|
|
|
|
'codeinjection_head',
|
|
|
|
'codeinjection_foot',
|
|
|
|
'custom_template',
|
|
|
|
'canonical_url',
|
|
|
|
'url',
|
|
|
|
'excerpt',
|
|
|
|
'access',
|
|
|
|
'og_image',
|
|
|
|
'og_title',
|
|
|
|
'og_description',
|
|
|
|
'twitter_image',
|
|
|
|
'twitter_title',
|
|
|
|
'twitter_description',
|
|
|
|
'meta_title',
|
|
|
|
'meta_description',
|
|
|
|
'email_subject',
|
|
|
|
'frontmatter',
|
|
|
|
'reading_time'
|
|
|
|
],
|
2021-05-13 15:19:33 +03:00
|
|
|
author: [
|
|
|
|
'id',
|
|
|
|
'name',
|
|
|
|
'slug',
|
|
|
|
'profile_image',
|
|
|
|
'cover_image',
|
|
|
|
'bio',
|
|
|
|
'website',
|
|
|
|
'location',
|
|
|
|
'facebook',
|
|
|
|
'twitter',
|
|
|
|
'meta_title',
|
|
|
|
'meta_description'
|
|
|
|
],
|
|
|
|
tag: [
|
|
|
|
'id',
|
|
|
|
'name',
|
|
|
|
'slug',
|
|
|
|
'description',
|
|
|
|
'feature_image',
|
|
|
|
'visibility',
|
|
|
|
'og_image',
|
|
|
|
'og_title',
|
|
|
|
'og_description',
|
|
|
|
'twitter_image',
|
|
|
|
'twitter_title',
|
|
|
|
'twitter_description',
|
|
|
|
'meta_title',
|
|
|
|
'meta_description',
|
|
|
|
'codeinjection_head',
|
|
|
|
'codeinjection_foot',
|
|
|
|
'canonical_url',
|
|
|
|
'accent_color'
|
|
|
|
]
|
2018-12-17 18:14:36 +03:00
|
|
|
};
|
|
|
|
|
2018-10-07 17:36:02 +03:00
|
|
|
module.exports = {
|
|
|
|
API: {
|
|
|
|
getApiQuery(route) {
|
|
|
|
return url.resolve(API_URL, route);
|
2018-12-17 18:14:36 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
checkResponse(...args) {
|
|
|
|
this.expectedProperties = expectedProperties;
|
|
|
|
return testUtils.API.checkResponse.call(this, ...args);
|
2018-10-07 17:36:02 +03:00
|
|
|
}
|
2018-10-15 12:23:34 +03:00
|
|
|
},
|
|
|
|
getValidKey() {
|
2019-01-18 19:37:58 +03:00
|
|
|
return testUtils.DataGenerator.Content.api_keys[1].secret;
|
2021-11-18 11:38:55 +03:00
|
|
|
},
|
|
|
|
async startGhost(overrides = {}) {
|
|
|
|
const defaults = {
|
2021-11-22 09:51:54 +03:00
|
|
|
backend: true,
|
|
|
|
frontend: false
|
2021-11-18 11:38:55 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
return await testUtils.startGhost(Object.assign(defaults, overrides));
|
2018-10-07 17:36:02 +03:00
|
|
|
}
|
|
|
|
};
|