Skip to content

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

Add e2e test for global search per-resource cap

fzaninotto68071ce58073
diff --git a/e2e/globalSearch.spec.ts b/e2e/globalSearch.spec.ts
new file mode 100644
index 00000000..40ae0bf2
--- /dev/null
+++ b/e2e/globalSearch.spec.ts
@@ -0,0 +1,44 @@
+import { expect, test } from "./fixtures";
+
+test.describe("global search", () => {
+ test.beforeEach(async ({ createSales, createContact }) => {
+ const sales = await createSales({
+ first_name: "John",
+ last_name: "Doe",
+ email: "[email protected]",
+ password: "password",
+ });
+
+ // The contact is created before its notes, so every note is newer
+ await createContact({
+ first_name: "Zebulon",
+ last_name: "Durand",
+ sales_id: sales.id,
+ notes: Array.from({ length: 12 }, (_, index) => ({
+ text: `Called Zebulon about the renewal (${index + 1})`,
+ })),
+ });
+ });
+
+ test("finds an old contact despite many newer notes mentioning them", async ({
+ page,
+ }) => {
+ await page.goto("/");
+ await page.getByLabel("Email").fill("[email protected]");
+ await page.getByLabel("Password").fill("password");
+ await page.getByRole("button", { name: "Sign in" }).click();
+ await expect(page.getByText("Latest Activity")).toBeVisible();
+
+ await page.getByRole("button", { name: "Search", exact: true }).click();
+ await page
+ .getByPlaceholder("Search contacts, companies, deals, tasks and notes...")
+ .fill("zebulon");
+
+ const contacts = page.getByRole("group", { name: "Contacts" });
+ await expect(contacts.getByRole("option")).toHaveCount(1);
+ await expect(contacts.getByRole("option")).toContainText("Zebulon Durand");
+
+ const notes = page.getByRole("group", { name: "Contact notes" });
+ await expect(notes.getByRole("option")).toHaveCount(10);
+ });
+});