Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

fix tests

erwanMarmelab7313134983be
diff --git a/src/components/atomic-crm/search/GlobalSearchDialog.test.tsx b/src/components/atomic-crm/search/GlobalSearchDialog.test.tsx
index 15669afd..e680a702 100644
--- a/src/components/atomic-crm/search/GlobalSearchDialog.test.tsx
+++ b/src/components/atomic-crm/search/GlobalSearchDialog.test.tsx
@@ -27,14 +27,25 @@ const data = {
],
} as any;
-const renderDialog = () =>
+const renderDialog = (open = true) =>
render(
<StoryWrapper data={data}>
- <GlobalSearchDialog open onOpenChange={() => {}} />
+ <GlobalSearchDialog open={open} onOpenChange={() => {}} />
</StoryWrapper>,
);
describe("GlobalSearchDialog", () => {
+ it("puts nothing in the document while closed", async () => {
+ const screen = await renderDialog(false);
+
+ // The dialog's accessible description mentions every searchable resource,
+ // so leaking it into a closed dialog breaks text queries app-wide.
+ await expect.element(screen.getByText(PLACEHOLDER)).not.toBeInTheDocument();
+ await expect
+ .element(screen.getByPlaceholder(PLACEHOLDER))
+ .not.toBeInTheDocument();
+ });
+
it("asks for a longer query before searching", async () => {
const screen = await renderDialog();
diff --git a/src/components/ui/command.tsx b/src/components/ui/command.tsx
index 066c9fad..4310486e 100644
--- a/src/components/ui/command.tsx
+++ b/src/components/ui/command.tsx
@@ -40,11 +40,11 @@ function CommandDialog({
}) {
return (
<Dialog {...props}>
- <DialogHeader className="sr-only">
- <DialogTitle>{title}</DialogTitle>
- <DialogDescription>{description}</DialogDescription>
- </DialogHeader>
<DialogContent className="overflow-hidden p-0">
+ <DialogHeader className="sr-only">
+ <DialogTitle>{title}</DialogTitle>
+ <DialogDescription>{description}</DialogDescription>
+ </DialogHeader>
<Command
shouldFilter={shouldFilter}
className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5"