feat: migrate Modal Popover and Tooltip with shared overlay foundation
This commit is contained in:
@@ -346,3 +346,89 @@ it("renders disclosure group and accordion without browser globals", async () =>
|
||||
expect(html).toContain(`id="${id}"`);
|
||||
}
|
||||
});
|
||||
|
||||
it("renders overlay state and closed/open roots without accessing browser globals", async () => {
|
||||
const { useOverlayState, ConfigProvider } =
|
||||
await import("../packages/vue/src");
|
||||
const { default: OverlayDialogRoot } =
|
||||
await import("../packages/vue/src/components/overlay/OverlayDialogRoot.vue");
|
||||
const { default: OverlayPortal } =
|
||||
await import("../packages/vue/src/components/overlay/OverlayPortal.vue");
|
||||
const { default: OverlayDialogContent } =
|
||||
await import("../packages/vue/src/components/overlay/OverlayDialogContent.vue");
|
||||
const { DialogTrigger, DialogTitle, DialogDescription } =
|
||||
await import("../packages/vue/src/components/overlay/primitives");
|
||||
for (const initiallyOpen of [false, true]) {
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
setup() {
|
||||
const state = useOverlayState({ defaultOpen: initiallyOpen });
|
||||
return () =>
|
||||
h(
|
||||
ConfigProvider,
|
||||
{ dir: "rtl", locale: "ar", teleportTo: "#portals" },
|
||||
() =>
|
||||
h(OverlayDialogRoot, { state }, () => [
|
||||
h(DialogTrigger, {}, () => "Open"),
|
||||
h(OverlayPortal, {}, () =>
|
||||
h(OverlayDialogContent, {}, () => [
|
||||
h(DialogTitle, {}, () => "Title"),
|
||||
h(DialogDescription, {}, () => "Hint"),
|
||||
]),
|
||||
),
|
||||
]),
|
||||
);
|
||||
},
|
||||
}),
|
||||
);
|
||||
expect(html).toContain(`aria-expanded="${initiallyOpen}"`);
|
||||
expect(html).not.toContain('role="dialog"'); // Portals deliberately render after client mount.
|
||||
}
|
||||
});
|
||||
|
||||
it("renders public Modal Popover and Tooltip roots without browser globals", async () => {
|
||||
const {
|
||||
Modal,
|
||||
ModalBackdrop,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalHeading,
|
||||
Popover,
|
||||
PopoverContent,
|
||||
PopoverDialog,
|
||||
PopoverHeading,
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
} = await import("../packages/vue/src");
|
||||
const html = await renderToString(
|
||||
createSSRApp({
|
||||
render: () =>
|
||||
h("div", {}, [
|
||||
h(Modal, { defaultOpen: true }, () => [
|
||||
h(Button, {}, () => "Modal"),
|
||||
h(ModalBackdrop, {}, () =>
|
||||
h(ModalContainer, {}, () =>
|
||||
h(ModalDialog, {}, () => h(ModalHeading, {}, () => "Heading")),
|
||||
),
|
||||
),
|
||||
]),
|
||||
h(Popover, { defaultOpen: true }, () => [
|
||||
h(Button, {}, () => "Popover"),
|
||||
h(PopoverContent, {}, () =>
|
||||
h(PopoverDialog, {}, () =>
|
||||
h(PopoverHeading, {}, () => "Heading"),
|
||||
),
|
||||
),
|
||||
]),
|
||||
h(Tooltip, { defaultOpen: true }, () => [
|
||||
h(Button, {}, () => "Tooltip"),
|
||||
h(TooltipContent, {}, () => "Hint"),
|
||||
]),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('aria-expanded="true"');
|
||||
expect(html).toContain("aria-describedby=");
|
||||
expect(html).not.toContain('role="dialog"');
|
||||
expect(html).not.toContain('role="tooltip"');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user