diff --git a/test/e2e/app-dir/app/app/not-found/suspense/page.js b/test/e2e/app-dir/app/app/not-found/suspense/page.js new file mode 100644 index 0000000000000..c6881d14d45f1 --- /dev/null +++ b/test/e2e/app-dir/app/app/not-found/suspense/page.js @@ -0,0 +1,41 @@ +import { Suspense } from 'react' +import { notFound } from 'next/navigation' + +function createSuspenseyComponent(Component, { timeout = 0, expire = 10 }) { + let result + let promise + return function Data() { + if (result) return result + if (!promise) + promise = new Promise((resolve) => { + setTimeout(() => { + result = + setTimeout(() => { + result = undefined + promise = undefined + }, expire) + resolve() + }, timeout) + }) + throw promise + } +} + +function NotFound() { + notFound() + return <> +} + +const SuspenseyNotFound = createSuspenseyComponent(NotFound, { + timeout: 300, +}) + +export default function () { + return ( +
+ + + +
+ ) +} diff --git a/test/e2e/app-dir/index.test.ts b/test/e2e/app-dir/index.test.ts index 87604259b2f02..bc5174abe0903 100644 --- a/test/e2e/app-dir/index.test.ts +++ b/test/e2e/app-dir/index.test.ts @@ -2364,6 +2364,20 @@ createNextDescribe( .getAttribute('content') ).toBe('noindex') }) + it('should trigger not-found while streaming', async () => { + const initialHtml = await next.render('/not-found/suspense') + expect(initialHtml).not.toContain('noindex') + + const browser = await next.browser('/not-found/suspense') + expect( + await browser.waitForElementByCss('#not-found-component').text() + ).toBe('Not Found!') + expect( + await browser + .waitForElementByCss('meta[name="robots"]') + .getAttribute('content') + ).toBe('noindex') + }) }) describe('bots', () => {