mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
Converted pages e2e test to use test-framework
refs https://github.com/TryGhost/Toolbox/issues/215 - The conversion should serve as a reference test. Eventually the aim is to have all tests converted to use "utils/e2e-framework" instead of previously used plethora of utils and whatnot
This commit is contained in:
parent
d6d064be71
commit
33da584161
293
test/e2e-api/content/__snapshots__/pages.test.js.snap
Normal file
293
test/e2e-api/content/__snapshots__/pages.test.js.snap
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`Pages Content API Can request page 1: [body] 1`] = `
|
||||||
|
Object {
|
||||||
|
"pages": Array [
|
||||||
|
Object {
|
||||||
|
"access": true,
|
||||||
|
"canonical_url": null,
|
||||||
|
"codeinjection_foot": null,
|
||||||
|
"codeinjection_head": null,
|
||||||
|
"comment_id": "618ba1ffbe2896088840a6e9",
|
||||||
|
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"custom_excerpt": null,
|
||||||
|
"custom_template": null,
|
||||||
|
"excerpt": "Static page test is what this is for.
|
||||||
|
Hopefully you don't find it a bore.",
|
||||||
|
"feature_image": null,
|
||||||
|
"feature_image_alt": null,
|
||||||
|
"feature_image_caption": null,
|
||||||
|
"featured": false,
|
||||||
|
"frontmatter": null,
|
||||||
|
"html": "<!--kg-card-begin: markdown--><h1>Static page test is what this is for.</h1><p>Hopefully you don't find it a bore.</p><!--kg-card-end: markdown-->",
|
||||||
|
"id": "618ba1ffbe2896088840a6e9",
|
||||||
|
"meta_description": null,
|
||||||
|
"meta_title": null,
|
||||||
|
"og_description": null,
|
||||||
|
"og_image": null,
|
||||||
|
"og_title": null,
|
||||||
|
"page": true,
|
||||||
|
"published_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"reading_time": 0,
|
||||||
|
"slug": "static-page-test",
|
||||||
|
"title": "This is a static page",
|
||||||
|
"twitter_description": null,
|
||||||
|
"twitter_image": null,
|
||||||
|
"twitter_title": null,
|
||||||
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"url": "http://127.0.0.1:2369/static-page-test/",
|
||||||
|
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||||
|
"visibility": "public",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Pages Content API Can request page 2: [headers] 1`] = `
|
||||||
|
Object {
|
||||||
|
"access-control-allow-origin": "*",
|
||||||
|
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||||
|
"content-length": "1076",
|
||||||
|
"content-type": "application/json; charset=utf-8",
|
||||||
|
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||||
|
"vary": "Accept-Encoding",
|
||||||
|
"x-powered-by": "Express",
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Pages Content API Can request pages 1: [body] 1`] = `
|
||||||
|
Object {
|
||||||
|
"meta": Object {
|
||||||
|
"pagination": Object {
|
||||||
|
"limit": 15,
|
||||||
|
"next": null,
|
||||||
|
"page": 1,
|
||||||
|
"pages": 1,
|
||||||
|
"prev": null,
|
||||||
|
"total": 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"pages": Array [
|
||||||
|
Object {
|
||||||
|
"access": true,
|
||||||
|
"canonical_url": null,
|
||||||
|
"codeinjection_foot": null,
|
||||||
|
"codeinjection_head": null,
|
||||||
|
"comment_id": "6194d3ce51e2700162531a78",
|
||||||
|
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"custom_excerpt": null,
|
||||||
|
"custom_template": null,
|
||||||
|
"excerpt": "Unlike posts, pages in Ghost don't appear in the main feed. They're separate,
|
||||||
|
individual pages which only show up when you link to them. Great for content
|
||||||
|
which is important, but separate from your usual posts.
|
||||||
|
|
||||||
|
An about page is a great example of one you might want to set up early on so
|
||||||
|
people can find out more about you, and what you do. Why should people subscribe
|
||||||
|
to your site and become a member? Details help!
|
||||||
|
|
||||||
|
> Tip: If you're reading any post or page on your site and you notice something
|
||||||
|
y",
|
||||||
|
"feature_image": null,
|
||||||
|
"feature_image_alt": null,
|
||||||
|
"feature_image_caption": null,
|
||||||
|
"featured": false,
|
||||||
|
"frontmatter": null,
|
||||||
|
"html": "<p>Unlike posts, pages in Ghost don't appear in the main feed. They're separate, individual pages which only show up when you link to them. Great for content which is important, but separate from your usual posts.</p><p>An about page is a great example of one you might want to set up early on so people can find out more about you, and what you do. Why should people subscribe to your site and become a member? Details help!</p><blockquote><strong>Tip: </strong>If you're reading any post or page on your site and you notice something you want to edit, you can add <code>/edit</code> to the end of the URL – and you'll be taken directly to the Ghost editor.</blockquote><p>Now tell the world what your site is all about.</p>",
|
||||||
|
"id": "6194d3ce51e2700162531a78",
|
||||||
|
"meta_description": null,
|
||||||
|
"meta_title": null,
|
||||||
|
"og_description": null,
|
||||||
|
"og_image": null,
|
||||||
|
"og_title": null,
|
||||||
|
"page": true,
|
||||||
|
"published_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"reading_time": 0,
|
||||||
|
"slug": "about",
|
||||||
|
"title": "About this site",
|
||||||
|
"twitter_description": null,
|
||||||
|
"twitter_image": null,
|
||||||
|
"twitter_title": null,
|
||||||
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"url": "http://127.0.0.1:2369/about/",
|
||||||
|
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||||
|
"visibility": "public",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"access": true,
|
||||||
|
"canonical_url": null,
|
||||||
|
"codeinjection_foot": null,
|
||||||
|
"codeinjection_head": null,
|
||||||
|
"comment_id": "6194d3ce51e2700162531a79",
|
||||||
|
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"custom_excerpt": null,
|
||||||
|
"custom_template": null,
|
||||||
|
"excerpt": "If you want to set up a contact page for people to be able to reach out to you,
|
||||||
|
the simplest way is to set up a simple page like this and list the different
|
||||||
|
ways people can reach out to you.
|
||||||
|
|
||||||
|
For example, here's how to reach us!
|
||||||
|
* @Ghost [https://twitter.com/ghost] on Twitter
|
||||||
|
* @Ghost [https://www.facebook.com/ghost] on Facebook
|
||||||
|
* @Ghost [https://instagram.com/ghost] on Instagram
|
||||||
|
|
||||||
|
If you prefer to use a contact form, almost all of the great embedded form
|
||||||
|
services work great with Ghost and are",
|
||||||
|
"feature_image": null,
|
||||||
|
"feature_image_alt": null,
|
||||||
|
"feature_image_caption": null,
|
||||||
|
"featured": false,
|
||||||
|
"frontmatter": null,
|
||||||
|
"html": "<p>If you want to set up a contact page for people to be able to reach out to you, the simplest way is to set up a simple page like this and list the different ways people can reach out to you.</p><h3 id=\\"for-example-heres-how-to-reach-us\\">For example, here's how to reach us!</h3><ul><li><a href=\\"https://twitter.com/ghost\\">@Ghost</a> on Twitter</li><li><a href=\\"https://www.facebook.com/ghost\\">@Ghost</a> on Facebook</li><li><a href=\\"https://instagram.com/ghost\\">@Ghost</a> on Instagram</li></ul><p>If you prefer to use a contact form, almost all of the great embedded form services work great with Ghost and are easy to set up:</p><figure class=\\"kg-card kg-image-card\\"><a href=\\"https://ghost.org/integrations/?tag=forms\\"><img src=\\"https://static.ghost.org/v4.0.0/images/integrations.png\\" class=\\"kg-image\\" alt loading=\\"lazy\\" width=\\"2944\\" height=\\"1716\\"></a></figure>",
|
||||||
|
"id": "6194d3ce51e2700162531a79",
|
||||||
|
"meta_description": null,
|
||||||
|
"meta_title": null,
|
||||||
|
"og_description": null,
|
||||||
|
"og_image": null,
|
||||||
|
"og_title": null,
|
||||||
|
"page": true,
|
||||||
|
"published_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"reading_time": 1,
|
||||||
|
"slug": "contact",
|
||||||
|
"title": "Contact",
|
||||||
|
"twitter_description": null,
|
||||||
|
"twitter_image": null,
|
||||||
|
"twitter_title": null,
|
||||||
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"url": "http://127.0.0.1:2369/contact/",
|
||||||
|
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||||
|
"visibility": "public",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"access": true,
|
||||||
|
"canonical_url": null,
|
||||||
|
"codeinjection_foot": null,
|
||||||
|
"codeinjection_head": null,
|
||||||
|
"comment_id": "6194d3ce51e2700162531a7b",
|
||||||
|
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"custom_excerpt": null,
|
||||||
|
"custom_template": null,
|
||||||
|
"excerpt": "Oh hey, you clicked every link of our starter content and even clicked this
|
||||||
|
small link in the footer! If you like Ghost and you're enjoying the product so
|
||||||
|
far, we'd hugely appreciate your support in any way you care to show it.
|
||||||
|
|
||||||
|
Ghost is a non-profit organization, and we give away all our intellectual
|
||||||
|
property as open source software. If you believe in what we do, there are a
|
||||||
|
number of ways you can give us a hand, and we hugely appreciate all of them:
|
||||||
|
|
||||||
|
* Contribute code via GitHub [https://gith",
|
||||||
|
"feature_image": null,
|
||||||
|
"feature_image_alt": null,
|
||||||
|
"feature_image_caption": null,
|
||||||
|
"featured": false,
|
||||||
|
"frontmatter": null,
|
||||||
|
"html": "<p>Oh hey, you clicked every link of our starter content and even clicked this small link in the footer! If you like Ghost and you're enjoying the product so far, we'd hugely appreciate your support in any way you care to show it.</p><p>Ghost is a non-profit organization, and we give away all our intellectual property as open source software. If you believe in what we do, there are a number of ways you can give us a hand, and we hugely appreciate all of them:</p><ul><li>Contribute code via <a href=\\"https://github.com/tryghost\\">GitHub</a></li><li>Contribute financially via <a href=\\"https://github.com/sponsors/TryGhost\\">GitHub Sponsors</a></li><li>Contribute financially via <a href=\\"https://opencollective.com/ghost\\">Open Collective</a></li><li>Contribute reviews via <strong>writing a blog post</strong></li><li>Contribute good vibes via <strong>telling your friends</strong> about us</li></ul><p>Thanks for checking us out!</p>",
|
||||||
|
"id": "6194d3ce51e2700162531a7b",
|
||||||
|
"meta_description": null,
|
||||||
|
"meta_title": null,
|
||||||
|
"og_description": null,
|
||||||
|
"og_image": null,
|
||||||
|
"og_title": null,
|
||||||
|
"page": true,
|
||||||
|
"published_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"reading_time": 0,
|
||||||
|
"slug": "contribute",
|
||||||
|
"title": "Contribute",
|
||||||
|
"twitter_description": null,
|
||||||
|
"twitter_image": null,
|
||||||
|
"twitter_title": null,
|
||||||
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"url": "http://127.0.0.1:2369/contribute/",
|
||||||
|
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||||
|
"visibility": "public",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"access": true,
|
||||||
|
"canonical_url": null,
|
||||||
|
"codeinjection_foot": null,
|
||||||
|
"codeinjection_head": null,
|
||||||
|
"comment_id": "6194d3ce51e2700162531a7a",
|
||||||
|
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"custom_excerpt": null,
|
||||||
|
"custom_template": null,
|
||||||
|
"excerpt": "Wondering how Ghost fares when it comes to privacy and GDPR rules? Good news:
|
||||||
|
Ghost does not use any tracking cookies of any kind.
|
||||||
|
|
||||||
|
You can integrate any products, services, ads or integrations with Ghost
|
||||||
|
yourself if you want to, but it's always a good idea to disclose how subscriber
|
||||||
|
data will be used by putting together a privacy page.",
|
||||||
|
"feature_image": null,
|
||||||
|
"feature_image_alt": null,
|
||||||
|
"feature_image_caption": null,
|
||||||
|
"featured": false,
|
||||||
|
"frontmatter": null,
|
||||||
|
"html": "<p>Wondering how Ghost fares when it comes to privacy and GDPR rules? Good news: Ghost does not use any tracking cookies of any kind.</p><p>You can integrate any products, services, ads or integrations with Ghost yourself if you want to, but it's always a good idea to disclose how subscriber data will be used by putting together a privacy page.</p>",
|
||||||
|
"id": "6194d3ce51e2700162531a7a",
|
||||||
|
"meta_description": null,
|
||||||
|
"meta_title": null,
|
||||||
|
"og_description": null,
|
||||||
|
"og_image": null,
|
||||||
|
"og_title": null,
|
||||||
|
"page": true,
|
||||||
|
"published_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"reading_time": 0,
|
||||||
|
"slug": "privacy",
|
||||||
|
"title": "Privacy",
|
||||||
|
"twitter_description": null,
|
||||||
|
"twitter_image": null,
|
||||||
|
"twitter_title": null,
|
||||||
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"url": "http://127.0.0.1:2369/privacy/",
|
||||||
|
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||||
|
"visibility": "public",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"access": true,
|
||||||
|
"canonical_url": null,
|
||||||
|
"codeinjection_foot": null,
|
||||||
|
"codeinjection_head": null,
|
||||||
|
"comment_id": "618ba1ffbe2896088840a6e9",
|
||||||
|
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"custom_excerpt": null,
|
||||||
|
"custom_template": null,
|
||||||
|
"excerpt": "Static page test is what this is for.
|
||||||
|
Hopefully you don't find it a bore.",
|
||||||
|
"feature_image": null,
|
||||||
|
"feature_image_alt": null,
|
||||||
|
"feature_image_caption": null,
|
||||||
|
"featured": false,
|
||||||
|
"frontmatter": null,
|
||||||
|
"html": "<!--kg-card-begin: markdown--><h1>Static page test is what this is for.</h1><p>Hopefully you don't find it a bore.</p><!--kg-card-end: markdown-->",
|
||||||
|
"id": "618ba1ffbe2896088840a6e9",
|
||||||
|
"meta_description": null,
|
||||||
|
"meta_title": null,
|
||||||
|
"og_description": null,
|
||||||
|
"og_image": null,
|
||||||
|
"og_title": null,
|
||||||
|
"page": true,
|
||||||
|
"published_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"reading_time": 0,
|
||||||
|
"slug": "static-page-test",
|
||||||
|
"title": "This is a static page",
|
||||||
|
"twitter_description": null,
|
||||||
|
"twitter_image": null,
|
||||||
|
"twitter_title": null,
|
||||||
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000\\\\\\+\\\\d\\{2\\}:\\\\d\\{2\\}/,
|
||||||
|
"url": "http://127.0.0.1:2369/static-page-test/",
|
||||||
|
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||||
|
"visibility": "public",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Pages Content API Can request pages 2: [headers] 1`] = `
|
||||||
|
Object {
|
||||||
|
"access-control-allow-origin": "*",
|
||||||
|
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||||
|
"content-length": "9207",
|
||||||
|
"content-type": "application/json; charset=utf-8",
|
||||||
|
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||||
|
"vary": "Accept-Encoding",
|
||||||
|
"x-powered-by": "Express",
|
||||||
|
}
|
||||||
|
`;
|
@ -1,68 +1,57 @@
|
|||||||
const url = require('url');
|
const assert = require('assert');
|
||||||
const should = require('should');
|
|
||||||
const supertest = require('supertest');
|
const {agentProvider, fixtureManager, matchers} = require('../../utils/e2e-framework');
|
||||||
const testUtils = require('../../utils');
|
const {anyEtag, anyUuid, anyDateWithTimezoneOffset} = matchers;
|
||||||
const configUtils = require('../../utils/configUtils');
|
|
||||||
const config = require('../../../core/shared/config');
|
const pageMatcher = {
|
||||||
const localUtils = require('./utils');
|
published_at: anyDateWithTimezoneOffset,
|
||||||
|
created_at: anyDateWithTimezoneOffset,
|
||||||
|
updated_at: anyDateWithTimezoneOffset,
|
||||||
|
uuid: anyUuid
|
||||||
|
};
|
||||||
|
|
||||||
describe('Pages Content API', function () {
|
describe('Pages Content API', function () {
|
||||||
let request;
|
let agent;
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
await localUtils.startGhost();
|
agent = await agentProvider.getContentAPIAgent();
|
||||||
request = supertest.agent(config.get('url'));
|
await fixtureManager.init('users:no-owner', 'user:inactive', 'posts', 'tags:extra', 'api_keys');
|
||||||
await testUtils.initFixtures('users:no-owner', 'user:inactive', 'posts', 'tags:extra', 'api_keys');
|
agent.authenticate();
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function () {
|
|
||||||
configUtils.restore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Can request pages', async function () {
|
it('Can request pages', async function () {
|
||||||
const key = localUtils.getValidKey();
|
const res = await agent.get(`pages/`)
|
||||||
const res = await request.get(localUtils.API.getApiQuery(`pages/?key=${key}`))
|
.expectStatus(200)
|
||||||
.set('Origin', testUtils.API.getURL())
|
.matchHeaderSnapshot({
|
||||||
.expect('Content-Type', /json/)
|
etag: anyEtag
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
})
|
||||||
.expect(200);
|
.matchBodySnapshot({
|
||||||
|
pages: new Array(5)
|
||||||
|
.fill(pageMatcher)
|
||||||
|
});
|
||||||
|
|
||||||
res.headers.vary.should.eql('Accept-Encoding');
|
assert.equal(res.body.pages[0].slug, 'about');
|
||||||
should.exist(res.headers['access-control-allow-origin']);
|
|
||||||
should.not.exist(res.headers['x-cache-invalidate']);
|
|
||||||
|
|
||||||
const jsonResponse = res.body;
|
const urlParts = new URL(res.body.pages[0].url);
|
||||||
should.exist(jsonResponse.pages);
|
assert.equal(urlParts.protocol, 'http:');
|
||||||
should.exist(jsonResponse.meta);
|
assert.equal(urlParts.host, '127.0.0.1:2369');
|
||||||
jsonResponse.pages.should.have.length(5);
|
|
||||||
|
|
||||||
res.body.pages[0].slug.should.eql('about');
|
|
||||||
|
|
||||||
const urlParts = url.parse(res.body.pages[0].url);
|
|
||||||
should.exist(urlParts.protocol);
|
|
||||||
should.exist(urlParts.host);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Can request page', async function () {
|
it('Can request page', async function () {
|
||||||
const key = localUtils.getValidKey();
|
const res = await agent.get(`pages/${fixtureManager.get('posts', 5).id}/`)
|
||||||
const res = await request.get(localUtils.API.getApiQuery(`pages/${testUtils.DataGenerator.Content.posts[5].id}/?key=${key}`))
|
.expectStatus(200)
|
||||||
.set('Origin', testUtils.API.getURL())
|
.matchHeaderSnapshot({
|
||||||
.expect('Content-Type', /json/)
|
etag: anyEtag
|
||||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
})
|
||||||
.expect(200);
|
.matchBodySnapshot({
|
||||||
|
pages: new Array(1)
|
||||||
|
.fill(pageMatcher)
|
||||||
|
});
|
||||||
|
|
||||||
res.headers.vary.should.eql('Accept-Encoding');
|
assert.equal(res.body.pages[0].slug, fixtureManager.get('posts', 5).slug);
|
||||||
should.exist(res.headers['access-control-allow-origin']);
|
|
||||||
should.not.exist(res.headers['x-cache-invalidate']);
|
|
||||||
|
|
||||||
const jsonResponse = res.body;
|
const urlParts = new URL(res.body.pages[0].url);
|
||||||
should.exist(jsonResponse.pages);
|
assert.equal(urlParts.protocol, 'http:');
|
||||||
jsonResponse.pages.should.have.length(1);
|
assert.equal(urlParts.host, '127.0.0.1:2369');
|
||||||
|
|
||||||
res.body.pages[0].slug.should.eql(testUtils.DataGenerator.Content.posts[5].slug);
|
|
||||||
|
|
||||||
const urlParts = url.parse(res.body.pages[0].url);
|
|
||||||
should.exist(urlParts.protocol);
|
|
||||||
should.exist(urlParts.host);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user