feat: add InputGroup and verify shared field integration
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user