* 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 <noreply@anthropic.com> * 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 <noreply@anthropic.com> * 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 <noreply@anthropic.com> * 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 <noreply@anthropic.com> * 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 <noreply@anthropic.com> * 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 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
90 lines
3.5 KiB
TypeScript
90 lines
3.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import type { RoutingStep } from "../repositories/RoutingTraceRepository.interface";
|
|
import { RoutingFormTracePresenter } from "./RoutingFormTracePresenter";
|
|
|
|
function makeStep(step: string, data: Record<string, unknown> = {}): RoutingStep {
|
|
return { domain: "routing_form", step, timestamp: Date.now(), data };
|
|
}
|
|
|
|
describe("RoutingFormTracePresenter", () => {
|
|
it("presents route_matched", () => {
|
|
const result = RoutingFormTracePresenter.present(
|
|
makeStep("route_matched", { routeId: "route-1", routeName: "Enterprise" })
|
|
);
|
|
expect(result).toBe('Route matched: "Enterprise" (ID: route-1)');
|
|
});
|
|
|
|
it("presents fallback_route_used", () => {
|
|
const result = RoutingFormTracePresenter.present(
|
|
makeStep("fallback_route_used", { routeId: "route-2", routeName: "Default" })
|
|
);
|
|
expect(result).toBe('Fallback route used: "Default" (ID: route-2)');
|
|
});
|
|
|
|
it("presents attribute-logic-evaluated with all fields", () => {
|
|
const result = RoutingFormTracePresenter.present(
|
|
makeStep("attribute-logic-evaluated", {
|
|
routeName: "APAC",
|
|
routeIsFallback: false,
|
|
attributeRoutingDetails: [
|
|
{ attributeName: "Company Size", attributeValue: "Enterprise" },
|
|
{ attributeName: "Region", attributeValue: "APAC" },
|
|
],
|
|
})
|
|
);
|
|
expect(result).toBe(
|
|
'Attribute logic evaluated: Route: "APAC" Attributes: [Company Size=Enterprise, Region=APAC]'
|
|
);
|
|
});
|
|
|
|
it("presents attribute-logic-evaluated with fallback", () => {
|
|
const result = RoutingFormTracePresenter.present(
|
|
makeStep("attribute-logic-evaluated", {
|
|
routeName: "Fallback Route",
|
|
routeIsFallback: true,
|
|
})
|
|
);
|
|
expect(result).toBe('Attribute logic evaluated: Route: "Fallback Route" (fallback)');
|
|
});
|
|
|
|
it("presents attribute-logic-evaluated with no optional fields", () => {
|
|
const result = RoutingFormTracePresenter.present(makeStep("attribute-logic-evaluated", {}));
|
|
expect(result).toBe('Attribute logic evaluated: Route: "Unnamed route"');
|
|
});
|
|
|
|
it("presents attribute_fallback_used with routeName", () => {
|
|
const result = RoutingFormTracePresenter.present(
|
|
makeStep("attribute_fallback_used", { routeName: "Default Route" })
|
|
);
|
|
expect(result).toBe('Attribute fallback used: "Default Route"');
|
|
});
|
|
|
|
it("presents attribute_fallback_used without routeName", () => {
|
|
const result = RoutingFormTracePresenter.present(makeStep("attribute_fallback_used", {}));
|
|
expect(result).toBe('Attribute fallback used: "Unnamed route"');
|
|
});
|
|
|
|
it("presents route_matched without routeName", () => {
|
|
const result = RoutingFormTracePresenter.present(makeStep("route_matched", { routeId: "route-1" }));
|
|
expect(result).toBe('Route matched: "Unnamed route" (ID: route-1)');
|
|
});
|
|
|
|
it("presents fallback_route_used without routeName", () => {
|
|
const result = RoutingFormTracePresenter.present(makeStep("fallback_route_used", { routeId: "route-2" }));
|
|
expect(result).toBe('Fallback route used: "Unnamed route" (ID: route-2)');
|
|
});
|
|
|
|
it("treats routeName matching routeId as unnamed", () => {
|
|
const result = RoutingFormTracePresenter.present(
|
|
makeStep("route_matched", { routeId: "abc-123", routeName: "abc-123" })
|
|
);
|
|
expect(result).toBe('Route matched: "Unnamed route" (ID: abc-123)');
|
|
});
|
|
|
|
it("returns fallback for unknown step", () => {
|
|
const result = RoutingFormTracePresenter.present(makeStep("unknown_step", {}));
|
|
expect(result).toBe("Routing Form: unknown_step");
|
|
});
|
|
});
|