tests: ensure asset mapping works correctly in islands client side (#245)
This commit is contained in:
@@ -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 (
|
||||
<div>
|
||||
<Counter id="counter1" start={3} />
|
||||
<Counter id="counter2" start={10} />
|
||||
<Test message="" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
+21
-1
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user