@@ -391,6 +391,53 @@ function runTests(isDev) {
391391 await checkDomainLocales ( 'fr' , 'example.fr' )
392392 } )
393393
394+ it ( 'should generate AMP pages with all locales' , async ( ) => {
395+ for ( const locale of locales ) {
396+ const localePath = locale !== 'en-US' ? `/${ locale } ` : ''
397+ const html = await renderViaHTTP ( appPort , `${ localePath } /amp/amp-hybrid` )
398+ const $ = cheerio . load ( html )
399+ expect ( $ ( 'html' ) . attr ( 'lang' ) ) . toBe ( locale )
400+ expect ( $ ( '#is-amp' ) . text ( ) ) . toBe ( 'no' )
401+ expect ( $ ( '#router-locale' ) . text ( ) ) . toBe ( locale )
402+ expect ( JSON . parse ( $ ( '#router-locales' ) . text ( ) ) ) . toEqual ( locales )
403+ expect ( $ ( '#router-pathname' ) . text ( ) ) . toBe ( '/amp/amp-hybrid' )
404+ expect ( $ ( '#router-as-path' ) . text ( ) ) . toBe ( '/amp/amp-hybrid' )
405+ expect ( JSON . parse ( $ ( '#router-query' ) . text ( ) ) ) . toEqual ( { } )
406+
407+ const amphtmlPath = `${ localePath } /amp/amp-hybrid${
408+ isDev ? '?amp=1' : '.amp'
409+ } `
410+ expect ( $ ( 'link[rel=amphtml]' ) . attr ( 'href' ) ) . toBe ( amphtmlPath )
411+
412+ const html2 = await renderViaHTTP ( appPort , amphtmlPath )
413+ const $2 = cheerio . load ( html2 )
414+ expect ( $2 ( 'html' ) . attr ( 'lang' ) ) . toBe ( locale )
415+ expect ( $2 ( '#is-amp' ) . text ( ) ) . toBe ( 'yes' )
416+ expect ( $2 ( '#router-locale' ) . text ( ) ) . toBe ( locale )
417+ expect ( JSON . parse ( $2 ( '#router-locales' ) . text ( ) ) ) . toEqual ( locales )
418+ expect ( $2 ( '#router-pathname' ) . text ( ) ) . toBe ( '/amp/amp-hybrid' )
419+ expect ( $2 ( '#router-as-path' ) . text ( ) ) . toBe ( '/amp/amp-hybrid' )
420+ expect ( JSON . parse ( $2 ( '#router-query' ) . text ( ) ) ) . toEqual ( { amp : '1' } )
421+ expect ( $2 ( 'link[rel=amphtml]' ) . attr ( 'href' ) ) . toBeFalsy ( )
422+ }
423+ } )
424+
425+ it ( 'should work with AMP first page with all locales' , async ( ) => {
426+ for ( const locale of locales ) {
427+ const localePath = locale !== 'en-US' ? `/${ locale } ` : ''
428+ const html = await renderViaHTTP ( appPort , `${ localePath } /amp/amp-first` )
429+ const $ = cheerio . load ( html )
430+ expect ( $ ( 'html' ) . attr ( 'lang' ) ) . toBe ( locale )
431+ expect ( $ ( '#is-amp' ) . text ( ) ) . toBe ( 'yes' )
432+ expect ( $ ( '#router-locale' ) . text ( ) ) . toBe ( locale )
433+ expect ( JSON . parse ( $ ( '#router-locales' ) . text ( ) ) ) . toEqual ( locales )
434+ expect ( $ ( '#router-pathname' ) . text ( ) ) . toBe ( '/amp/amp-first' )
435+ expect ( $ ( '#router-as-path' ) . text ( ) ) . toBe ( '/amp/amp-first' )
436+ expect ( JSON . parse ( $ ( '#router-query' ) . text ( ) ) ) . toEqual ( { } )
437+ expect ( $ ( 'link[rel=amphtml]' ) . attr ( 'href' ) ) . toBeFalsy ( )
438+ }
439+ } )
440+
394441 it ( 'should generate fallbacks with all locales' , async ( ) => {
395442 for ( const locale of locales ) {
396443 const html = await renderViaHTTP (
0 commit comments