From e068e6dbce907a8eaa565cbfaa05b11497eb040b Mon Sep 17 00:00:00 2001 From: wattanx Date: Thu, 26 Sep 2024 23:31:26 +0900 Subject: [PATCH] test: add tests to check 404 handling in client-side rendering --- test/basic.test.ts | 10 ++++++++++ test/fixtures/basic/pages/route-rules/spa.vue | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/test/basic.test.ts b/test/basic.test.ts index 9b9100f07e..9eaa238e48 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -249,6 +249,16 @@ describe('pages', () => { await serverPage.close() }) + it('should render 404 page even in spa mode', async () => { + const { page } = await renderPage('/route-rules/spa') + + await page.getByText('should throw a 404 error').click() + expect(await page.getByRole('heading').textContent()).toMatchInlineSnapshot(`"Page Not Found: /forbidden"`) + expect(await page.getByTestId('path').textContent()).toMatchInlineSnapshot(`" Path: /forbidden"`) + + await page.close() + }) + it('returns 500 when there is an infinite redirect', async () => { const { status } = await fetch('/redirect-infinite', { redirect: 'manual' }) expect(status).toEqual(500) diff --git a/test/fixtures/basic/pages/route-rules/spa.vue b/test/fixtures/basic/pages/route-rules/spa.vue index 6777da5c53..b29b77d980 100644 --- a/test/fixtures/basic/pages/route-rules/spa.vue +++ b/test/fixtures/basic/pages/route-rules/spa.vue @@ -1,5 +1,10 @@