Merge pull request 'fix: label the lead's own company on the Leads list' (#47) from fix-lead-company-label into main
CI / build-and-publish (push) Failing after 1s

This commit was merged in pull request #47.
This commit is contained in:
ngqile committed 2026-12-02 03:03:51 +00:00
commit 085bcafe63
3 files changed
+25 -1

No files matched your search

@@ -0,0 +1,23 @@
import { render, screen } from "@testing-library/react";
import { describe, it, expect, vi } from "vitest";
vi.mock("@/app/lib/services/adminLeads", async (importActual) => ({
...(await importActual<typeof import("@/app/lib/services/adminLeads")>()),
listLeads: vi.fn().mockResolvedValue({ items: [], total: 0 }),
}));
vi.mock("@/app/lib/AdminAuthContext", () => ({ useAdminAuth: () => ({ loading: false, hasModule: () => true }) }));
vi.mock("@/app/lib/CompanyScope", () => ({
useCompanyScope: () => ({ companyId: null, showCompanyColumn: true, codeOf: () => "INS" }),
}));
vi.mock("next/navigation", async () => (await import("@/test/memoryRouter")).navigationMock);
import LeadsPage from "./page";
describe("LeadsPage columns", () => {
it("tells the tenant company from the lead's own company", async () => {
render(<LeadsPage />);
const headers = (await screen.findAllByRole("columnheader")).map((h) => h.textContent);
expect(headers).toContain("Company");
expect(headers).toContain("Lead's company");
});
});
+1 -1
View File
@@ -79,7 +79,7 @@ function LeadsPageContent() {
...(showCompanyColumn ? [{ id: "company", cell: ({ row }) => codeOf(row.original.companyId ?? 0), header: t("Company"), enableSorting: false } as ColumnDef<LeadRow, unknown>] : []),
{ accessorKey: "mobile", header: t("LeadMobile"), enableSorting: false },
{ accessorKey: "email", header: t("Email"), enableSorting: false },
{ accessorKey: "companyName", header: t("LeadCompany"), enableSorting: false },
{ accessorKey: "companyName", header: t("LeadsLeadCompany"), enableSorting: false },
{ accessorKey: "eventCount", header: t("LeadsEvents"), enableSorting: false },
{ id: "lastEvent", header: t("LeadsLastEvent"), enableSorting: false, cell: ({ row }) => row.original.lastEvent?.name ?? "" },
{ id: "latestSalesperson", header: t("LeadsLatestSalesperson"), enableSorting: false, cell: ({ row }) => row.original.latestSalesperson?.name ?? "" },
@@ -366,6 +366,7 @@ export const DEFAULT_MESSAGES: Record<string, string> = {
LeadNew: "New",
LeadExisting: "Existing",
LeadCompany: "Company",
LeadsLeadCompany: "Lead's company",
LeadJobTitle: "Job title",
LeadStatus: "Status",
LeadNotes: "Notes",