2019-08-09 17:25:12 +03:00
|
|
|
const url = require('url');
|
|
|
|
const _ = require('lodash');
|
2022-02-06 19:18:41 +03:00
|
|
|
const testUtils = require('../../../utils');
|
|
|
|
const schema = require('../../../../core/server/data/schema').tables;
|
2019-08-09 17:25:12 +03:00
|
|
|
const API_URL = '/ghost/api/canary/content/';
|
|
|
|
|
|
|
|
const expectedProperties = {
|
|
|
|
// API top level
|
|
|
|
posts: ['posts', 'meta'],
|
|
|
|
tags: ['tags', 'meta'],
|
|
|
|
authors: ['authors', 'meta'],
|
|
|
|
pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'],
|
|
|
|
|
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',
|
|
|
|
'email_recipient_filter',
|
|
|
|
'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'
|
|
|
|
],
|
2019-08-09 17:25:12 +03:00
|
|
|
author: _(schema.users)
|
|
|
|
.keys()
|
|
|
|
.without(
|
|
|
|
'password',
|
|
|
|
'email',
|
|
|
|
'created_at',
|
|
|
|
'created_by',
|
|
|
|
'updated_at',
|
|
|
|
'updated_by',
|
|
|
|
'last_seen',
|
|
|
|
'status'
|
|
|
|
)
|
|
|
|
// canary API doesn't return unused fields
|
|
|
|
.without('accessibility', 'locale', 'tour', 'visibility')
|
|
|
|
,
|
|
|
|
tag: _(schema.tags)
|
|
|
|
.keys()
|
|
|
|
// canary Tag API doesn't return parent_id or parent
|
|
|
|
.without('parent_id', 'parent')
|
|
|
|
// canary Tag API doesn't return date fields
|
|
|
|
.without('created_at', 'updated_at')
|
|
|
|
};
|
|
|
|
|
|
|
|
_.each(expectedProperties, (value, key) => {
|
|
|
|
if (!value.__wrapped__) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated: x_by
|
|
|
|
*/
|
|
|
|
expectedProperties[key] = value
|
|
|
|
.without(
|
|
|
|
'created_by',
|
|
|
|
'updated_by',
|
|
|
|
'published_by'
|
|
|
|
)
|
|
|
|
.value();
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
API: {
|
|
|
|
getApiQuery(route) {
|
|
|
|
return url.resolve(API_URL, route);
|
|
|
|
},
|
|
|
|
|
|
|
|
checkResponse(...args) {
|
|
|
|
this.expectedProperties = expectedProperties;
|
|
|
|
return testUtils.API.checkResponse.call(this, ...args);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getValidKey() {
|
|
|
|
return testUtils.DataGenerator.Content.api_keys[1].secret;
|
2021-11-24 16:29:45 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
async startGhost(overrides = {}) {
|
|
|
|
const defaults = {
|
|
|
|
backend: true,
|
|
|
|
frontend: false
|
|
|
|
};
|
|
|
|
|
|
|
|
return await testUtils.startGhost(Object.assign(defaults, overrides));
|
2019-08-09 17:25:12 +03:00
|
|
|
}
|
|
|
|
};
|