@@ -10,7 +10,7 @@ const helpers = require('../../../../../../core/frontend/services/helpers');
1010describe ( 'Helpers' , function ( ) {
1111 const hbsHelpers = [ 'each' , 'if' , 'unless' , 'with' , 'helperMissing' , 'blockHelperMissing' , 'log' , 'lookup' , 'block' , 'contentFor' ] ;
1212 const ghostHelpers = [
13- 'admin_url' , ' asset', 'authors' , 'body_class' , 'cancel_link' , 'color_to_rgba' , 'concat' , 'content' , 'content_api_key' , 'content_api_url' , 'contrast_text_color' , 'date' , 'encode' , 'excerpt' , 'facebook_url' , 'foreach' , 'get' ,
13+ 'asset' , 'authors' , 'body_class' , 'cancel_link' , 'color_to_rgba' , 'concat' , 'content' , 'content_api_key' , 'content_api_url' , 'contrast_text_color' , 'date' , 'encode' , 'excerpt' , 'facebook_url' , 'foreach' , 'get' ,
1414 'ghost_foot' , 'ghost_head' , 'has' , 'img_url' , 'is' , 'json' , 'link' , 'link_class' , 'meta_description' , 'meta_title' , 'navigation' ,
1515 'next_post' , 'page_url' , 'pagination' , 'plural' , 'post_class' , 'prev_post' , 'price' , 'raw' , 'reading_time' , 'split' , 't' , 'tags' , 'title' , 'total_members' , 'total_paid_members' , 'twitter_url' ,
1616 'url' , 'comment_count' , 'collection' , 'recommendations' , 'readable_url' , 'social_url'
@@ -37,23 +37,24 @@ describe('Helpers', function () {
3737 } ) ;
3838
3939 describe ( 'gscan compatibility' , function ( ) {
40- // Helpers that are intentionally NOT added to gscan's knownHelpers.
41- // Each entry must have a comment explaining why it 's excluded .
42- // gscan already knows about 'search' via its own knownHelpers list — check
43- // if there's a version mismatch. The remaining entries are intentionally excluded:
44- const intentionallyExcluded = [
45- 'raw' , // internal helper used by Ghost's own templates , not intended for theme developers
46- 'collection' , // experimental helper, not yet stable enough for gscan enforcement
40+ // Ghost helpers that are not intended for theme developers and are
41+ // legitimately absent from gscan 's knownHelpers .
42+ const internalHelpers = [
43+ 'raw' , // internal helper used by Ghost's own templates
44+ 'collection' , // experimental, not yet stable for themes
45+ 'search' // experimental , not yet in gscan
46+ ] ;
4747
48- // The following helpers need gscan bumps (tracked separately):
49- 'admin_url' , // new in this PR — gscan PR pending
50- 'json' , // new in this PR — gscan PR pending
51- 'color_to_rgba' , // new in this PR — gscan PR pending
52- 'contrast_text_color' , // new in this PR — gscan PR pending
53- 'search' // pre-existing gap — gscan doesn't know about this helper yet
48+ // Helpers that are available for themes but gscan doesn't know about yet.
49+ // When gscan is updated, remove entries here — the test will fail if you
50+ // add a new helper without updating either this list or gscan.
51+ const pendingGscanUpdate = [
52+ 'json' ,
53+ 'color_to_rgba' ,
54+ 'contrast_text_color'
5455 ] ;
5556
56- it ( 'all global helpers should be known to gscan' , function ( ) {
57+ it ( 'should track helpers not yet known to gscan' , function ( ) {
5758 const gscanSpec = require ( 'gscan/lib/specs/v6' ) ;
5859 const gscanKnownHelpers = new Set ( gscanSpec . knownHelpers ) ;
5960
@@ -63,12 +64,15 @@ describe('Helpers', function () {
6364 . map ( f => f . replace ( '.js' , '' ) ) ;
6465
6566 const missing = globalHelperFiles
66- . filter ( h => ! intentionallyExcluded . includes ( h ) )
67+ . filter ( h => ! internalHelpers . includes ( h ) )
6768 . filter ( h => ! gscanKnownHelpers . has ( h ) ) ;
6869
69- assert . deepEqual ( missing , [ ] ,
70- `Helpers in core/frontend/helpers/ but missing from gscan\'s knownHelpers: ${ missing . join ( ', ' ) } . ` +
71- 'Either add them to gscan or add to intentionallyExcluded with a reason.'
70+ // This assertion ensures the missing set matches exactly what we expect.
71+ // If you add a new helper, it will fail until you either:
72+ // 1. Add it to gscan's knownHelpers (preferred), or
73+ // 2. Add it to pendingGscanUpdate with a tracking issue
74+ assert . deepEqual ( missing . sort ( ) , pendingGscanUpdate . sort ( ) ,
75+ 'gscan helper mismatch. If you added a new helper, update gscan or add to pendingGscanUpdate.'
7276 ) ;
7377 } ) ;
7478 } ) ;
0 commit comments