Files
98b6d63164 refactor: apply biome formatting to packages/features (#27844)
* refactor: apply biome formatting to packages/features (batch 1 - small subdirs)

Format small subdirectories in packages/features: di, flags, holidays, oauth,
settings, users, assignment-reason, selectedCalendar, hashedLink, host, form,
form-builder, availability, data-table, pbac, schedules, troubleshooter,
eventtypes, calendar-subscription, and root-level files.

Also includes straggler apps/web BookEventForm.tsx.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* refactor: apply biome formatting to packages/features (batch 2 - medium subdirs)

Format medium subdirectories in packages/features: auth, credentials,
calendars, routing-forms, routing-trace, attributes, watchlist, calAIPhone,
tasker, and webhooks.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* refactor: apply biome formatting to packages/features (batch 3 - bookings + insights)

Format bookings and insights subdirectories in packages/features.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* refactor: apply biome formatting to packages/features (batch 4 - ee)

Format packages/features/ee subdirectory covering billing, workflows,
organizations, teams, managed-event-types, round-robin, dsync,
integration-attribute-sync, and payments.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* refactor: apply biome formatting to packages/features (batch 5 - booking-audit part 1)

Format booking-audit di, actions, common, dto, repository, and types
subdirectories in packages/features/booking-audit.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* refactor: apply biome formatting to packages/features (batch 6 - booking-audit part 2)

Format booking-audit service subdirectory in packages/features/booking-audit.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
2026-02-11 15:47:14 +01:00

102 lines
2.9 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { RoutingTrace } from "../repositories/RoutingTraceRepository.interface";
import { RoutingTracePresenter } from "./RoutingTracePresenter";
describe("RoutingTracePresenter", () => {
it("delegates salesforce steps to SalesforceRoutingTracePresenter", () => {
const trace: RoutingTrace = [
{
domain: "salesforce",
step: "searching_by_website_value",
timestamp: 1000,
data: { emailDomain: "acme.com" },
},
];
const result = RoutingTracePresenter.present(trace);
expect(result).toHaveLength(1);
expect(result[0]).toEqual({
message: 'Searching for Salesforce account by website matching domain "acme.com"',
domain: "salesforce",
step: "searching_by_website_value",
timestamp: 1000,
});
});
it("delegates routing form steps to RoutingFormTracePresenter", () => {
const trace: RoutingTrace = [
{
domain: "routing_form",
step: "route_matched",
timestamp: 2000,
data: { routeId: "route-1", routeName: "Enterprise" },
},
];
const result = RoutingTracePresenter.present(trace);
expect(result).toHaveLength(1);
expect(result[0]).toEqual({
message: 'Route matched: "Enterprise" (ID: route-1)',
domain: "routing_form",
step: "route_matched",
timestamp: 2000,
});
});
it("handles unknown domains with fallback", () => {
const trace: RoutingTrace = [
{
domain: "unknown_domain",
step: "some_step",
timestamp: 3000,
data: {},
},
];
const result = RoutingTracePresenter.present(trace);
expect(result).toHaveLength(1);
expect(result[0].message).toBe("unknown_domain: some_step");
});
it("presents a multi-step trace in order", () => {
const trace: RoutingTrace = [
{
domain: "routing_form",
step: "route_matched",
timestamp: 1000,
data: { routeId: "route-1", routeName: "Sales" },
},
{
domain: "salesforce",
step: "graphql_query_initiated",
timestamp: 2000,
data: { email: "[email protected]", emailDomain: "acme.com" },
},
{
domain: "salesforce",
step: "salesforce_assignment",
timestamp: 3000,
data: { email: "[email protected]", recordType: "Contact", recordId: "003ABC" },
},
];
const result = RoutingTracePresenter.present(trace);
expect(result).toHaveLength(3);
expect(result[0].message).toBe('Route matched: "Sales" (ID: route-1)');
expect(result[1].message).toBe(
"GraphQL account resolution initiated for [email protected] (domain: acme.com)"
);
expect(result[2].message).toBe("Salesforce assignment: [email protected] via Contact (ID: 003ABC)");
});
it("returns empty array for empty trace", () => {
const result = RoutingTracePresenter.present([]);
expect(result).toEqual([]);
});
});