feat: add InputGroup and verify shared field integration

This commit is contained in:
maoyingjie
2026-10-21 22:56:18 +08:00
parent 7f11afeaa6
commit 37e11e6330
48 changed files with 2374 additions and 6 deletions
+39
View File
@@ -71,3 +71,42 @@ it("renders complete field associations without browser globals", async () => {
for (const id of refs) expect(ids).toContain(id);
expect(html).toContain('value="a@example.com"');
});
it("associates labels with explicit grouped control IDs on the server", async () => {
const {
TextField,
Label,
InputGroup,
InputGroupInput,
InputGroupTextArea,
Description,
} = await import("../packages/vue/src");
const html = await renderToString(
createSSRApp({
render: () =>
h("div", {}, [
h(TextField, {}, () => [
h(Label, {}, () => "Email"),
h(InputGroup, {}, () => [
h(InputGroupInput, { id: "grouped-email" }),
]),
h(Description, {}, () => "Hint"),
]),
h(TextField, {}, () => [
h(Label, {}, () => "Notes"),
h(InputGroup, {}, () => [
h(InputGroupTextArea, { id: "grouped-notes" }),
]),
]),
]),
}),
);
expect(html).toContain('for="grouped-email"');
expect(html).toContain('for="grouped-notes"');
const ids = [...html.matchAll(/\sid="([^"]+)"/g)].map((m) => m[1]);
const refs = [
...html.matchAll(/(?:for|aria-describedby)="([^"]+)"/g),
].flatMap((m) => m[1].split(" "));
expect(new Set(ids).size).toBe(ids.length);
for (const id of refs) expect(ids).toContain(id);
});