@@ -596,46 +596,33 @@ describe('server', () => {
596
596
} )
597
597
598
598
describeViaActionsOnly ( 'Early Access articles' , ( ) => {
599
- let hiddenPageHrefs , hiddenPages
600
-
601
- beforeAll ( async ( ) => {
602
- const $ = await getDOM ( '/early-access' )
603
- hiddenPageHrefs = $ ( '#article-contents ul > li > a' )
604
- . map ( ( i , el ) => $ ( el ) . attr ( 'href' ) )
605
- . get ( )
606
-
607
- const allPages = await loadPages ( )
608
- hiddenPages = allPages . filter ( ( page ) => page . languageCode === 'en' && page . hidden )
609
- } )
610
-
611
- test ( 'exist in the set of English pages' , async ( ) => {
612
- expect ( hiddenPages . length ) . toBeGreaterThan ( 0 )
613
- } )
614
-
615
- test ( 'are listed at /early-access' , async ( ) => {
616
- expect ( hiddenPageHrefs . length ) . toBeGreaterThan ( 0 )
617
- } )
618
-
619
599
// Test skipped because this test file is no longer able to
620
600
// change the `NODE_ENV` between tests because it depends on
621
601
// HTTP and not raw supertest.
622
602
// Idea: Move this one test somewhere into tests/unit/
623
603
test . skip ( 'are not listed at /early-access in production' , async ( ) => {
624
- const oldNodeEnv = process . env . NODE_ENV
625
- process . env . NODE_ENV = 'production'
626
604
const res = await get ( '/early-access' , { followRedirects : true } )
627
- process . env . NODE_ENV = oldNodeEnv
628
605
expect ( res . statusCode ) . toBe ( 404 )
629
606
} )
630
607
631
608
test ( 'have noindex meta tags' , async ( ) => {
632
- const $ = await getDOM ( hiddenPageHrefs [ 0 ] )
633
- expect ( $ ( 'meta[content="noindex"]' ) . length ) . toBe ( 1 )
634
- } )
635
-
636
- test ( 'public articles do not have noindex meta tags' , async ( ) => {
637
- const $ = await getDOM ( '/en/articles/set-up-git' )
638
- expect ( $ ( 'meta[content="noindex"]' ) . length ) . toBe ( 0 )
609
+ const allPages = await loadPages ( )
610
+ // This is what the earlyAccessContext middleware does to get a
611
+ // list of early-access pages for that TOC it displays when
612
+ // viewing /en/early-access in development.
613
+ // Here we're using it to get a least 1 page we can end-to-end
614
+ // test to look at it's meta tags.
615
+ const hiddenPages = allPages . filter (
616
+ ( page ) =>
617
+ page . languageCode === 'en' &&
618
+ page . hidden &&
619
+ page . relativePath . startsWith ( 'early-access' ) &&
620
+ ! page . relativePath . endsWith ( 'index.md' )
621
+ )
622
+ for ( const { href } of hiddenPages [ 0 ] . permalinks ) {
623
+ const $ = await getDOM ( href )
624
+ expect ( $ ( 'meta[content="noindex"]' ) . length ) . toBe ( 1 )
625
+ }
639
626
} )
640
627
} )
641
628
0 commit comments