fix(server): sanitize brackets from island names (#1723)

This commit is contained in:
Reed von Redwitz
2023-09-01 15:58:15 +02:00
committed by GitHub
parent 03df5f7306
commit 4a4af1f915
5 changed files with 121 additions and 46 deletions
+38
View File
@@ -2,8 +2,11 @@ import { assert } from "./deps.ts";
import {
assertNotSelector,
assertSelector,
clickWhenListenerReady,
fetchHtml,
waitForText,
withFresh,
withPageName,
} from "./test_utils.ts";
Deno.test("apply root _layout and _app", async () => {
@@ -160,3 +163,38 @@ Deno.test("route overrides layout and app", async () => {
},
);
});
Deno.test({
name: "island in dynamic route test",
async fn(t) {
await withPageName(
"./tests/fixture_layouts/main.ts",
async (page, address) => {
async function counterTest(counterId: string, originalValue: number) {
const pElem = await page.waitForSelector(`#${counterId} > p`);
const value = await pElem?.evaluate((el) => el.textContent);
assert(value === `${originalValue}`, `${counterId} first value`);
await clickWhenListenerReady(page, `#b-${counterId}`);
await waitForText(
page,
`#${counterId} > p`,
String(originalValue + 1),
);
}
await page.goto(`${address}/dynamic/acme-corp`, {
waitUntil: "networkidle2",
});
await t.step("Ensure 1 island on 1 page are revived", async () => {
await counterTest("counter", 3);
});
},
);
},
sanitizeOps: false,
sanitizeResources: false,
});