diff --git a/ghost/core/test/unit/frontend/helpers/__snapshots__/ghost_head.test.js.snap b/ghost/core/test/unit/frontend/helpers/__snapshots__/ghost_head.test.js.snap index 09b3771fcb..3da011b45a 100644 --- a/ghost/core/test/unit/frontend/helpers/__snapshots__/ghost_head.test.js.snap +++ b/ghost/core/test/unit/frontend/helpers/__snapshots__/ghost_head.test.js.snap @@ -2,7 +2,7 @@ exports[`{{ghost_head}} helper accent_color attaches style tag to existing script/style tag 1 1`] = ` Object { - "string": " + "rendered": " @@ -70,7 +70,7 @@ Object { - - + ", } `; exports[`{{ghost_head}} helper accent_color does not include style tag in AMP context 1 1`] = ` Object { - "string": " + "rendered": " @@ -213,7 +213,7 @@ Object { exports[`{{ghost_head}} helper accent_color does not include style tag when not set 1 1`] = ` Object { - "string": " + "rendered": " @@ -282,22 +282,22 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper accent_color includes style tag on templates with no context 1 1`] = ` Object { - "string": " + "rendered": " - ", + ", } `; exports[`{{ghost_head}} helper accent_color includes style tag when set 1 1`] = ` Object { - "string": " + "rendered": " @@ -366,13 +366,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper amp is disabled does not contain amphtml link 1 1`] = ` Object { - "string": " + "rendered": " @@ -440,7 +440,7 @@ Object { - ", + ", } `; @@ -726,7 +726,7 @@ Object { exports[`{{ghost_head}} helper attribution scripts is included when tracking setting is enabled 1 1`] = ` Object { - "string": " + "rendered": " @@ -770,7 +770,7 @@ Object { - - + ", } `; exports[`{{ghost_head}} helper attribution scripts is not included when tracking setting is disabled 1 1`] = ` Object { - "string": " + "rendered": " @@ -885,7 +885,7 @@ Object { - - ", + ", } `; exports[`{{ghost_head}} helper members scripts includes portal when members enabled 1 1`] = ` Object { - "string": " + "rendered": " @@ -999,7 +999,7 @@ Object { - - + ", } `; exports[`{{ghost_head}} helper members scripts includes stripe when connected 1 1`] = ` Object { - "string": " + "rendered": " @@ -1114,7 +1114,7 @@ Object { - - + ", } `; exports[`{{ghost_head}} helper members scripts skips portal and stripe when members are disabled 1 1`] = ` Object { - "string": " + "rendered": " @@ -1230,13 +1230,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper members scripts skips stripe if not set up 1 1`] = ` Object { - "string": " + "rendered": " @@ -1280,7 +1280,7 @@ Object { - - + ", } `; exports[`{{ghost_head}} helper search scripts includes search when labs flag enabled 1 1`] = ` Object { - "string": " + "rendered": " @@ -1397,57 +1397,57 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper with /site subdirectory returns correct rss url with subdirectory 1 1`] = ` Object { - "string": " + "rendered": " - ", + ", } `; exports[`{{ghost_head}} helper with Code Injection handles post codeinjection being empty 1 1`] = ` Object { - "string": " + "rendered": " - + ", } `; exports[`{{ghost_head}} helper with Code Injection handles post codeinjection being null 1 1`] = ` Object { - "string": " + "rendered": " - + ", } `; exports[`{{ghost_head}} helper with Code Injection outputs post codeinjection as well 1 1`] = ` Object { - "string": " + "rendered": " - + post-codeinjection", } @@ -1455,20 +1455,20 @@ Object { exports[`{{ghost_head}} helper with Code Injection returns meta tag plus injected code 1 1`] = ` Object { - "string": " + "rendered": " - + ", } `; exports[`{{ghost_head}} helper with Code Injection returns meta tag without injected code for amp context 1 1`] = ` Object { - "string": " + "rendered": " @@ -1541,19 +1541,19 @@ Object { exports[`{{ghost_head}} helper with changed origin in config file contains the changed origin 1 1`] = ` Object { - "string": " + "rendered": " - ", + ", } `; exports[`{{ghost_head}} helper with useStructuredData is set to false in config file does not return structured data 1 1`] = ` Object { - "string": " + "rendered": " @@ -1561,13 +1561,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection disallows indexing for preview pages 1 1`] = ` Object { - "string": " + "rendered": " @@ -1585,13 +1585,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection does not inject count script if comments off 1 1`] = ` Object { - "string": " + "rendered": " @@ -1636,35 +1636,35 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection does not return structured data on paginated author pages 1 1`] = ` Object { - "string": " + "rendered": " - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection does not return structured data on paginated tag pages 1 1`] = ` Object { - "string": " + "rendered": " - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection implicit indexing settings for non-preview pages 1 1`] = ` Object { - "string": " + "rendered": " @@ -1674,7 +1674,7 @@ Object { exports[`{{ghost_head}} helper without Code Injection injects comment count script if comments all 1 1`] = ` Object { - "string": " + "rendered": " @@ -1719,14 +1719,14 @@ Object { - + ", } `; exports[`{{ghost_head}} helper without Code Injection injects comment count script if comments paid 1 1`] = ` Object { - "string": " + "rendered": " @@ -1771,14 +1771,14 @@ Object { - + ", } `; exports[`{{ghost_head}} helper without Code Injection outputs structured data but not schema for custom collection 1 1`] = ` Object { - "string": " + "rendered": " @@ -1792,13 +1792,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns canonical URL 1 1`] = ` Object { - "string": " + "rendered": " @@ -1858,13 +1858,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns meta structured data on homepage with site metadata defined 1 1`] = ` Object { - "string": " + "rendered": " @@ -1909,13 +1909,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns meta tag string even if safeVersion is invalid 1 1`] = ` Object { - "string": " + "rendered": " @@ -1929,50 +1929,50 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns meta tag string on paginated index page without structured data and schema 1 1`] = ` Object { - "string": " + "rendered": " - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns next & prev URL correctly for middle page 1 1`] = ` Object { - "string": " + "rendered": " - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns next & prev URL correctly for second page 1 1`] = ` Object { - "string": " + "rendered": " - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns structured data and schema first tag page with meta description and meta title 1 1`] = ` Object { - "string": " + "rendered": " @@ -2019,13 +2019,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns structured data and schema on first author page with cover image 1 1`] = ` Object { - "string": " + "rendered": " @@ -2070,13 +2070,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns structured data if metaTitle and metaDescription have double quotes 1 1`] = ` Object { - "string": " + "rendered": " @@ -2152,13 +2152,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns structured data on AMP post page with author image and post cover image 1 1`] = ` Object { - "string": " + "rendered": " @@ -2237,7 +2237,7 @@ Object { exports[`{{ghost_head}} helper without Code Injection returns structured data on first index page 1 1`] = ` Object { - "string": " + "rendered": " @@ -2282,13 +2282,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns structured data on post page with author image and post cover image 1 1`] = ` Object { - "string": " + "rendered": " @@ -2364,13 +2364,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns structured data on post page with custom excerpt for description and meta description 1 1`] = ` Object { - "string": " + "rendered": " @@ -2446,13 +2446,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns structured data on post page with fall back excerpt if no meta description provided 1 1`] = ` Object { - "string": " + "rendered": " @@ -2516,13 +2516,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns structured data on post page with null author image and post cover image 1 1`] = ` Object { - "string": " + "rendered": " @@ -2590,13 +2590,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns structured data on static page 1 1`] = ` Object { - "string": " + "rendered": " @@ -2664,13 +2664,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns structured data on static page with custom post structured data 1 1`] = ` Object { - "string": " + "rendered": " @@ -2738,13 +2738,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns structured data without tags if there are no tags 1 1`] = ` Object { - "string": " + "rendered": " @@ -2813,13 +2813,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection returns twitter and facebook descriptions even if no meta description available 1 1`] = ` Object { - "string": " + "rendered": " @@ -2880,13 +2880,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection tag first page without meta and model description returns no description fields 1 1`] = ` Object { - "string": " + "rendered": " @@ -2929,13 +2929,13 @@ Object { - ", + ", } `; exports[`{{ghost_head}} helper without Code Injection tag first page without meta data if no meta title and meta description, but model description provided 1 1`] = ` Object { - "string": " + "rendered": " @@ -2982,6 +2982,6 @@ Object { - ", + ", } `; diff --git a/ghost/core/test/unit/frontend/helpers/ghost_head.test.js b/ghost/core/test/unit/frontend/helpers/ghost_head.test.js index 7423f3a653..952e4f8d19 100644 --- a/ghost/core/test/unit/frontend/helpers/ghost_head.test.js +++ b/ghost/core/test/unit/frontend/helpers/ghost_head.test.js @@ -21,9 +21,18 @@ const {settingsCache, labs} = proxy; * So these changes become visible in PR's. */ async function testGhostHead(options) { - const rendered = await ghost_head(options); + let rendered = (await ghost_head(options)).toString(); + + // Ignore some parts of the response by replacing regexes + const portalVersion = /portal@~\d+\.\d+(\.\d+)?\//g; + rendered = rendered.replace(portalVersion, 'portal@~[[VERSION]]/'); + + const sodoSearchVersion = /sodo-search@~\d+\.\d+(\.\d+)?\//g; + rendered = rendered.replace(sodoSearchVersion, 'sodo-search@~[[VERSION]]/'); + should.exist(rendered); - rendered.should.matchSnapshot(); + // Note: we need to convert the string to an object in order to use the snapshot feature + should({rendered}).matchSnapshot(); return rendered; }