mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Refactored test utils "post" properties
refs 06dd9bac59
refs https://github.com/TryGhost/Team/issues/687
- This is a continuation of the work started in the refed commit. In short: allowlisting response checks wherever possible
This commit is contained in:
parent
c6eafeb89b
commit
d98f76b18c
7 changed files with 244 additions and 174 deletions
|
@ -70,31 +70,41 @@ const expectedProperties = {
|
|||
'frontmatter'
|
||||
],
|
||||
|
||||
page: _(schema.posts)
|
||||
.keys()
|
||||
.filter(key => key.indexOf('@@') === -1)
|
||||
// by default we only return mobildoc
|
||||
.without('html', 'plaintext')
|
||||
.without('locale')
|
||||
.without('page')
|
||||
// v2 API doesn't return new type field
|
||||
.without('type')
|
||||
// deprecated
|
||||
.without('author_id', 'author')
|
||||
// pages are not sent as emails
|
||||
.without('email_recipient_filter')
|
||||
// always returns computed properties
|
||||
.concat('url', 'primary_tag', 'primary_author', 'excerpt')
|
||||
// returned by default
|
||||
.concat('tags', 'authors')
|
||||
// returns meta fields from `posts_meta` schema
|
||||
.concat(
|
||||
..._(schema.posts_meta).keys()
|
||||
.without('post_id', 'id')
|
||||
// pages are not sent as emails
|
||||
.without('email_subject')
|
||||
)
|
||||
,
|
||||
page: [
|
||||
'id',
|
||||
'uuid',
|
||||
'title',
|
||||
'slug',
|
||||
'mobiledoc',
|
||||
'comment_id',
|
||||
'feature_image',
|
||||
'featured',
|
||||
'status',
|
||||
'visibility',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'published_at',
|
||||
'custom_excerpt',
|
||||
'codeinjection_head',
|
||||
'codeinjection_foot',
|
||||
'custom_template',
|
||||
'canonical_url',
|
||||
'url',
|
||||
'primary_tag',
|
||||
'primary_author',
|
||||
'excerpt',
|
||||
'tags',
|
||||
'authors',
|
||||
'og_image',
|
||||
'og_title',
|
||||
'og_description',
|
||||
'twitter_image',
|
||||
'twitter_title',
|
||||
'twitter_description',
|
||||
'meta_title',
|
||||
'meta_description',
|
||||
'frontmatter'
|
||||
],
|
||||
|
||||
user: _(schema.users)
|
||||
.keys()
|
||||
|
|
|
@ -11,33 +11,40 @@ const expectedProperties = {
|
|||
authors: ['authors', 'meta'],
|
||||
pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'],
|
||||
|
||||
post: _(schema.posts)
|
||||
.keys()
|
||||
.filter(key => key.indexOf('@@') === -1)
|
||||
// by default we only return html
|
||||
.without('mobiledoc', 'plaintext')
|
||||
// v2 doesn't return author_id OR author
|
||||
.without('author_id', 'author')
|
||||
// and always returns computed properties: url
|
||||
.concat('url')
|
||||
// v2 API doesn't return unused fields
|
||||
.without('locale')
|
||||
// These fields aren't useful as they always have known values
|
||||
.without('status')
|
||||
// v2 API doesn't return new type field
|
||||
.without('type')
|
||||
// @TODO: https://github.com/TryGhost/Ghost/issues/10335
|
||||
// .without('page')
|
||||
// v2 returns a calculated excerpt field
|
||||
.concat('excerpt')
|
||||
// Access is a calculated property in >= v3
|
||||
.concat('access')
|
||||
// returns meta fields from `posts_meta` schema
|
||||
.concat(
|
||||
..._(schema.posts_meta).keys().without('post_id', 'id')
|
||||
)
|
||||
.concat('reading_time')
|
||||
,
|
||||
post: [
|
||||
'id',
|
||||
'uuid',
|
||||
'title',
|
||||
'slug',
|
||||
'html',
|
||||
'comment_id',
|
||||
'feature_image',
|
||||
'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'
|
||||
],
|
||||
author: _(schema.users)
|
||||
.keys()
|
||||
.without(
|
||||
|
|
|
@ -11,32 +11,40 @@ const expectedProperties = {
|
|||
authors: ['authors', 'meta'],
|
||||
pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'],
|
||||
|
||||
post: _(schema.posts)
|
||||
.keys()
|
||||
.filter(key => key.indexOf('@@') === -1)
|
||||
// by default we only return html
|
||||
.without('mobiledoc', 'plaintext')
|
||||
// canary doesn't return author_id OR author
|
||||
.without('author_id', 'author')
|
||||
// and always returns computed properties: url, primary_tag, primary_author
|
||||
.concat('url')
|
||||
// canary API doesn't return unused fields
|
||||
.without('locale')
|
||||
// These fields aren't useful as they always have known values
|
||||
.without('status')
|
||||
// @TODO: https://github.com/TryGhost/Ghost/issues/10335
|
||||
// .without('page')
|
||||
.without('type')
|
||||
// canary returns a calculated excerpt field
|
||||
.concat('excerpt')
|
||||
// Access is a calculated property in >= v3
|
||||
.concat('access')
|
||||
// returns meta fields from `posts_meta` schema
|
||||
.concat(
|
||||
..._(schema.posts_meta).keys().without('post_id', 'id')
|
||||
)
|
||||
.concat('reading_time')
|
||||
,
|
||||
post: [
|
||||
'id',
|
||||
'uuid',
|
||||
'title',
|
||||
'slug',
|
||||
'html',
|
||||
'comment_id',
|
||||
'feature_image',
|
||||
'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'
|
||||
],
|
||||
author: _(schema.users)
|
||||
.keys()
|
||||
.without(
|
||||
|
|
|
@ -20,28 +20,41 @@ const expectedProperties = {
|
|||
|
||||
site: ['title', 'url', 'version'],
|
||||
|
||||
post: _(schema.posts)
|
||||
.keys()
|
||||
.filter(key => key.indexOf('@@') === -1)
|
||||
// by default we only return mobiledoc
|
||||
.without('html', 'plaintext')
|
||||
.without('visibility')
|
||||
.without('locale')
|
||||
.without('page')
|
||||
.without('author_id', 'author')
|
||||
// emails are not supported in API v2
|
||||
.without('email_recipient_filter')
|
||||
// always returns computed properties
|
||||
.concat('url', 'primary_tag', 'primary_author', 'excerpt')
|
||||
.concat('authors', 'tags')
|
||||
// returns meta fields from `posts_meta` schema
|
||||
.concat(
|
||||
..._(schema.posts_meta).keys()
|
||||
.without('post_id', 'id')
|
||||
// emails are not supported in API v2
|
||||
.without('email_subject')
|
||||
)
|
||||
,
|
||||
post: [
|
||||
'id',
|
||||
'uuid',
|
||||
'title',
|
||||
'slug',
|
||||
'mobiledoc',
|
||||
'comment_id',
|
||||
'feature_image',
|
||||
'featured',
|
||||
'type',
|
||||
'status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'published_at',
|
||||
'custom_excerpt',
|
||||
'codeinjection_head',
|
||||
'codeinjection_foot',
|
||||
'custom_template',
|
||||
'canonical_url',
|
||||
'url',
|
||||
'primary_tag',
|
||||
'primary_author',
|
||||
'excerpt',
|
||||
'authors',
|
||||
'tags',
|
||||
'og_image',
|
||||
'og_title',
|
||||
'og_description',
|
||||
'twitter_image',
|
||||
'twitter_title',
|
||||
'twitter_description',
|
||||
'meta_title',
|
||||
'meta_description',
|
||||
'frontmatter'
|
||||
],
|
||||
user: _(schema.users)
|
||||
.keys()
|
||||
.without('visibility')
|
||||
|
|
|
@ -11,33 +11,38 @@ const expectedProperties = {
|
|||
authors: ['authors', 'meta'],
|
||||
pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'],
|
||||
|
||||
post: _(schema.posts)
|
||||
.keys()
|
||||
.filter(key => key.indexOf('@@') === -1)
|
||||
// by default we only return html
|
||||
.without('mobiledoc', 'plaintext')
|
||||
// v2 doesn't return author_id OR author
|
||||
.without('author_id', 'author')
|
||||
// and always returns computed properties: url, primary_tag, primary_author
|
||||
.concat('url', 'primary_tag', 'primary_author')
|
||||
// v2 API doesn't return unused fields
|
||||
.without('locale', 'visibility')
|
||||
// emails are not supported in API v2
|
||||
.without('email_recipient_filter')
|
||||
// These fields aren't useful as they always have known values
|
||||
.without('status')
|
||||
.concat('page')
|
||||
.without('type')
|
||||
// v2 returns a calculated excerpt field
|
||||
.concat('excerpt')
|
||||
// returns meta fields from `posts_meta` schema
|
||||
.concat(
|
||||
..._(schema.posts_meta).keys()
|
||||
.without('post_id', 'id')
|
||||
// emails are not supported in API v2
|
||||
.without('email_subject')
|
||||
)
|
||||
,
|
||||
post: [
|
||||
'id',
|
||||
'uuid',
|
||||
'title',
|
||||
'slug',
|
||||
'html',
|
||||
'comment_id',
|
||||
'feature_image',
|
||||
'featured',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'published_at',
|
||||
'custom_excerpt',
|
||||
'codeinjection_head',
|
||||
'codeinjection_foot',
|
||||
'custom_template',
|
||||
'canonical_url',
|
||||
'url',
|
||||
'primary_tag',
|
||||
'primary_author',
|
||||
'page',
|
||||
'excerpt',
|
||||
'og_image',
|
||||
'og_title',
|
||||
'og_description',
|
||||
'twitter_image',
|
||||
'twitter_title',
|
||||
'twitter_description',
|
||||
'meta_title',
|
||||
'meta_description',
|
||||
'frontmatter'
|
||||
],
|
||||
author: _(schema.users)
|
||||
.keys()
|
||||
.without(
|
||||
|
|
|
@ -21,26 +21,45 @@ const expectedProperties = {
|
|||
|
||||
site: ['title', 'description', 'logo', 'accent_color', 'url', 'version'],
|
||||
|
||||
post: _(schema.posts)
|
||||
.keys()
|
||||
.filter(key => key.indexOf('@@') === -1)
|
||||
// by default we only return mobiledoc
|
||||
.without('html', 'plaintext')
|
||||
.without('locale')
|
||||
.without('page')
|
||||
.without('author_id', 'author')
|
||||
.without('type')
|
||||
// always returns computed properties
|
||||
// primary_tag and primary_author properties are included
|
||||
// only because authors and tags are always included
|
||||
.concat('url', 'primary_tag', 'primary_author', 'excerpt')
|
||||
.concat('authors', 'tags', 'email')
|
||||
// returns meta fields from `posts_meta` schema
|
||||
.concat(
|
||||
..._(schema.posts_meta).keys().without('post_id', 'id')
|
||||
)
|
||||
.concat('send_email_when_published')
|
||||
,
|
||||
post: [
|
||||
'id',
|
||||
'uuid',
|
||||
'title',
|
||||
'slug',
|
||||
'mobiledoc',
|
||||
'comment_id',
|
||||
'feature_image',
|
||||
'featured',
|
||||
'status',
|
||||
'visibility',
|
||||
'email_recipient_filter',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'published_at',
|
||||
'custom_excerpt',
|
||||
'codeinjection_head',
|
||||
'codeinjection_foot',
|
||||
'custom_template',
|
||||
'canonical_url',
|
||||
'url',
|
||||
'primary_tag',
|
||||
'primary_author',
|
||||
'excerpt',
|
||||
'authors',
|
||||
'tags',
|
||||
'email',
|
||||
'og_image',
|
||||
'og_title',
|
||||
'og_description',
|
||||
'twitter_image',
|
||||
'twitter_title',
|
||||
'twitter_description',
|
||||
'meta_title',
|
||||
'meta_description',
|
||||
'email_subject',
|
||||
'frontmatter',
|
||||
'send_email_when_published'
|
||||
],
|
||||
user: _(schema.users)
|
||||
.keys()
|
||||
.without('visibility')
|
||||
|
|
|
@ -11,33 +11,41 @@ const expectedProperties = {
|
|||
authors: ['authors', 'meta'],
|
||||
pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'],
|
||||
|
||||
post: _(schema.posts)
|
||||
.keys()
|
||||
.filter(key => key.indexOf('@@') === -1)
|
||||
// by default we only return html
|
||||
.without('mobiledoc', 'plaintext')
|
||||
// v3 doesn't return author_id OR author
|
||||
.without('author_id', 'author')
|
||||
// and always returns computed properties: url, primary_tag, primary_author
|
||||
.concat('url')
|
||||
// v3 API doesn't return unused fields
|
||||
.without('locale')
|
||||
// These fields aren't useful as they always have known values
|
||||
.without('status')
|
||||
// @TODO: https://github.com/TryGhost/Ghost/issues/10335
|
||||
// .without('page')
|
||||
.without('type')
|
||||
// v3 returns a calculated excerpt field
|
||||
.concat('excerpt')
|
||||
// Access is a calculated property in >= v3
|
||||
.concat('access')
|
||||
// returns meta fields from `posts_meta` schema
|
||||
.concat(
|
||||
..._(schema.posts_meta).keys().without('post_id', 'id')
|
||||
)
|
||||
.concat('reading_time')
|
||||
.concat('send_email_when_published')
|
||||
,
|
||||
post: [
|
||||
'id',
|
||||
'uuid',
|
||||
'title',
|
||||
'slug',
|
||||
'html',
|
||||
'comment_id',
|
||||
'feature_image',
|
||||
'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',
|
||||
'send_email_when_published'
|
||||
],
|
||||
author: _(schema.users)
|
||||
.keys()
|
||||
.without(
|
||||
|
|
Loading…
Add table
Reference in a new issue