import { describe, it, expect, afterEach } from "vitest"; import { renderHydrationRoundTrip, type HydrationRoundTripResult, } from "../../../scripts/test-utils/hydration-harness.ts"; // A client-side owner created in the factory needs a matching server owner, or the hydration // ids of everything after it shift and later elements miss their server-rendered twins. const app = (imports: string, setup: string, tag: string) => ` import { createUniqueId } from "solid-js"; ${imports} export default function App() { ${setup} const id = createUniqueId(); return (
<${tag} id="a" ref={ref}>box {id}
); } `; let result: HydrationRoundTripResult | undefined; afterEach(() => { result?.cleanup(); result = undefined; }); async function expectAligned(source: string) { result = await renderHydrationRoundTrip(source, import.meta.dirname); const serverId = /id="uid">([^<]*) { it("keeps hydration ids aligned for later siblings", () => expectAligned( app( `import { cursorRef } from "@solid-primitives/cursor";`, `const ref = cursorRef("pointer");`, "span", ), )); });