next.js/test/e2e/app-dir/ppr-metadata-blocking/ppr-metadata-blocking-ppr-fallback.test.ts
ppr-metadata-blocking-ppr-fallback.test.ts40 lines1.5 KB
import { nextTestSetup } from 'e2e-utils'

function countSubstring(str: string, substr: string): number {
  return str.split(substr).length - 1
}

// TODO(NAR-423): Migrate to Cache Components.
describe.skip('ppr-metadata-blocking-ppr-fallback', () => {
  const { next, skipped } = nextTestSetup({
    files: __dirname,
    // Need to skip deployment because the test uses the private env cannot be used in deployment
    skipDeployment: true,
    env: {
      __NEXT_EXPERIMENTAL_STATIC_SHELL_DEBUGGING: '1',
    },
  })

  if (skipped) return

  it('should not include metadata in partial shell when page is fully dynamic', async () => {
    const $ = await next.render$('/fully-dynamic?__nextppronly=fallback')
    expect(countSubstring($.html(), '<title>')).toBe(0)
  })

  it('should include viewport metadata in partial shell when metadata is dynamic under suspense', async () => {
    const $ = await next.render$(
      '/dynamic-metadata/partial?__nextppronly=fallback'
    )
    expect(countSubstring($.html(), '<title>')).toBe(0)
    expect(countSubstring($.html(), '<meta name="viewport"')).toBe(1)
  })

  it('should include viewport metadata in partial shell when page is partially dynamic', async () => {
    const $ = await next.render$('/dynamic-page/partial?__nextppronly=fallback')
    expect($('head title').text()).toBe('dynamic-page - partial')
    expect(countSubstring($.html(), '<title>')).toBe(1)
    expect(countSubstring($.html(), '<meta name="viewport"')).toBe(1)
  })
})
Quest for Codev2.0.0
/
SIGN IN