A full-featured CRM built with React, shadcn/ui, and Supabase.
import { expect, test } from "./fixtures";
test.describe("admin filtering by account manager", () => {
test.beforeEach(async ({ createSales, createCompany, createContact }) => {
const admin = await createSales({
administrator: true,
email: "[email protected]",
first_name: "John",
last_name: "Doe",
password: "password",
});
const teammate = await createSales({
email: "[email protected]",
first_name: "Marie",
last_name: "Curie",
password: "password",
});
const company = await createCompany({
name: "Smith Corp",
salesId: admin.id,
});
await createContact({
company_id: company.id,
first_name: "Ada",
last_name: "Lovelace",
sales_id: admin.id,
title: "CTO",
});
await createContact({
company_id: company.id,
first_name: "Grace",
last_name: "Hopper",
sales_id: teammate.id,
title: "Rear Admiral",
});
});
test("admin narrows the contact list down to a teammate's contacts", async ({
page,
isMobile,
menu,
}) => {
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 menu.goToContacts();
await expect(page.getByText("Ada Lovelace")).toBeVisible();
await expect(page.getByText("Grace Hopper")).toBeVisible();
if (isMobile) {
await page.getByRole("button", { name: "Add filter" }).click();
}
await page.getByRole("button", { name: "Marie Curie" }).click();
if (isMobile) {
await page.getByRole("button", { name: "Confirm" }).click();
}
await expect(page.getByText("Grace Hopper")).toBeVisible();
await expect(page.getByText("Ada Lovelace")).toBeHidden();
if (isMobile) {
await page.getByRole("button", { name: "Add filter" }).click();
}
await page.getByRole("button", { name: "Marie Curie" }).click();
if (isMobile) {
await page.getByRole("button", { name: "Confirm" }).click();
}
await expect(page.getByText("Ada Lovelace")).toBeVisible();
await expect(page.getByText("Grace Hopper")).toBeVisible();
});
test("a non-admin user gets no account manager list", async ({
page,
isMobile,
menu,
}) => {
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 menu.goToContacts();
await expect(page.getByText("Grace Hopper")).toBeVisible();
if (isMobile) {
await page.getByRole("button", { name: "Add filter" }).click();
}
await expect(
page.getByRole("button", { name: "Me", exact: true }),
).toBeVisible();
await expect(page.getByRole("button", { name: "John Doe" })).toBeHidden();
});
});