refactor: migrate legacy wire namespace to wrn
This commit is contained in:
@@ -24,7 +24,7 @@ afterEach(() => {
|
||||
|
||||
test("action runtime exposes pending, optimistic, success, and invalidation state", async () => {
|
||||
const win = new Window({ url: "https://example.test/users" });
|
||||
win.document.cookie = "wire-csrf=token";
|
||||
win.document.cookie = "wrn-csrf=token";
|
||||
win.document.body.innerHTML = `<form data-wrn-action="createUser"><input name="name" value="Ada"></form>`;
|
||||
const phases: string[] = [];
|
||||
["optimistic", "pending", "success"].forEach((phase) =>
|
||||
|
||||
@@ -129,14 +129,14 @@ test("exposes programmatic navigation", async () => {
|
||||
test("rebinds theme controls after swapping the page", async () => {
|
||||
install(`<div id="app"><a href="/about" id="lnk">About</a></div>`);
|
||||
let boundRoot: unknown;
|
||||
win.wireTheme = { bind: (root: unknown) => (boundRoot = root) };
|
||||
nextHtml = `<html><body><div id="app"><button data-wire-theme-toggle>Theme</button></div></body></html>`;
|
||||
win.wrnTheme = { bind: (root: unknown) => (boundRoot = root) };
|
||||
nextHtml = `<html><body><div id="app"><button data-wrn-theme-toggle>Theme</button></div></body></html>`;
|
||||
|
||||
win.document.getElementById("lnk").click();
|
||||
await flush();
|
||||
|
||||
expect(boundRoot).toBe(win.document);
|
||||
expect(win.document.querySelector("[data-wire-theme-toggle]")).not.toBeNull();
|
||||
expect(win.document.querySelector("[data-wrn-theme-toggle]")).not.toBeNull();
|
||||
});
|
||||
|
||||
test("unmounts and remounts package runtimes during client navigation", async () => {
|
||||
|
||||
@@ -809,7 +809,7 @@ test("component server calls send the CSRF cookie in the RPC header", async () =
|
||||
);
|
||||
Object.defineProperty(win.document, "cookie", {
|
||||
configurable: true,
|
||||
value: "wire-csrf=rpc%20token",
|
||||
value: "wrn-csrf=rpc%20token",
|
||||
});
|
||||
let request: RequestInit | undefined;
|
||||
const globals = globalThis as Record<string, unknown>;
|
||||
@@ -837,7 +837,7 @@ test("component server calls prefer the rendered CSRF token over stale cookies",
|
||||
);
|
||||
Object.defineProperty(win.document, "cookie", {
|
||||
configurable: true,
|
||||
value: "wire-csrf=stale-token",
|
||||
value: "wrn-csrf=stale-token",
|
||||
});
|
||||
let request: RequestInit | undefined;
|
||||
const globals = globalThis as Record<string, unknown>;
|
||||
@@ -902,8 +902,8 @@ test("development runtime warns when a component binding names a missing functio
|
||||
test("development runtime warns for referenced theme tokens absent from rendered CSS", () => {
|
||||
const win = new Window() as unknown as Window & Record<string, unknown>;
|
||||
win.document.head.innerHTML =
|
||||
`<style>:root { --wire-present-test: red; } .probe { ` +
|
||||
`color: var(--wire-present-test); background: var(--wire-missing-test); }</style>`;
|
||||
`<style>:root { --wrn-present-test: red; } .probe { ` +
|
||||
`color: var(--wrn-present-test); background: var(--wrn-missing-test); }</style>`;
|
||||
win.document.body.innerHTML = `<div class="probe" data-scope=""></div>`;
|
||||
(globalThis as Record<string, unknown>).window = win;
|
||||
(globalThis as Record<string, unknown>).document = win.document;
|
||||
@@ -930,15 +930,15 @@ test("development runtime warns for referenced theme tokens absent from rendered
|
||||
}
|
||||
expect(warnings).toHaveLength(1);
|
||||
expect(String(warnings[0]?.[0])).toContain("WRN-DEV-THEME-TOKEN-MISSING");
|
||||
expect(String(warnings[0]?.[0])).toContain("--wire-missing-test");
|
||||
expect(String(warnings[0]?.[0])).toContain("--wrn-missing-test");
|
||||
});
|
||||
|
||||
test("development runtime accepts component-local and inline wire variables", () => {
|
||||
test("development runtime accepts component-local and inline wrn variables", () => {
|
||||
const win = new Window() as unknown as Window & Record<string, unknown>;
|
||||
win.document.head.innerHTML =
|
||||
`<style>.component { --wire-component-local: red; color: var(--wire-component-local); ` +
|
||||
`background: var(--wire-inline-local); }</style>`;
|
||||
win.document.body.innerHTML = `<div class="component" style="--wire-inline-local: blue" data-scope=""></div>`;
|
||||
`<style>.component { --wrn-component-local: red; color: var(--wrn-component-local); ` +
|
||||
`background: var(--wrn-inline-local); }</style>`;
|
||||
win.document.body.innerHTML = `<div class="component" style="--wrn-inline-local: blue" data-scope=""></div>`;
|
||||
(globalThis as Record<string, unknown>).window = win;
|
||||
(globalThis as Record<string, unknown>).document = win.document;
|
||||
(globalThis as Record<string, unknown>).location = win.location;
|
||||
@@ -1076,9 +1076,9 @@ test("toast() falls back to the console when no toaster is mounted", () => {
|
||||
test("toast is reachable as a real global for compiled client modules", () => {
|
||||
const win = mount(`<div data-scope=""></div>`) as unknown as Window & {
|
||||
toast?: unknown;
|
||||
wireToast?: unknown;
|
||||
wrnToast?: unknown;
|
||||
};
|
||||
expect(typeof win.wireToast).toBe("function");
|
||||
expect(typeof win.wrnToast).toBe("function");
|
||||
expect(typeof win.toast).toBe("function");
|
||||
});
|
||||
|
||||
|
||||
@@ -103,9 +103,9 @@ test("submitting [data-room-send] sends JSON and clears reset fields", () => {
|
||||
expect((inputs[1] as unknown as HTMLInputElement).value).toBe("");
|
||||
});
|
||||
|
||||
test("programmatic wire.room() sends and receives", () => {
|
||||
test("programmatic wrn.room() sends and receives", () => {
|
||||
const win = boot(`<div></div>`) as unknown as Window & {
|
||||
wire: {
|
||||
wrn: {
|
||||
room: (n: string) => {
|
||||
on: (t: string, cb: (m: unknown) => void) => unknown;
|
||||
send: (o: unknown) => void;
|
||||
@@ -113,7 +113,7 @@ test("programmatic wire.room() sends and receives", () => {
|
||||
};
|
||||
};
|
||||
const got: unknown[] = [];
|
||||
const room = win.wire.room("lobby");
|
||||
const room = win.wrn.room("lobby");
|
||||
room.on("ping", (m: unknown) => got.push(m));
|
||||
sockets[0]!.fireOpen();
|
||||
room.send({ type: "hello" });
|
||||
@@ -137,11 +137,11 @@ test("declarative room reconnects when its user identity changes", () => {
|
||||
const win = boot(
|
||||
`<div id="room" data-room="teamspace" data-room-user="asha"></div>`,
|
||||
) as unknown as Window & {
|
||||
wire: { bindRooms: (root?: unknown) => void };
|
||||
wrn: { bindRooms: (root?: unknown) => void };
|
||||
};
|
||||
expect(sockets[0]?.url).toBe("ws://localhost/realtime/teamspace?user=asha");
|
||||
win.document.getElementById("room")!.setAttribute("data-room-user", "neha");
|
||||
win.wire.bindRooms(win.document);
|
||||
win.wrn.bindRooms(win.document);
|
||||
expect(sockets[0]?.readyState).toBe(3);
|
||||
expect(sockets[1]?.url).toBe("ws://localhost/realtime/teamspace?user=neha");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user