0
Fork 0
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:
Naz 2021-05-13 15:40:17 +04:00
parent c6eafeb89b
commit d98f76b18c
7 changed files with 244 additions and 174 deletions

View file

@ -70,31 +70,41 @@ const expectedProperties = {
'frontmatter' 'frontmatter'
], ],
page: _(schema.posts) page: [
.keys() 'id',
.filter(key => key.indexOf('@@') === -1) 'uuid',
// by default we only return mobildoc 'title',
.without('html', 'plaintext') 'slug',
.without('locale') 'mobiledoc',
.without('page') 'comment_id',
// v2 API doesn't return new type field 'feature_image',
.without('type') 'featured',
// deprecated 'status',
.without('author_id', 'author') 'visibility',
// pages are not sent as emails 'created_at',
.without('email_recipient_filter') 'updated_at',
// always returns computed properties 'published_at',
.concat('url', 'primary_tag', 'primary_author', 'excerpt') 'custom_excerpt',
// returned by default 'codeinjection_head',
.concat('tags', 'authors') 'codeinjection_foot',
// returns meta fields from `posts_meta` schema 'custom_template',
.concat( 'canonical_url',
..._(schema.posts_meta).keys() 'url',
.without('post_id', 'id') 'primary_tag',
// pages are not sent as emails 'primary_author',
.without('email_subject') 'excerpt',
) 'tags',
, 'authors',
'og_image',
'og_title',
'og_description',
'twitter_image',
'twitter_title',
'twitter_description',
'meta_title',
'meta_description',
'frontmatter'
],
user: _(schema.users) user: _(schema.users)
.keys() .keys()

View file

@ -11,33 +11,40 @@ const expectedProperties = {
authors: ['authors', 'meta'], authors: ['authors', 'meta'],
pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'], pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'],
post: _(schema.posts) post: [
.keys() 'id',
.filter(key => key.indexOf('@@') === -1) 'uuid',
// by default we only return html 'title',
.without('mobiledoc', 'plaintext') 'slug',
// v2 doesn't return author_id OR author 'html',
.without('author_id', 'author') 'comment_id',
// and always returns computed properties: url 'feature_image',
.concat('url') 'featured',
// v2 API doesn't return unused fields 'visibility',
.without('locale') 'email_recipient_filter',
// These fields aren't useful as they always have known values 'created_at',
.without('status') 'updated_at',
// v2 API doesn't return new type field 'published_at',
.without('type') 'custom_excerpt',
// @TODO: https://github.com/TryGhost/Ghost/issues/10335 'codeinjection_head',
// .without('page') 'codeinjection_foot',
// v2 returns a calculated excerpt field 'custom_template',
.concat('excerpt') 'canonical_url',
// Access is a calculated property in >= v3 'url',
.concat('access') 'excerpt',
// returns meta fields from `posts_meta` schema 'access',
.concat( 'og_image',
..._(schema.posts_meta).keys().without('post_id', 'id') 'og_title',
) 'og_description',
.concat('reading_time') 'twitter_image',
, 'twitter_title',
'twitter_description',
'meta_title',
'meta_description',
'email_subject',
'frontmatter',
'reading_time'
],
author: _(schema.users) author: _(schema.users)
.keys() .keys()
.without( .without(

View file

@ -11,32 +11,40 @@ const expectedProperties = {
authors: ['authors', 'meta'], authors: ['authors', 'meta'],
pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'], pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'],
post: _(schema.posts) post: [
.keys() 'id',
.filter(key => key.indexOf('@@') === -1) 'uuid',
// by default we only return html 'title',
.without('mobiledoc', 'plaintext') 'slug',
// canary doesn't return author_id OR author 'html',
.without('author_id', 'author') 'comment_id',
// and always returns computed properties: url, primary_tag, primary_author 'feature_image',
.concat('url') 'featured',
// canary API doesn't return unused fields 'visibility',
.without('locale') 'email_recipient_filter',
// These fields aren't useful as they always have known values 'created_at',
.without('status') 'updated_at',
// @TODO: https://github.com/TryGhost/Ghost/issues/10335 'published_at',
// .without('page') 'custom_excerpt',
.without('type') 'codeinjection_head',
// canary returns a calculated excerpt field 'codeinjection_foot',
.concat('excerpt') 'custom_template',
// Access is a calculated property in >= v3 'canonical_url',
.concat('access') 'url',
// returns meta fields from `posts_meta` schema 'excerpt',
.concat( 'access',
..._(schema.posts_meta).keys().without('post_id', 'id') 'og_image',
) 'og_title',
.concat('reading_time') 'og_description',
, 'twitter_image',
'twitter_title',
'twitter_description',
'meta_title',
'meta_description',
'email_subject',
'frontmatter',
'reading_time'
],
author: _(schema.users) author: _(schema.users)
.keys() .keys()
.without( .without(

View file

@ -20,28 +20,41 @@ const expectedProperties = {
site: ['title', 'url', 'version'], site: ['title', 'url', 'version'],
post: _(schema.posts) post: [
.keys() 'id',
.filter(key => key.indexOf('@@') === -1) 'uuid',
// by default we only return mobiledoc 'title',
.without('html', 'plaintext') 'slug',
.without('visibility') 'mobiledoc',
.without('locale') 'comment_id',
.without('page') 'feature_image',
.without('author_id', 'author') 'featured',
// emails are not supported in API v2 'type',
.without('email_recipient_filter') 'status',
// always returns computed properties 'created_at',
.concat('url', 'primary_tag', 'primary_author', 'excerpt') 'updated_at',
.concat('authors', 'tags') 'published_at',
// returns meta fields from `posts_meta` schema 'custom_excerpt',
.concat( 'codeinjection_head',
..._(schema.posts_meta).keys() 'codeinjection_foot',
.without('post_id', 'id') 'custom_template',
// emails are not supported in API v2 'canonical_url',
.without('email_subject') '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) user: _(schema.users)
.keys() .keys()
.without('visibility') .without('visibility')

View file

@ -11,33 +11,38 @@ const expectedProperties = {
authors: ['authors', 'meta'], authors: ['authors', 'meta'],
pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'], pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'],
post: _(schema.posts) post: [
.keys() 'id',
.filter(key => key.indexOf('@@') === -1) 'uuid',
// by default we only return html 'title',
.without('mobiledoc', 'plaintext') 'slug',
// v2 doesn't return author_id OR author 'html',
.without('author_id', 'author') 'comment_id',
// and always returns computed properties: url, primary_tag, primary_author 'feature_image',
.concat('url', 'primary_tag', 'primary_author') 'featured',
// v2 API doesn't return unused fields 'created_at',
.without('locale', 'visibility') 'updated_at',
// emails are not supported in API v2 'published_at',
.without('email_recipient_filter') 'custom_excerpt',
// These fields aren't useful as they always have known values 'codeinjection_head',
.without('status') 'codeinjection_foot',
.concat('page') 'custom_template',
.without('type') 'canonical_url',
// v2 returns a calculated excerpt field 'url',
.concat('excerpt') 'primary_tag',
// returns meta fields from `posts_meta` schema 'primary_author',
.concat( 'page',
..._(schema.posts_meta).keys() 'excerpt',
.without('post_id', 'id') 'og_image',
// emails are not supported in API v2 'og_title',
.without('email_subject') 'og_description',
) 'twitter_image',
, 'twitter_title',
'twitter_description',
'meta_title',
'meta_description',
'frontmatter'
],
author: _(schema.users) author: _(schema.users)
.keys() .keys()
.without( .without(

View file

@ -21,26 +21,45 @@ const expectedProperties = {
site: ['title', 'description', 'logo', 'accent_color', 'url', 'version'], site: ['title', 'description', 'logo', 'accent_color', 'url', 'version'],
post: _(schema.posts) post: [
.keys() 'id',
.filter(key => key.indexOf('@@') === -1) 'uuid',
// by default we only return mobiledoc 'title',
.without('html', 'plaintext') 'slug',
.without('locale') 'mobiledoc',
.without('page') 'comment_id',
.without('author_id', 'author') 'feature_image',
.without('type') 'featured',
// always returns computed properties 'status',
// primary_tag and primary_author properties are included 'visibility',
// only because authors and tags are always included 'email_recipient_filter',
.concat('url', 'primary_tag', 'primary_author', 'excerpt') 'created_at',
.concat('authors', 'tags', 'email') 'updated_at',
// returns meta fields from `posts_meta` schema 'published_at',
.concat( 'custom_excerpt',
..._(schema.posts_meta).keys().without('post_id', 'id') 'codeinjection_head',
) 'codeinjection_foot',
.concat('send_email_when_published') '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) user: _(schema.users)
.keys() .keys()
.without('visibility') .without('visibility')

View file

@ -11,33 +11,41 @@ const expectedProperties = {
authors: ['authors', 'meta'], authors: ['authors', 'meta'],
pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'], pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'],
post: _(schema.posts) post: [
.keys() 'id',
.filter(key => key.indexOf('@@') === -1) 'uuid',
// by default we only return html 'title',
.without('mobiledoc', 'plaintext') 'slug',
// v3 doesn't return author_id OR author 'html',
.without('author_id', 'author') 'comment_id',
// and always returns computed properties: url, primary_tag, primary_author 'feature_image',
.concat('url') 'featured',
// v3 API doesn't return unused fields 'visibility',
.without('locale') 'email_recipient_filter',
// These fields aren't useful as they always have known values 'created_at',
.without('status') 'updated_at',
// @TODO: https://github.com/TryGhost/Ghost/issues/10335 'published_at',
// .without('page') 'custom_excerpt',
.without('type') 'codeinjection_head',
// v3 returns a calculated excerpt field 'codeinjection_foot',
.concat('excerpt') 'custom_template',
// Access is a calculated property in >= v3 'canonical_url',
.concat('access') 'url',
// returns meta fields from `posts_meta` schema 'excerpt',
.concat( 'access',
..._(schema.posts_meta).keys().without('post_id', 'id') 'og_image',
) 'og_title',
.concat('reading_time') 'og_description',
.concat('send_email_when_published') 'twitter_image',
, 'twitter_title',
'twitter_description',
'meta_title',
'meta_description',
'email_subject',
'frontmatter',
'reading_time',
'send_email_when_published'
],
author: _(schema.users) author: _(schema.users)
.keys() .keys()
.without( .without(