diff --git a/src/runtime/entrypoints/main.ts b/src/runtime/entrypoints/main.ts index 8c5d7724..ac40fe48 100644 --- a/src/runtime/entrypoints/main.ts +++ b/src/runtime/entrypoints/main.ts @@ -639,10 +639,6 @@ class NoPartialsError extends Error {} * Apply partials from a HTML response */ export async function applyPartials(res: Response): Promise { - if (!res.ok) { - throw new Error(partialErrorMessage); - } - const contentType = res.headers.get("Content-Type"); if (contentType !== "text/html; charset=utf-8") { throw new Error(partialErrorMessage); diff --git a/tests/fixture_partials/fresh.gen.ts b/tests/fixture_partials/fresh.gen.ts index 6a7c7a51..70f15dec 100644 --- a/tests/fixture_partials/fresh.gen.ts +++ b/tests/fixture_partials/fresh.gen.ts @@ -2,6 +2,7 @@ // This file SHOULD be checked into source version control. // This file is automatically updated during development when running `dev.ts`. +import * as $_404 from "./routes/_404.tsx"; import * as $_app from "./routes/_app.tsx"; import * as $active_nav_foo_bar from "./routes/active_nav/foo/bar.tsx"; import * as $active_nav_foo_index from "./routes/active_nav/foo/index.tsx"; @@ -35,6 +36,7 @@ import * as $deep_partial_index from "./routes/deep_partial/index.tsx"; import * as $deep_partial_injected from "./routes/deep_partial/injected.tsx"; import * as $deep_partial_update from "./routes/deep_partial/update.tsx"; import * as $duplicate_name_index from "./routes/duplicate_name/index.tsx"; +import * as $error_404 from "./routes/error_404.tsx"; import * as $form_index from "./routes/form/index.tsx"; import * as $form_injected from "./routes/form/injected.tsx"; import * as $form_update from "./routes/form/update.tsx"; @@ -133,6 +135,7 @@ import { Manifest } from "$fresh/server.ts"; const manifest = { routes: { + "./routes/_404.tsx": $_404, "./routes/_app.tsx": $_app, "./routes/active_nav/foo/bar.tsx": $active_nav_foo_bar, "./routes/active_nav/foo/index.tsx": $active_nav_foo_index, @@ -166,6 +169,7 @@ const manifest = { "./routes/deep_partial/injected.tsx": $deep_partial_injected, "./routes/deep_partial/update.tsx": $deep_partial_update, "./routes/duplicate_name/index.tsx": $duplicate_name_index, + "./routes/error_404.tsx": $error_404, "./routes/form/index.tsx": $form_index, "./routes/form/injected.tsx": $form_injected, "./routes/form/update.tsx": $form_update, diff --git a/tests/fixture_partials/routes/_404.tsx b/tests/fixture_partials/routes/_404.tsx new file mode 100644 index 00000000..c3857ef9 --- /dev/null +++ b/tests/fixture_partials/routes/_404.tsx @@ -0,0 +1,9 @@ +import { Partial } from "$fresh/runtime.ts"; + +export default function Page() { + return ( + +

Not found - Error 404

+
+ ); +} diff --git a/tests/fixture_partials/routes/error_404.tsx b/tests/fixture_partials/routes/error_404.tsx new file mode 100644 index 00000000..b58683db --- /dev/null +++ b/tests/fixture_partials/routes/error_404.tsx @@ -0,0 +1,19 @@ +import { Partial } from "$fresh/runtime.ts"; + +export default function ModeDemo() { + return ( +
+ +

default content

+
+

+ + update + +

+
+ ); +} diff --git a/tests/partials_test.ts b/tests/partials_test.ts index 63ae50b2..220fe21a 100644 --- a/tests/partials_test.ts +++ b/tests/partials_test.ts @@ -1509,3 +1509,16 @@ Deno.test("partials with redirects", async () => { }, ); }); + +Deno.test("render 404 partial", async () => { + await withPageName( + "./tests/fixture_partials/main.ts", + async (page, address) => { + await page.goto(`${address}/error_404`); + await page.waitForSelector(".status"); + + await page.click(".update-link"); + await page.waitForSelector(".status-404"); + }, + ); +});