2026-07-23 15:23:03 -03:00
|
|
|
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
|
|
import { API_PATHS } from "@/api/api-paths";
|
|
|
|
|
|
|
|
|
|
|
|
const apiGet = vi.fn();
|
|
|
|
|
|
const apiPost = vi.fn();
|
|
|
|
|
|
const apiPut = vi.fn();
|
2026-07-23 17:36:21 -03:00
|
|
|
|
const apiDelete = vi.fn();
|
2026-07-23 15:23:03 -03:00
|
|
|
|
|
|
|
|
|
|
vi.mock("@/api/api", () => ({
|
|
|
|
|
|
apiGet: (...args: unknown[]) => apiGet(...args),
|
|
|
|
|
|
apiPost: (...args: unknown[]) => apiPost(...args),
|
|
|
|
|
|
apiPut: (...args: unknown[]) => apiPut(...args),
|
2026-07-23 17:36:21 -03:00
|
|
|
|
apiDelete: (...args: unknown[]) => apiDelete(...args),
|
2026-07-23 15:23:03 -03:00
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
import { vendorsApi } from "@/domain/vendors/api/vendors-api";
|
|
|
|
|
|
|
|
|
|
|
|
describe("vendorsApi.getList", () => {
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
|
apiGet.mockReset();
|
|
|
|
|
|
apiPost.mockReset();
|
|
|
|
|
|
apiPut.mockReset();
|
2026-07-23 17:36:21 -03:00
|
|
|
|
apiDelete.mockReset();
|
2026-07-23 15:23:03 -03:00
|
|
|
|
apiGet.mockResolvedValue({
|
|
|
|
|
|
Data: [
|
|
|
|
|
|
{
|
|
|
|
|
|
Id: 7,
|
2026-07-23 17:36:21 -03:00
|
|
|
|
CompanyId: "co-1",
|
2026-07-23 15:23:03 -03:00
|
|
|
|
CompanyName: "Gateway Plumbing",
|
|
|
|
|
|
ContactName: "Adam Whyte",
|
2026-09-14 13:07:00 -03:00
|
|
|
|
Email: "dispatch@gateway.test",
|
|
|
|
|
|
Phone: "314-555-0198",
|
2026-08-25 21:03:18 -03:00
|
|
|
|
Address: "1 Market St",
|
2026-07-23 15:23:03 -03:00
|
|
|
|
City: "St. Louis",
|
|
|
|
|
|
State: "MO",
|
|
|
|
|
|
IsActive: false,
|
2026-07-23 17:36:21 -03:00
|
|
|
|
PreferredContact: "Email",
|
2026-09-14 13:07:00 -03:00
|
|
|
|
Technicians: [
|
|
|
|
|
|
{
|
|
|
|
|
|
Id: 7,
|
|
|
|
|
|
ContactName: "Adam Whyte",
|
|
|
|
|
|
Email: "adam@gateway.test",
|
|
|
|
|
|
Phone: "314-555-0198",
|
|
|
|
|
|
TradeSpecialties: "Plumbing",
|
|
|
|
|
|
IsActive: false,
|
|
|
|
|
|
TotalJobs: 3,
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
2026-07-23 15:23:03 -03:00
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
TotalCount: 1,
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("forwards the status filter and maps list location fields", async () => {
|
|
|
|
|
|
const result = await vendorsApi.getList({ search: "gateway", isActive: false, page: 1 });
|
|
|
|
|
|
|
|
|
|
|
|
expect(apiGet).toHaveBeenCalledWith(API_PATHS.vendor.getList, {
|
|
|
|
|
|
searchParams: { search: "gateway", isActive: "false", page: 1, pageSize: 12 },
|
|
|
|
|
|
});
|
2026-07-23 17:36:21 -03:00
|
|
|
|
expect(result.items[0]).toMatchObject({
|
2026-08-25 21:03:18 -03:00
|
|
|
|
address: "1 Market St",
|
2026-07-23 17:36:21 -03:00
|
|
|
|
city: "St. Louis",
|
|
|
|
|
|
state: "MO",
|
|
|
|
|
|
isActive: false,
|
|
|
|
|
|
companyId: "co-1",
|
|
|
|
|
|
preferredContact: "Email",
|
2026-09-14 13:07:00 -03:00
|
|
|
|
technicians: [
|
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
|
id: 7,
|
|
|
|
|
|
email: "adam@gateway.test",
|
|
|
|
|
|
phone: "314-555-0198",
|
|
|
|
|
|
totalJobs: 3,
|
|
|
|
|
|
}),
|
|
|
|
|
|
],
|
2026-07-23 17:36:21 -03:00
|
|
|
|
});
|
2026-07-23 15:23:03 -03:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-09-14 13:07:00 -03:00
|
|
|
|
it("synthesizes one technician for a legacy ungrouped response", async () => {
|
|
|
|
|
|
apiGet.mockResolvedValueOnce({
|
|
|
|
|
|
Data: [
|
|
|
|
|
|
{
|
|
|
|
|
|
Id: 9,
|
|
|
|
|
|
CompanyName: "Legacy Co",
|
|
|
|
|
|
ContactName: "Legacy Tech",
|
|
|
|
|
|
Email: "legacy@example.test",
|
|
|
|
|
|
Phone: "555-0109",
|
|
|
|
|
|
IsActive: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
TotalCount: 1,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const result = await vendorsApi.getList();
|
|
|
|
|
|
|
|
|
|
|
|
expect(result.items[0]?.technicians).toEqual([
|
|
|
|
|
|
expect.objectContaining({ id: 9, contactName: "Legacy Tech", phone: "555-0109" }),
|
|
|
|
|
|
]);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-07-23 15:23:03 -03:00
|
|
|
|
it("forwards all selected facets as repeated indexed query parameters", async () => {
|
|
|
|
|
|
await vendorsApi.getList({
|
|
|
|
|
|
companies: ["Gateway Plumbing", "Metro HVAC"],
|
|
|
|
|
|
trades: ["Plumbing"],
|
|
|
|
|
|
locations: ["St. Louis, MO"],
|
|
|
|
|
|
jobBuckets: ["50-99"],
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
expect(apiGet).toHaveBeenCalledWith(API_PATHS.vendor.getList, {
|
|
|
|
|
|
searchParams: {
|
|
|
|
|
|
search: "",
|
|
|
|
|
|
page: 1,
|
|
|
|
|
|
pageSize: 12,
|
|
|
|
|
|
"companies[0]": "Gateway Plumbing",
|
|
|
|
|
|
"companies[1]": "Metro HVAC",
|
|
|
|
|
|
"trades[0]": "Plumbing",
|
|
|
|
|
|
"locations[0]": "St. Louis, MO",
|
|
|
|
|
|
"jobBuckets[0]": "50-99",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("maps company profiles and labels returned by the facets endpoint", async () => {
|
|
|
|
|
|
apiGet.mockResolvedValueOnce({
|
|
|
|
|
|
data: {
|
|
|
|
|
|
companies: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "Gateway Plumbing",
|
|
|
|
|
|
companyPhone: "314-555-0100",
|
|
|
|
|
|
email: "dispatch@gateway.test",
|
|
|
|
|
|
address: "1 Market St",
|
|
|
|
|
|
city: "St. Louis",
|
|
|
|
|
|
state: "MO",
|
|
|
|
|
|
zip: "63101",
|
|
|
|
|
|
googleMapsUrl: "https://maps.google.com/gateway",
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
trades: ["Plumbing"],
|
|
|
|
|
|
locations: [{ city: "St. Louis", state: "MO" }],
|
|
|
|
|
|
jobBuckets: [{ id: "50-99", label: "50–99" }],
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const facets = await vendorsApi.getFacets();
|
|
|
|
|
|
|
|
|
|
|
|
expect(apiGet).toHaveBeenCalledWith(API_PATHS.vendor.facets, { searchParams: {} });
|
|
|
|
|
|
expect(facets.companies[0]).toMatchObject({
|
|
|
|
|
|
name: "Gateway Plumbing",
|
2026-07-23 19:17:14 -03:00
|
|
|
|
companyPhone: "314-555-0100",
|
2026-07-23 15:23:03 -03:00
|
|
|
|
googleMapsUrl: "https://maps.google.com/gateway",
|
|
|
|
|
|
});
|
|
|
|
|
|
expect(facets.locations[0]?.label).toBe("St. Louis, MO");
|
|
|
|
|
|
expect(facets.jobBuckets[0]).toEqual({ id: "50-99", label: "50–99" });
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("serializes the requested facet scope as an isActive query parameter", async () => {
|
|
|
|
|
|
apiGet.mockResolvedValue({
|
|
|
|
|
|
data: { companies: [], trades: [], locations: [], jobBuckets: [] },
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
await vendorsApi.getFacets({ isActive: true });
|
|
|
|
|
|
await vendorsApi.getFacets({ isActive: false });
|
|
|
|
|
|
|
|
|
|
|
|
expect(apiGet).toHaveBeenNthCalledWith(1, API_PATHS.vendor.facets, {
|
|
|
|
|
|
searchParams: { isActive: "true" },
|
|
|
|
|
|
});
|
|
|
|
|
|
expect(apiGet).toHaveBeenNthCalledWith(2, API_PATHS.vendor.facets, {
|
|
|
|
|
|
searchParams: { isActive: "false" },
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("sends all editable prototype fields when creating and updating", async () => {
|
|
|
|
|
|
const values = {
|
2026-07-23 19:17:14 -03:00
|
|
|
|
companyId: "42",
|
2026-07-23 15:23:03 -03:00
|
|
|
|
companyName: "Gateway Plumbing",
|
|
|
|
|
|
contactName: "Adam Whyte",
|
2026-07-23 19:17:14 -03:00
|
|
|
|
phone: "+1 314-555-0198",
|
2026-07-23 15:23:03 -03:00
|
|
|
|
companyPhone: "314-555-0100",
|
|
|
|
|
|
email: "dispatch@gateway.test",
|
|
|
|
|
|
address: "1 Market St",
|
|
|
|
|
|
city: "St. Louis",
|
|
|
|
|
|
state: "MO",
|
|
|
|
|
|
zip: "63101",
|
|
|
|
|
|
tradeSpecialties: "Plumbing, HVAC",
|
|
|
|
|
|
googleMapsUrl: "https://maps.google.com/gateway",
|
|
|
|
|
|
notes: "Preferred after-hours vendor",
|
|
|
|
|
|
totalJobs: 72,
|
|
|
|
|
|
isActive: true,
|
|
|
|
|
|
};
|
|
|
|
|
|
apiPost.mockResolvedValueOnce({ data: values });
|
|
|
|
|
|
apiPut.mockResolvedValueOnce({ data: { ...values, isActive: false } });
|
|
|
|
|
|
|
|
|
|
|
|
await vendorsApi.create(values);
|
|
|
|
|
|
await vendorsApi.update(7, { ...values, isActive: false });
|
|
|
|
|
|
|
|
|
|
|
|
expect(apiPost).toHaveBeenCalledWith(
|
|
|
|
|
|
API_PATHS.rest.vendors,
|
2026-07-23 17:36:21 -03:00
|
|
|
|
expect.objectContaining({
|
|
|
|
|
|
companyName: "Gateway Plumbing",
|
|
|
|
|
|
notes: values.notes,
|
2026-07-23 19:17:14 -03:00
|
|
|
|
companyId: 42,
|
2026-07-23 17:36:21 -03:00
|
|
|
|
phone: "(314) 555-0198",
|
|
|
|
|
|
companyPhone: "(314) 555-0100",
|
|
|
|
|
|
}),
|
2026-07-23 15:23:03 -03:00
|
|
|
|
);
|
2026-08-03 17:53:39 -03:00
|
|
|
|
expect(apiPost.mock.calls[0]?.[1]).not.toHaveProperty("preferredContact");
|
2026-07-23 15:23:03 -03:00
|
|
|
|
expect(apiPut).toHaveBeenCalledWith(
|
|
|
|
|
|
`${API_PATHS.rest.vendors}/7`,
|
|
|
|
|
|
expect.objectContaining({ companyName: "Gateway Plumbing", isActive: false }),
|
|
|
|
|
|
);
|
2026-08-03 17:53:39 -03:00
|
|
|
|
expect(apiPut.mock.calls[0]?.[1]).not.toHaveProperty("preferredContact");
|
2026-07-23 15:23:03 -03:00
|
|
|
|
expect(apiPost.mock.calls[0]?.[1]).not.toHaveProperty("totalJobs");
|
|
|
|
|
|
expect(apiPut.mock.calls[0]?.[1]).not.toHaveProperty("totalJobs");
|
|
|
|
|
|
});
|
2026-07-23 17:36:21 -03:00
|
|
|
|
|
|
|
|
|
|
it("sends a null companyId when free-text company has no company link", async () => {
|
|
|
|
|
|
apiPost.mockResolvedValueOnce({ data: {} });
|
|
|
|
|
|
await vendorsApi.create({
|
|
|
|
|
|
companyName: "Independent Vendor LLC",
|
|
|
|
|
|
contactName: "Indy Tech",
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
expect(apiPost).toHaveBeenCalledWith(
|
|
|
|
|
|
API_PATHS.rest.vendors,
|
|
|
|
|
|
expect.objectContaining({ companyName: "Independent Vendor LLC", companyId: null }),
|
|
|
|
|
|
);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-07-23 19:17:14 -03:00
|
|
|
|
it("does not send a non-numeric company id to the integer backend contract", async () => {
|
|
|
|
|
|
apiPost.mockResolvedValueOnce({ data: {} });
|
|
|
|
|
|
|
|
|
|
|
|
await vendorsApi.create({
|
|
|
|
|
|
companyId: "co-1",
|
|
|
|
|
|
companyName: "Gateway Plumbing",
|
|
|
|
|
|
contactName: "Adam Whyte",
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
expect(apiPost).toHaveBeenCalledWith(
|
|
|
|
|
|
API_PATHS.rest.vendors,
|
|
|
|
|
|
expect.objectContaining({ companyId: null }),
|
|
|
|
|
|
);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-07-28 17:15:42 -03:00
|
|
|
|
it("preserves a legacy phone on read and omits it from an unrelated update", async () => {
|
2026-07-23 19:17:14 -03:00
|
|
|
|
apiGet.mockResolvedValueOnce({
|
|
|
|
|
|
data: {
|
|
|
|
|
|
id: 7,
|
|
|
|
|
|
companyName: "Legacy Vendor",
|
|
|
|
|
|
contactName: "Taylor",
|
|
|
|
|
|
phone: "555-1234 ext 9",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
apiPut.mockResolvedValueOnce({ data: {} });
|
|
|
|
|
|
|
|
|
|
|
|
const vendor = await vendorsApi.getById(7);
|
|
|
|
|
|
expect(vendor.phone).toBe("555-1234 ext 9");
|
|
|
|
|
|
|
2026-07-28 17:15:42 -03:00
|
|
|
|
await vendorsApi.update(7, { notes: "Updated only the notes" });
|
|
|
|
|
|
expect(apiPut).toHaveBeenCalledWith(`${API_PATHS.rest.vendors}/7`, {
|
|
|
|
|
|
notes: "Updated only the notes",
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("sends only changed fields and canonicalizes a supplied phone", async () => {
|
|
|
|
|
|
apiPut.mockResolvedValueOnce({ data: {} });
|
|
|
|
|
|
|
|
|
|
|
|
await vendorsApi.update(7, {
|
|
|
|
|
|
isActive: false,
|
|
|
|
|
|
companyId: null,
|
|
|
|
|
|
phone: "314-555-0198",
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
expect(apiPut).toHaveBeenCalledWith(`${API_PATHS.rest.vendors}/7`, {
|
|
|
|
|
|
isActive: false,
|
|
|
|
|
|
companyId: null,
|
|
|
|
|
|
phone: "(314) 555-0198",
|
|
|
|
|
|
});
|
2026-07-23 19:17:14 -03:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-07-23 17:36:21 -03:00
|
|
|
|
it("maps the deactivation-impact payload including linked work orders", async () => {
|
|
|
|
|
|
apiGet.mockResolvedValueOnce({
|
|
|
|
|
|
data: {
|
|
|
|
|
|
vendorId: 7,
|
|
|
|
|
|
canDeactivate: false,
|
|
|
|
|
|
openWorkOrders: [
|
|
|
|
|
|
{
|
|
|
|
|
|
workOrderId: 101,
|
|
|
|
|
|
workOrderNumber: "WO-101",
|
|
|
|
|
|
workOrderTitle: "Boiler repair",
|
|
|
|
|
|
status: "Dispatched",
|
|
|
|
|
|
scheduledDate: "2025-01-02",
|
|
|
|
|
|
dispatchId: 501,
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const impact = await vendorsApi.getDeactivationImpact(7);
|
|
|
|
|
|
|
|
|
|
|
|
expect(apiGet).toHaveBeenCalledWith(
|
|
|
|
|
|
`${API_PATHS.rest.vendors}/7/${API_PATHS.vendor.deactivationImpact}`,
|
|
|
|
|
|
);
|
|
|
|
|
|
expect(impact).toEqual({
|
|
|
|
|
|
vendorId: 7,
|
|
|
|
|
|
canDeactivate: false,
|
|
|
|
|
|
openWorkOrders: [
|
|
|
|
|
|
{
|
|
|
|
|
|
workOrderId: 101,
|
|
|
|
|
|
workOrderNumber: "WO-101",
|
|
|
|
|
|
workOrderTitle: "Boiler repair",
|
|
|
|
|
|
status: "Dispatched",
|
|
|
|
|
|
scheduledDate: "2025-01-02",
|
|
|
|
|
|
dispatchId: 501,
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("deletes a vendor by id and surfaces the 409 error without retry swallowing", async () => {
|
|
|
|
|
|
apiDelete.mockResolvedValueOnce(undefined);
|
|
|
|
|
|
await vendorsApi.delete(7);
|
|
|
|
|
|
expect(apiDelete).toHaveBeenCalledWith(`${API_PATHS.rest.vendors}/7`);
|
|
|
|
|
|
|
|
|
|
|
|
const conflict = Object.assign(new Error("Conflict"), { response: { status: 409 } });
|
|
|
|
|
|
apiDelete.mockRejectedValueOnce(conflict);
|
|
|
|
|
|
await expect(vendorsApi.delete(8)).rejects.toThrow("Conflict");
|
|
|
|
|
|
});
|
2026-07-23 15:23:03 -03:00
|
|
|
|
});
|
2026-09-14 15:24:55 -03:00
|
|
|
|
|
|
|
|
|
|
describe("vendorsApi.getDirectoryList", () => {
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
|
apiGet.mockReset();
|
|
|
|
|
|
apiGet.mockResolvedValue({
|
|
|
|
|
|
Data: [
|
|
|
|
|
|
{
|
|
|
|
|
|
Id: 7,
|
|
|
|
|
|
CompanyId: "co-1",
|
|
|
|
|
|
CompanyName: "Gateway Plumbing",
|
|
|
|
|
|
ContactName: "Adam Whyte",
|
|
|
|
|
|
Email: "dispatch@gateway.test",
|
|
|
|
|
|
Phone: "314-555-0198",
|
|
|
|
|
|
Address: "1 Market St",
|
|
|
|
|
|
City: "St. Louis",
|
|
|
|
|
|
State: "MO",
|
|
|
|
|
|
IsActive: false,
|
|
|
|
|
|
PreferredContact: "Email",
|
|
|
|
|
|
Technicians: [
|
|
|
|
|
|
{
|
|
|
|
|
|
Id: 7,
|
|
|
|
|
|
ContactName: "Adam Whyte",
|
|
|
|
|
|
Email: "adam@gateway.test",
|
|
|
|
|
|
Phone: "314-555-0198",
|
|
|
|
|
|
TradeSpecialties: "Plumbing",
|
|
|
|
|
|
IsActive: false,
|
|
|
|
|
|
TotalJobs: 3,
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
TotalCount: 1,
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("targets the dedicated directory endpoint while getList keeps the legacy route", async () => {
|
|
|
|
|
|
await vendorsApi.getDirectoryList({ search: "gateway", isActive: false, page: 1 });
|
|
|
|
|
|
await vendorsApi.getList({ search: "gateway", isActive: false, page: 1 });
|
|
|
|
|
|
|
|
|
|
|
|
expect(API_PATHS.vendor.getDirectoryList).toBe("Vendor/GetVendorDirectoryList");
|
|
|
|
|
|
expect(API_PATHS.vendor.getList).toBe("Vendor/GetVendorList");
|
|
|
|
|
|
expect(apiGet).toHaveBeenNthCalledWith(1, API_PATHS.vendor.getDirectoryList, {
|
|
|
|
|
|
searchParams: { search: "gateway", isActive: "false", page: 1, pageSize: 12 },
|
|
|
|
|
|
});
|
|
|
|
|
|
expect(apiGet).toHaveBeenNthCalledWith(2, API_PATHS.vendor.getList, {
|
|
|
|
|
|
searchParams: { search: "gateway", isActive: "false", page: 1, pageSize: 12 },
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("builds directory query parameters with the same repeated facet encoding", async () => {
|
|
|
|
|
|
await vendorsApi.getDirectoryList({
|
|
|
|
|
|
companies: ["Gateway Plumbing", "Metro HVAC"],
|
|
|
|
|
|
trades: ["Plumbing"],
|
|
|
|
|
|
locations: ["St. Louis, MO"],
|
|
|
|
|
|
jobBuckets: ["50-99"],
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
expect(apiGet).toHaveBeenCalledWith(API_PATHS.vendor.getDirectoryList, {
|
|
|
|
|
|
searchParams: {
|
|
|
|
|
|
search: "",
|
|
|
|
|
|
page: 1,
|
|
|
|
|
|
pageSize: 12,
|
|
|
|
|
|
"companies[0]": "Gateway Plumbing",
|
|
|
|
|
|
"companies[1]": "Metro HVAC",
|
|
|
|
|
|
"trades[0]": "Plumbing",
|
|
|
|
|
|
"locations[0]": "St. Louis, MO",
|
|
|
|
|
|
"jobBuckets[0]": "50-99",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("maps grouped company rows with the shared grouped-row mapper", async () => {
|
|
|
|
|
|
const result = await vendorsApi.getDirectoryList({ isActive: false, page: 1 });
|
|
|
|
|
|
|
|
|
|
|
|
expect(result.items[0]).toMatchObject({
|
|
|
|
|
|
companyId: "co-1",
|
|
|
|
|
|
companyName: "Gateway Plumbing",
|
|
|
|
|
|
address: "1 Market St",
|
|
|
|
|
|
city: "St. Louis",
|
|
|
|
|
|
state: "MO",
|
|
|
|
|
|
isActive: false,
|
|
|
|
|
|
technicians: [
|
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
|
id: 7,
|
|
|
|
|
|
contactName: "Adam Whyte",
|
|
|
|
|
|
email: "adam@gateway.test",
|
|
|
|
|
|
phone: "314-555-0198",
|
|
|
|
|
|
totalJobs: 3,
|
|
|
|
|
|
}),
|
|
|
|
|
|
],
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|