feat(server): multiple island exports (#1397)

This commit is contained in:
Reed von Redwitz
2023-07-03 09:59:38 +02:00
committed by GitHub
parent 16be99e69b
commit a3f7c212f4
9 changed files with 166 additions and 70 deletions
+35
View File
@@ -59,6 +59,41 @@ Deno.test({
sanitizeResources: false,
});
Deno.test({
name: "multiple islands exported from one file",
async fn(t) {
await withPage(async (page, address) => {
async function counterTest(counterId: string, originalValue: number) {
const pElem = await page.waitForSelector(`#${counterId} > p`);
let value = await pElem?.evaluate((el) => el.textContent);
assert(value === `${originalValue}`, `${counterId} first value`);
const buttonPlus = await page.$(`#b-${counterId}`);
await buttonPlus?.click();
await delay(100);
value = await pElem?.evaluate((el) => el.textContent);
assert(value === `${originalValue + 1}`, `${counterId} click`);
}
await page.goto(`${address}/islands/multiple_island_exports`, {
waitUntil: "networkidle2",
});
await t.step("Ensure 3 islands on 1 page are revived", async () => {
await counterTest("counter0", 4);
await counterTest("counter1", 3);
await counterTest("counter2", 10);
});
});
},
sanitizeOps: false,
sanitizeResources: false,
});
function withPage(fn: (page: Page, address: string) => Promise<void>) {
return withPageName("./tests/fixture/main.ts", fn);
}