fix: allow string based event handlers in SSR (#1515)
This commit is contained in:
+55
-1
@@ -5,11 +5,17 @@ import {
|
||||
assertStringIncludes,
|
||||
delay,
|
||||
puppeteer,
|
||||
retry,
|
||||
} from "./deps.ts";
|
||||
import manifest from "./fixture/fresh.gen.ts";
|
||||
import options from "./fixture/options.ts";
|
||||
import { BUILD_ID } from "../src/server/build_id.ts";
|
||||
import { parseHtml, startFreshServer, withPageName } from "./test_utils.ts";
|
||||
import {
|
||||
parseHtml,
|
||||
startFreshServer,
|
||||
waitForText,
|
||||
withPageName,
|
||||
} from "./test_utils.ts";
|
||||
import { assertMatch } from "https://deno.land/std@0.193.0/testing/asserts.ts";
|
||||
|
||||
const ctx = await ServerContext.fromManifest(manifest, options);
|
||||
@@ -945,3 +951,51 @@ Deno.test({
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "support string based event handlers during SSR",
|
||||
async fn() {
|
||||
await withPageName("./tests/fixture/main.ts", async (page, address) => {
|
||||
await page.goto(`${address}/event_handler_string`);
|
||||
await page.waitForSelector("p");
|
||||
await page.click("button");
|
||||
|
||||
await waitForText(page, "p", "it works");
|
||||
});
|
||||
},
|
||||
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "Log error in browser console on string event handlers",
|
||||
async fn() {
|
||||
await withPageName("./tests/fixture/main.ts", async (page, address) => {
|
||||
const logs: { type: string; message: string }[] = [];
|
||||
page.on("console", (ev) => {
|
||||
logs.push({ type: ev.type(), message: ev.text() });
|
||||
});
|
||||
|
||||
page.on("pageerror", (ev) => {
|
||||
logs.push({ type: "error", message: ev.toString() });
|
||||
});
|
||||
|
||||
await page.goto(`${address}/event_handler_string_island`);
|
||||
await page.waitForSelector("p");
|
||||
await page.click("button");
|
||||
await waitForText(page, "p", "it works");
|
||||
|
||||
await retry(() => {
|
||||
for (const item of logs) {
|
||||
if (/property should be a function/.test(item.message)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
sanitizeOps: false,
|
||||
sanitizeResources: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user