diff --git a/app/src/components/ui/button.tsx b/app/src/components/ui/button.tsx index f71ec13d3..2b49c9e21 100644 --- a/app/src/components/ui/button.tsx +++ b/app/src/components/ui/button.tsx @@ -44,12 +44,32 @@ function Button({ className, variant = "default", size = "default", + render, + /* + * DIVERGES FROM UPSTREAM SHADCN. Base UI defaults `nativeButton` to `true`, which is right only + * while the element really is a `); + + expect(complaints).toEqual([]); + expect(element.tagName).toBe("BUTTON"); + expect(element.getAttribute("type")).toBe("button"); + expect(element.getAttribute("role")).toBeNull(); +}); + +test("a button drawn as a link takes button semantics rather than `type`", () => { + const { complaints, element } = drawing( + , + ); + + expect(complaints).toEqual([]); + expect(element.tagName).toBe("A"); + expect(element.getAttribute("role")).toBe("button"); + expect(element.getAttribute("type")).toBeNull(); +}); + +/** + * The shape `PageShell`'s back button and the sidebar's links use: a function, because a router + * `Link` takes its own props alongside the ones Base UI merges in. + */ +test("a button drawn as a link through the function form does the same", () => { + const { complaints, element } = drawing( + , + ); + + expect(complaints).toEqual([]); + expect(element.tagName).toBe("A"); + expect(element.getAttribute("role")).toBe("button"); +}); + +/** + * `render` that draws a real button is the case the default cannot see, so a call site says so — + * `combobox.tsx` is the one that does. + */ +test("a call site drawing a real button can say so", () => { + const { complaints, element } = drawing( + , + ); + + expect(complaints).toEqual([]); + expect(element.tagName).toBe("BUTTON"); + expect(element.getAttribute("role")).toBeNull(); +});