From 519d0fb598580208ee485e1a1a2212c828db7500 Mon Sep 17 00:00:00 2001 From: Ahad Birang Date: Tue, 2 Aug 2022 18:27:33 +0430 Subject: [PATCH] fix(document-driven): throw 404 error when content is missing (#1394) --- scripts/test.sh | 4 +- src/runtime/pages/document-driven.vue | 9 ++ test/document-driven.test.ts | 11 ++- .../document-driven/pages/[...slug].vue | 82 ------------------- 4 files changed, 21 insertions(+), 85 deletions(-) delete mode 100644 test/fixtures/document-driven/pages/[...slug].vue diff --git a/scripts/test.sh b/scripts/test.sh index 1c2a99ecb..633fb44f6 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -13,8 +13,8 @@ done if [[ $ARG1 ]] then - echo "npx vitest run -t $ARG1" - (npx vitest run -t $ARG1.test) + echo "npx vitest run $ARG1" + (npx vitest run $ARG1.test) else echo "npx vitest run" (npx vitest run) diff --git a/src/runtime/pages/document-driven.vue b/src/runtime/pages/document-driven.vue index 270cb1b20..aa68694fd 100644 --- a/src/runtime/pages/document-driven.vue +++ b/src/runtime/pages/document-driven.vue @@ -1,8 +1,17 @@ diff --git a/test/document-driven.test.ts b/test/document-driven.test.ts index 0a9ebe16b..ba2b53ed0 100644 --- a/test/document-driven.test.ts +++ b/test/document-driven.test.ts @@ -11,7 +11,7 @@ describe('fixtures:document-driven', async () => { test(' from front-matter', async () => { const html = await $fetch('/') - expect(html).contains('Home | Document Driven Fixture') + expect(html).contains('<title>Home') }) test('disabled document driven', async () => { @@ -46,4 +46,13 @@ describe('fixtures:document-driven', async () => { expect(html).contains('with previous link /layout') expect(html).contains('with next link /no-surround') }) + + test('404 page', async () => { + try { + await $fetch('/page-not-found') + } catch (e) { + expect(e.response.status).toBe(404) + expect(e.response.statusText).toBe('Page not found: /page-not-found') + } + }) }) diff --git a/test/fixtures/document-driven/pages/[...slug].vue b/test/fixtures/document-driven/pages/[...slug].vue deleted file mode 100644 index 203b45cdb..000000000 --- a/test/fixtures/document-driven/pages/[...slug].vue +++ /dev/null @@ -1,82 +0,0 @@ - - - - -