Skip to content

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

fix unit tests

erwanMarmelab331760e8ff9e
diff --git a/src/components/atomic-crm/contacts/ContactList.test.tsx b/src/components/atomic-crm/contacts/ContactList.test.tsx
index 886ac2a6..30b0a75c 100644
--- a/src/components/atomic-crm/contacts/ContactList.test.tsx
+++ b/src/components/atomic-crm/contacts/ContactList.test.tsx
@@ -203,7 +203,11 @@ describe("ContactList", () => {
describe("account manager filter on mobile", () => {
beforeAll(() => {
- page.viewport(375, 667);
+ // Under the `md` breakpoint, so ResponsiveFilters renders its sheet, but
+ // still wide enough for the desktop list itself: production serves
+ // <ContactListMobile> at phone widths, and this desktop list collapses its
+ // name column to 0px there.
+ page.viewport(700, 800);
});
it("picks an account manager from inside the filter sheet", async () => {
diff --git a/src/components/atomic-crm/dashboard/DashboardStepper.tsx b/src/components/atomic-crm/dashboard/DashboardStepper.tsx
index 5cedd1f4..1267e8e0 100644
--- a/src/components/atomic-crm/dashboard/DashboardStepper.tsx
+++ b/src/components/atomic-crm/dashboard/DashboardStepper.tsx
@@ -1,4 +1,4 @@
-import { Button } from "@/components/ui/button";
+import { Button, buttonVariants } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
import { Progress } from "@/components/ui/progress";
import { CheckCircle, Circle, Plus } from "lucide-react";
@@ -100,20 +100,15 @@ export const DashboardStepper = ({
{addContactLabel}
</Button>
) : (
- <Button
- className="w-fit"
- render={
- <Link
- to={createPath({
- resource: "contacts",
- type: "create",
- })}
- />
- }
- nativeButton={false}
+ <Link
+ to={createPath({
+ resource: "contacts",
+ type: "create",
+ })}
+ className={buttonVariants({ className: "w-fit" })}
>
{addContactLabel}
- </Button>
+ </Link>
)}
</div>
</div>
diff --git a/src/components/atomic-crm/dataImport/DataImportDialog.tsx b/src/components/atomic-crm/dataImport/DataImportDialog.tsx
index 20a56a5d..85900263 100644
--- a/src/components/atomic-crm/dataImport/DataImportDialog.tsx
+++ b/src/components/atomic-crm/dataImport/DataImportDialog.tsx
@@ -10,7 +10,7 @@ import {
} from "ra-core";
import { Link } from "react-router";
import { Alert, AlertDescription } from "@/components/ui/alert";
-import { Button } from "@/components/ui/button";
+import { Button, buttonVariants } from "@/components/ui/button";
import {
Dialog,
DialogContent,
@@ -205,19 +205,16 @@ export function DataImportDialog({
<Alert>
<AlertDescription className="flex flex-col gap-4">
{translate("crm.data_import.sample_hint")}
- <Button
- variant="outline"
- size="sm"
- render={
- <Link
- to={sampleUrl}
- download={sampleFileName(resource.name)}
- />
- }
- nativeButton={false}
+ <Link
+ to={sampleUrl}
+ download={sampleFileName(resource.name)}
+ className={buttonVariants({
+ variant: "outline",
+ size: "sm",
+ })}
>
{translate("crm.data_import.sample_download")}
- </Button>
+ </Link>
</AlertDescription>
</Alert>
diff --git a/vitest.config.ts b/vitest.config.ts
index ad82b93c..91ac60b4 100644
--- a/vitest.config.ts
+++ b/vitest.config.ts
@@ -35,6 +35,11 @@ export default defineConfig({
headless: true,
provider: playwright(),
enabled: true,
+ // Vitest defaults to 414px. Now that the stylesheet above is loaded,
+ // Tailwind's responsive classes actually apply, so that default would
+ // render the mobile branch of every desktop story. Mobile tests opt in
+ // explicitly with `page.viewport(375, 667)`.
+ viewport: { width: 1280, height: 800 },
instances: [
{
browser: "chromium",