diff --git a/tests/fixture/routes/islands/index.tsx b/tests/fixture/routes/islands/index.tsx index 9a818073..ab478293 100644 --- a/tests/fixture/routes/islands/index.tsx +++ b/tests/fixture/routes/islands/index.tsx @@ -1,12 +1,14 @@ /** @jsx h */ import { h } from "preact"; import Counter from "../../islands/Counter.tsx"; +import Test from "../../islands/Test.tsx"; export default function Home() { return (
+
); } diff --git a/tests/islands_test.ts b/tests/islands_test.ts index 6af7b6e7..461615e6 100644 --- a/tests/islands_test.ts +++ b/tests/islands_test.ts @@ -1,4 +1,10 @@ -import { assert, delay, puppeteer, TextLineStream } from "./deps.ts"; +import { + assert, + assertStringIncludes, + delay, + puppeteer, + TextLineStream, +} from "./deps.ts"; Deno.test({ name: "island tests", @@ -52,6 +58,20 @@ Deno.test({ await counterTest("counter2", 10); }); + await t.step("Ensure an island revive an img 'hash' path", async () => { + // Ensure src path has __frsh_c= + const pElem = await page.waitForSelector(`#img-in-island`); + const srcString = (await pElem?.getProperty("src"))?.toString()!; + assertStringIncludes(srcString, "image.png?__frsh_c="); + + // Ensure src path is the same as server rendered + const resp = await fetch(new Request("http://localhost:8000/islands")); + const body = await resp.text(); + const imgFilePath = body.match(/img id="img-in-island" src="(.*?)"/) + ?.[1]!; + assertStringIncludes(srcString, imgFilePath); + }); + await browser.close(); await lines.cancel();