From 94713840209f5f969a4c5d3bb653bfff31efcacf Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Tue, 13 Sep 2022 13:30:17 +0100 Subject: [PATCH] Added tests for Admin API not returning lexical by default but including when requested no issue - left `mobiledoc` as the only default format added in the post/page input serializers for now to minimize API/test churn during these early stages of lexical development - tested that the `lexical` field is not returned by default but can be requested via `?formats=lexical` --- .../admin/__snapshots__/posts.test.js.snap | 772 ++++++++++++++++++ ghost/core/test/e2e-api/admin/pages.test.js | 18 + ghost/core/test/e2e-api/admin/posts.test.js | 28 +- 3 files changed, 817 insertions(+), 1 deletion(-) diff --git a/ghost/core/test/e2e-api/admin/__snapshots__/posts.test.js.snap b/ghost/core/test/e2e-api/admin/__snapshots__/posts.test.js.snap index cf0b7c9c06..7a2c187575 100644 --- a/ghost/core/test/e2e-api/admin/__snapshots__/posts.test.js.snap +++ b/ghost/core/test/e2e-api/admin/__snapshots__/posts.test.js.snap @@ -1,5 +1,777 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Posts API Can browse 1: [body] 1`] = ` +Object { + "meta": Object { + "pagination": Object { + "limit": 2, + "next": 2, + "page": 1, + "pages": 7, + "prev": null, + "total": 13, + }, + }, + "posts": Array [ + Object { + "authors": Array [ + Object { + "accessibility": null, + "bio": "bio", + "comment_notifications": true, + "cover_image": null, + "created_at": "2022-09-13T12:17:08.000Z", + "email": "jbloggs@example.com", + "facebook": null, + "free_member_signup_notification": true, + "id": "1", + "last_seen": "2022-09-13T12:17:09.000Z", + "location": "location", + "meta_description": null, + "meta_title": null, + "name": "Joe Bloggs", + "paid_subscription_canceled_notification": false, + "paid_subscription_started_notification": true, + "profile_image": "https://example.com/super_photo.jpg", + "roles": Array [ + Object { + "created_at": "2022-09-13T12:17:07.000Z", + "description": "Blog Owner", + "id": "632074c3082a107f3a4b0324", + "name": "Owner", + "updated_at": "2022-09-13T12:17:07.000Z", + }, + ], + "slug": "joe-bloggs", + "status": "active", + "tour": null, + "twitter": null, + "updated_at": "2022-09-13T12:17:09.000Z", + "url": "http://127.0.0.1:2369/author/joe-bloggs/", + "website": null, + }, + ], + "canonical_url": null, + "codeinjection_foot": null, + "codeinjection_head": null, + "comment_id": "618ba1ffbe2896088840a6ed", + "count": Object { + "conversions": 0, + "signups": 0, + }, + "created_at": "2022-09-13T12:17:07.000Z", + "custom_excerpt": null, + "custom_template": null, + "email": null, + "email_only": false, + "email_segment": "all", + "email_subject": null, + "excerpt": "Welcome to my invisible post!", + "feature_image": null, + "feature_image_alt": null, + "feature_image_caption": null, + "featured": false, + "frontmatter": null, + "id": StringMatching /\\[a-f0-9\\]\\{24\\}/, + "meta_description": null, + "meta_title": null, + "mobiledoc": "{\\"version\\":\\"0.3.1\\",\\"markups\\":[],\\"atoms\\":[],\\"cards\\":[[\\"markdown\\",{\\"markdown\\":\\"

Welcome to my invisible post!

\\"}]],\\"sections\\":[[10,0]]}", + "newsletter": null, + "og_description": null, + "og_image": null, + "og_title": null, + "primary_author": Object { + "accessibility": null, + "bio": "bio", + "comment_notifications": true, + "cover_image": null, + "created_at": "2022-09-13T12:17:08.000Z", + "email": "jbloggs@example.com", + "facebook": null, + "free_member_signup_notification": true, + "id": "1", + "last_seen": "2022-09-13T12:17:09.000Z", + "location": "location", + "meta_description": null, + "meta_title": null, + "name": "Joe Bloggs", + "paid_subscription_canceled_notification": false, + "paid_subscription_started_notification": true, + "profile_image": "https://example.com/super_photo.jpg", + "roles": Array [ + Object { + "created_at": "2022-09-13T12:17:07.000Z", + "description": "Blog Owner", + "id": "632074c3082a107f3a4b0324", + "name": "Owner", + "updated_at": "2022-09-13T12:17:07.000Z", + }, + ], + "slug": "joe-bloggs", + "status": "active", + "tour": null, + "twitter": null, + "updated_at": "2022-09-13T12:17:09.000Z", + "url": "http://127.0.0.1:2369/author/joe-bloggs/", + "website": null, + }, + "primary_tag": null, + "published_at": "2022-09-15T12:17:07.000Z", + "slug": "scheduled-post", + "status": "scheduled", + "tags": Array [], + "tiers": Array [ + Object { + "active": true, + "created_at": "2022-09-13T12:17:07.000Z", + "description": null, + "id": "632074c3082a107f3a4b032b", + "monthly_price_id": null, + "name": "Default Product", + "slug": "default-product", + "trial_days": 0, + "type": "paid", + "updated_at": "2022-09-13T12:17:07.000Z", + "visibility": "public", + "welcome_page_url": null, + "yearly_price_id": null, + }, + Object { + "active": true, + "created_at": "2022-09-13T12:17:07.000Z", + "description": null, + "id": "632074c3082a107f3a4b032c", + "monthly_price_id": null, + "name": "Free", + "slug": "free", + "trial_days": 0, + "type": "free", + "updated_at": "2022-09-13T12:17:07.000Z", + "visibility": "public", + "welcome_page_url": null, + "yearly_price_id": null, + }, + ], + "title": "This is a scheduled post!!", + "twitter_description": null, + "twitter_image": null, + "twitter_title": null, + "updated_at": "2022-09-13T12:17:07.000Z", + "url": "http://127.0.0.1:2369/p/fc6b0029-2565-4350-8265-78019c81301e/", + "uuid": "fc6b0029-2565-4350-8265-78019c81301e", + "visibility": "public", + }, + Object { + "authors": Array [ + Object { + "accessibility": null, + "bio": "bio", + "comment_notifications": true, + "cover_image": null, + "created_at": "2022-09-13T12:17:08.000Z", + "email": "jbloggs@example.com", + "facebook": null, + "free_member_signup_notification": true, + "id": "1", + "last_seen": "2022-09-13T12:17:09.000Z", + "location": "location", + "meta_description": null, + "meta_title": null, + "name": "Joe Bloggs", + "paid_subscription_canceled_notification": false, + "paid_subscription_started_notification": true, + "profile_image": "https://example.com/super_photo.jpg", + "roles": Array [ + Object { + "created_at": "2022-09-13T12:17:07.000Z", + "description": "Blog Owner", + "id": "632074c3082a107f3a4b0324", + "name": "Owner", + "updated_at": "2022-09-13T12:17:07.000Z", + }, + ], + "slug": "joe-bloggs", + "status": "active", + "tour": null, + "twitter": null, + "updated_at": "2022-09-13T12:17:09.000Z", + "url": "http://127.0.0.1:2369/author/joe-bloggs/", + "website": null, + }, + ], + "canonical_url": null, + "codeinjection_foot": null, + "codeinjection_head": null, + "comment_id": "618ba1ffbe2896088840a6e5", + "count": Object { + "conversions": 0, + "signups": 0, + }, + "created_at": "2022-09-13T12:17:07.000Z", + "custom_excerpt": null, + "custom_template": null, + "email": null, + "email_only": false, + "email_segment": "all", + "email_subject": null, + "excerpt": "HTML Ipsum Presents + +Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum o", + "feature_image": null, + "feature_image_alt": null, + "feature_image_caption": null, + "featured": false, + "frontmatter": null, + "id": StringMatching /\\[a-f0-9\\]\\{24\\}/, + "meta_description": "meta description for draft post", + "meta_title": null, + "mobiledoc": "{\\"version\\":\\"0.3.1\\",\\"markups\\":[],\\"atoms\\":[],\\"cards\\":[[\\"markdown\\",{\\"markdown\\":\\"

HTML Ipsum Presents

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.

Header Level 2

  1. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  2. Aliquam tincidunt mauris eu risus.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.

Header Level 3

#header h1 a{display: block;width: 300px;height: 80px;}
\\"}]],\\"sections\\":[[10,0]]}", + "newsletter": null, + "og_description": null, + "og_image": null, + "og_title": null, + "primary_author": Object { + "accessibility": null, + "bio": "bio", + "comment_notifications": true, + "cover_image": null, + "created_at": "2022-09-13T12:17:08.000Z", + "email": "jbloggs@example.com", + "facebook": null, + "free_member_signup_notification": true, + "id": "1", + "last_seen": "2022-09-13T12:17:09.000Z", + "location": "location", + "meta_description": null, + "meta_title": null, + "name": "Joe Bloggs", + "paid_subscription_canceled_notification": false, + "paid_subscription_started_notification": true, + "profile_image": "https://example.com/super_photo.jpg", + "roles": Array [ + Object { + "created_at": "2022-09-13T12:17:07.000Z", + "description": "Blog Owner", + "id": "632074c3082a107f3a4b0324", + "name": "Owner", + "updated_at": "2022-09-13T12:17:07.000Z", + }, + ], + "slug": "joe-bloggs", + "status": "active", + "tour": null, + "twitter": null, + "updated_at": "2022-09-13T12:17:09.000Z", + "url": "http://127.0.0.1:2369/author/joe-bloggs/", + "website": null, + }, + "primary_tag": Object { + "accent_color": null, + "canonical_url": null, + "codeinjection_foot": null, + "codeinjection_head": null, + "created_at": "2022-09-13T12:17:07.000Z", + "description": "description", + "feature_image": null, + "id": "6193c6d5e792de832cd08148", + "meta_description": null, + "meta_title": null, + "name": "pollo", + "og_description": null, + "og_image": null, + "og_title": null, + "slug": "pollo", + "twitter_description": null, + "twitter_image": null, + "twitter_title": null, + "updated_at": "2022-09-13T12:17:07.000Z", + "url": "http://127.0.0.1:2369/404/", + "visibility": "public", + }, + "published_at": "2022-09-13T12:17:07.000Z", + "slug": "unfinished", + "status": "draft", + "tags": Array [ + Object { + "accent_color": null, + "canonical_url": null, + "codeinjection_foot": null, + "codeinjection_head": null, + "created_at": "2022-09-13T12:17:07.000Z", + "description": "description", + "feature_image": null, + "id": "6193c6d5e792de832cd08148", + "meta_description": null, + "meta_title": null, + "name": "pollo", + "og_description": null, + "og_image": null, + "og_title": null, + "slug": "pollo", + "twitter_description": null, + "twitter_image": null, + "twitter_title": null, + "updated_at": "2022-09-13T12:17:07.000Z", + "url": "http://127.0.0.1:2369/404/", + "visibility": "public", + }, + ], + "tiers": Array [ + Object { + "active": true, + "created_at": "2022-09-13T12:17:07.000Z", + "description": null, + "id": "632074c3082a107f3a4b032b", + "monthly_price_id": null, + "name": "Default Product", + "slug": "default-product", + "trial_days": 0, + "type": "paid", + "updated_at": "2022-09-13T12:17:07.000Z", + "visibility": "public", + "welcome_page_url": null, + "yearly_price_id": null, + }, + Object { + "active": true, + "created_at": "2022-09-13T12:17:07.000Z", + "description": null, + "id": "632074c3082a107f3a4b032c", + "monthly_price_id": null, + "name": "Free", + "slug": "free", + "trial_days": 0, + "type": "free", + "updated_at": "2022-09-13T12:17:07.000Z", + "visibility": "public", + "welcome_page_url": null, + "yearly_price_id": null, + }, + ], + "title": "Not finished yet", + "twitter_description": null, + "twitter_image": null, + "twitter_title": null, + "updated_at": "2022-09-13T12:17:07.000Z", + "url": "http://127.0.0.1:2369/p/d52c42ae-2755-455c-80ec-70b2ec55c903/", + "uuid": "d52c42ae-2755-455c-80ec-70b2ec55c903", + "visibility": "public", + }, + ], +} +`; + +exports[`Posts API Can browse 2: [headers] 1`] = ` +Object { + "access-control-allow-origin": "http://127.0.0.1:2369", + "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", + "content-length": "9894", + "content-type": "application/json; charset=utf-8", + "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, + "vary": "Origin, Accept-Encoding", + "x-powered-by": "Express", +} +`; + +exports[`Posts API Can browse with formats 1: [body] 1`] = ` +Object { + "meta": Object { + "pagination": Object { + "limit": 2, + "next": 2, + "page": 1, + "pages": 7, + "prev": null, + "total": 13, + }, + }, + "posts": Array [ + Object { + "authors": Array [ + Object { + "accessibility": null, + "bio": "bio", + "comment_notifications": true, + "cover_image": null, + "created_at": "2022-09-13T12:17:08.000Z", + "email": "jbloggs@example.com", + "facebook": null, + "free_member_signup_notification": true, + "id": "1", + "last_seen": "2022-09-13T12:17:09.000Z", + "location": "location", + "meta_description": null, + "meta_title": null, + "name": "Joe Bloggs", + "paid_subscription_canceled_notification": false, + "paid_subscription_started_notification": true, + "profile_image": "https://example.com/super_photo.jpg", + "roles": Array [ + Object { + "created_at": "2022-09-13T12:17:07.000Z", + "description": "Blog Owner", + "id": "632074c3082a107f3a4b0324", + "name": "Owner", + "updated_at": "2022-09-13T12:17:07.000Z", + }, + ], + "slug": "joe-bloggs", + "status": "active", + "tour": null, + "twitter": null, + "updated_at": "2022-09-13T12:17:09.000Z", + "url": "http://127.0.0.1:2369/author/joe-bloggs/", + "website": null, + }, + ], + "canonical_url": null, + "codeinjection_foot": null, + "codeinjection_head": null, + "comment_id": "618ba1ffbe2896088840a6ed", + "count": Object { + "conversions": 0, + "signups": 0, + }, + "created_at": "2022-09-13T12:17:07.000Z", + "custom_excerpt": null, + "custom_template": null, + "email": null, + "email_only": false, + "email_segment": "all", + "email_subject": null, + "excerpt": "Welcome to my invisible post!", + "feature_image": null, + "feature_image_alt": null, + "feature_image_caption": null, + "featured": false, + "frontmatter": null, + "html": "

Welcome to my invisible post!

", + "id": StringMatching /\\[a-f0-9\\]\\{24\\}/, + "lexical": null, + "meta_description": null, + "meta_title": null, + "mobiledoc": "{\\"version\\":\\"0.3.1\\",\\"markups\\":[],\\"atoms\\":[],\\"cards\\":[[\\"markdown\\",{\\"markdown\\":\\"

Welcome to my invisible post!

\\"}]],\\"sections\\":[[10,0]]}", + "newsletter": null, + "og_description": null, + "og_image": null, + "og_title": null, + "plaintext": "Welcome to my invisible post!", + "primary_author": Object { + "accessibility": null, + "bio": "bio", + "comment_notifications": true, + "cover_image": null, + "created_at": "2022-09-13T12:17:08.000Z", + "email": "jbloggs@example.com", + "facebook": null, + "free_member_signup_notification": true, + "id": "1", + "last_seen": "2022-09-13T12:17:09.000Z", + "location": "location", + "meta_description": null, + "meta_title": null, + "name": "Joe Bloggs", + "paid_subscription_canceled_notification": false, + "paid_subscription_started_notification": true, + "profile_image": "https://example.com/super_photo.jpg", + "roles": Array [ + Object { + "created_at": "2022-09-13T12:17:07.000Z", + "description": "Blog Owner", + "id": "632074c3082a107f3a4b0324", + "name": "Owner", + "updated_at": "2022-09-13T12:17:07.000Z", + }, + ], + "slug": "joe-bloggs", + "status": "active", + "tour": null, + "twitter": null, + "updated_at": "2022-09-13T12:17:09.000Z", + "url": "http://127.0.0.1:2369/author/joe-bloggs/", + "website": null, + }, + "primary_tag": null, + "published_at": "2022-09-15T12:17:07.000Z", + "reading_time": 0, + "slug": "scheduled-post", + "status": "scheduled", + "tags": Array [], + "tiers": Array [ + Object { + "active": true, + "created_at": "2022-09-13T12:17:07.000Z", + "description": null, + "id": "632074c3082a107f3a4b032b", + "monthly_price_id": null, + "name": "Default Product", + "slug": "default-product", + "trial_days": 0, + "type": "paid", + "updated_at": "2022-09-13T12:17:07.000Z", + "visibility": "public", + "welcome_page_url": null, + "yearly_price_id": null, + }, + Object { + "active": true, + "created_at": "2022-09-13T12:17:07.000Z", + "description": null, + "id": "632074c3082a107f3a4b032c", + "monthly_price_id": null, + "name": "Free", + "slug": "free", + "trial_days": 0, + "type": "free", + "updated_at": "2022-09-13T12:17:07.000Z", + "visibility": "public", + "welcome_page_url": null, + "yearly_price_id": null, + }, + ], + "title": "This is a scheduled post!!", + "twitter_description": null, + "twitter_image": null, + "twitter_title": null, + "updated_at": "2022-09-13T12:17:07.000Z", + "url": "http://127.0.0.1:2369/p/fc6b0029-2565-4350-8265-78019c81301e/", + "uuid": "fc6b0029-2565-4350-8265-78019c81301e", + "visibility": "public", + }, + Object { + "authors": Array [ + Object { + "accessibility": null, + "bio": "bio", + "comment_notifications": true, + "cover_image": null, + "created_at": "2022-09-13T12:17:08.000Z", + "email": "jbloggs@example.com", + "facebook": null, + "free_member_signup_notification": true, + "id": "1", + "last_seen": "2022-09-13T12:17:09.000Z", + "location": "location", + "meta_description": null, + "meta_title": null, + "name": "Joe Bloggs", + "paid_subscription_canceled_notification": false, + "paid_subscription_started_notification": true, + "profile_image": "https://example.com/super_photo.jpg", + "roles": Array [ + Object { + "created_at": "2022-09-13T12:17:07.000Z", + "description": "Blog Owner", + "id": "632074c3082a107f3a4b0324", + "name": "Owner", + "updated_at": "2022-09-13T12:17:07.000Z", + }, + ], + "slug": "joe-bloggs", + "status": "active", + "tour": null, + "twitter": null, + "updated_at": "2022-09-13T12:17:09.000Z", + "url": "http://127.0.0.1:2369/author/joe-bloggs/", + "website": null, + }, + ], + "canonical_url": null, + "codeinjection_foot": null, + "codeinjection_head": null, + "comment_id": "618ba1ffbe2896088840a6e5", + "count": Object { + "conversions": 0, + "signups": 0, + }, + "created_at": "2022-09-13T12:17:07.000Z", + "custom_excerpt": null, + "custom_template": null, + "email": null, + "email_only": false, + "email_segment": "all", + "email_subject": null, + "excerpt": "HTML Ipsum Presents + +Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum o", + "feature_image": null, + "feature_image_alt": null, + "feature_image_caption": null, + "featured": false, + "frontmatter": null, + "html": "

HTML Ipsum Presents

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.

Header Level 2

  1. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  2. Aliquam tincidunt mauris eu risus.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.

Header Level 3

#header h1 a{display: block;width: 300px;height: 80px;}
", + "id": StringMatching /\\[a-f0-9\\]\\{24\\}/, + "lexical": null, + "meta_description": "meta description for draft post", + "meta_title": null, + "mobiledoc": "{\\"version\\":\\"0.3.1\\",\\"markups\\":[],\\"atoms\\":[],\\"cards\\":[[\\"markdown\\",{\\"markdown\\":\\"

HTML Ipsum Presents

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.

Header Level 2

  1. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  2. Aliquam tincidunt mauris eu risus.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.

Header Level 3

#header h1 a{display: block;width: 300px;height: 80px;}
\\"}]],\\"sections\\":[[10,0]]}", + "newsletter": null, + "og_description": null, + "og_image": null, + "og_title": null, + "plaintext": "HTML Ipsum Presents + +Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. + + +Header Level 2 + + 1. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. + 2. Aliquam tincidunt mauris eu risus. + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est. + + +Header Level 3 + + * Lorem ipsum dolor sit amet, consectetuer adipiscing elit. + * Aliquam tincidunt mauris eu risus. + +#header h1 a{display: block;width: 300px;height: 80px;}", + "primary_author": Object { + "accessibility": null, + "bio": "bio", + "comment_notifications": true, + "cover_image": null, + "created_at": "2022-09-13T12:17:08.000Z", + "email": "jbloggs@example.com", + "facebook": null, + "free_member_signup_notification": true, + "id": "1", + "last_seen": "2022-09-13T12:17:09.000Z", + "location": "location", + "meta_description": null, + "meta_title": null, + "name": "Joe Bloggs", + "paid_subscription_canceled_notification": false, + "paid_subscription_started_notification": true, + "profile_image": "https://example.com/super_photo.jpg", + "roles": Array [ + Object { + "created_at": "2022-09-13T12:17:07.000Z", + "description": "Blog Owner", + "id": "632074c3082a107f3a4b0324", + "name": "Owner", + "updated_at": "2022-09-13T12:17:07.000Z", + }, + ], + "slug": "joe-bloggs", + "status": "active", + "tour": null, + "twitter": null, + "updated_at": "2022-09-13T12:17:09.000Z", + "url": "http://127.0.0.1:2369/author/joe-bloggs/", + "website": null, + }, + "primary_tag": Object { + "accent_color": null, + "canonical_url": null, + "codeinjection_foot": null, + "codeinjection_head": null, + "created_at": "2022-09-13T12:17:07.000Z", + "description": "description", + "feature_image": null, + "id": "6193c6d5e792de832cd08148", + "meta_description": null, + "meta_title": null, + "name": "pollo", + "og_description": null, + "og_image": null, + "og_title": null, + "slug": "pollo", + "twitter_description": null, + "twitter_image": null, + "twitter_title": null, + "updated_at": "2022-09-13T12:17:07.000Z", + "url": "http://127.0.0.1:2369/404/", + "visibility": "public", + }, + "published_at": "2022-09-13T12:17:07.000Z", + "reading_time": 1, + "slug": "unfinished", + "status": "draft", + "tags": Array [ + Object { + "accent_color": null, + "canonical_url": null, + "codeinjection_foot": null, + "codeinjection_head": null, + "created_at": "2022-09-13T12:17:07.000Z", + "description": "description", + "feature_image": null, + "id": "6193c6d5e792de832cd08148", + "meta_description": null, + "meta_title": null, + "name": "pollo", + "og_description": null, + "og_image": null, + "og_title": null, + "slug": "pollo", + "twitter_description": null, + "twitter_image": null, + "twitter_title": null, + "updated_at": "2022-09-13T12:17:07.000Z", + "url": "http://127.0.0.1:2369/404/", + "visibility": "public", + }, + ], + "tiers": Array [ + Object { + "active": true, + "created_at": "2022-09-13T12:17:07.000Z", + "description": null, + "id": "632074c3082a107f3a4b032b", + "monthly_price_id": null, + "name": "Default Product", + "slug": "default-product", + "trial_days": 0, + "type": "paid", + "updated_at": "2022-09-13T12:17:07.000Z", + "visibility": "public", + "welcome_page_url": null, + "yearly_price_id": null, + }, + Object { + "active": true, + "created_at": "2022-09-13T12:17:07.000Z", + "description": null, + "id": "632074c3082a107f3a4b032c", + "monthly_price_id": null, + "name": "Free", + "slug": "free", + "trial_days": 0, + "type": "free", + "updated_at": "2022-09-13T12:17:07.000Z", + "visibility": "public", + "welcome_page_url": null, + "yearly_price_id": null, + }, + ], + "title": "Not finished yet", + "twitter_description": null, + "twitter_image": null, + "twitter_title": null, + "updated_at": "2022-09-13T12:17:07.000Z", + "url": "http://127.0.0.1:2369/p/d52c42ae-2755-455c-80ec-70b2ec55c903/", + "uuid": "d52c42ae-2755-455c-80ec-70b2ec55c903", + "visibility": "public", + }, + ], +} +`; + +exports[`Posts API Can browse with formats 2: [headers] 1`] = ` +Object { + "access-control-allow-origin": "http://127.0.0.1:2369", + "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0", + "content-length": "12760", + "content-type": "application/json; charset=utf-8", + "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, + "vary": "Origin, Accept-Encoding", + "x-powered-by": "Express", +} +`; + exports[`Posts API Cannot delete a non-existent posts 1: [body] 1`] = ` Object { "errors": Array [ diff --git a/ghost/core/test/e2e-api/admin/pages.test.js b/ghost/core/test/e2e-api/admin/pages.test.js index 167264ed74..8259760329 100644 --- a/ghost/core/test/e2e-api/admin/pages.test.js +++ b/ghost/core/test/e2e-api/admin/pages.test.js @@ -39,6 +39,24 @@ describe('Pages API', function () { jsonResponse.pages[1].url.should.eql(`${config.get('url')}/contribute/`); }); + it('Can retrieve pages with lexical format', async function () { + const res = await request.get(localUtils.API.getApiQuery('pages/?formats=lexical')) + .set('Origin', config.get('url')) + .expect('Content-Type', /json/) + .expect('Cache-Control', testUtils.cacheRules.private) + .expect(200); + + should.not.exist(res.headers['x-cache-invalidate']); + const jsonResponse = res.body; + should.exist(jsonResponse.pages); + localUtils.API.checkResponse(jsonResponse, 'pages'); + jsonResponse.pages.should.have.length(6); + + const additionalProperties = ['lexical']; + const missingProperties = ['mobiledoc']; + localUtils.API.checkResponse(jsonResponse.pages[0], 'page', additionalProperties, missingProperties); + }); + it('Can add a page', async function () { const page = { title: 'My Page', diff --git a/ghost/core/test/e2e-api/admin/posts.test.js b/ghost/core/test/e2e-api/admin/posts.test.js index 7dcc0e025c..fc9d890190 100644 --- a/ghost/core/test/e2e-api/admin/posts.test.js +++ b/ghost/core/test/e2e-api/admin/posts.test.js @@ -1,6 +1,6 @@ const assert = require('assert'); const {agentProvider, fixtureManager, mockManager, matchers} = require('../../utils/e2e-framework'); -const {anyEtag, anyErrorId} = matchers; +const {anyEtag, anyErrorId, anyObjectId} = matchers; describe('Posts API', function () { let agent; @@ -15,6 +15,32 @@ describe('Posts API', function () { mockManager.restore(); }); + it('Can browse', async function () { + const res = await agent.get('posts/?limit=2') + .expectStatus(200) + .matchHeaderSnapshot({ + etag: anyEtag + }) + .matchBodySnapshot({ + posts: new Array(2).fill({ + id: anyObjectId + }) + }); + }); + + it('Can browse with formats', async function () { + const res = await agent.get('posts/?formats=mobiledoc,lexical,html,plaintext&limit=2') + .expectStatus(200) + .matchHeaderSnapshot({ + etag: anyEtag + }) + .matchBodySnapshot({ + posts: new Array(2).fill({ + id: anyObjectId + }) + }); + }); + describe('Delete', function () { it('Can destroy a post', async function () { await agent