fix: resolve RPC component from hydration boundary
Quality / quality (ubuntu-latest) (push) Failing after 9m44s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-12 19:17:58 +05:30
parent 7ba7c8a73f
commit fe9bb9ede0
6 changed files with 35 additions and 7 deletions
+23
View File
@@ -828,6 +828,29 @@ test("component server calls send the CSRF cookie in the RPC header", async () =
expect(new Headers(request?.headers).get("x-csrf-token")).toBe("rpc token");
});
test("component server calls use the nearest hydration component identity", async () => {
const win = mount(
`<div data-scope="" data-wrn-hydration="CButton:abc123">` +
`<div data-wrn-events="click"><button data-on-click="server.handleClick()">go</button></div>` +
`</div>`,
);
let payload: { component?: string } | undefined;
const globals = globalThis as Record<string, unknown>;
const originalFetch = globals.fetch;
globals.fetch = async (_input: RequestInfo | URL, init?: RequestInit) => {
payload = JSON.parse(String(init?.body));
return Response.json({ ok: true });
};
try {
(win.document.querySelector("button") as unknown as HTMLElement).click();
await new Promise((resolve) => setTimeout(resolve, 0));
} finally {
globals.fetch = originalFetch;
}
expect(payload?.component).toBe("CButton");
});
test("component server calls prefer the rendered CSRF token over stale cookies", async () => {
const win = mount(
`<meta name="wrnexus-csrf" content="current-token">` +