feat: sales activities, forecast products, catalog categories, member cache, procurement filters, and comprehensive tests

New features:
- ActivityController and manager for CW sales activities (CRUD)
- ForecastProductController for opportunity forecast/product lines
- CW member cache with dual-layer (in-memory + Redis) resolution
- Catalog category/subcategory/ecosystem taxonomy module
- Quote statuses type definitions with CW mapping
- User-defined fields (UDF) module with cache and event refresh
- Company sites CW module with serialization
- Procurement manager filters (category, ecosystem, manufacturer, price, stock)
- Opportunity notes CRUD and product line management via CW API
- Opportunity type definitions endpoint

Updates:
- OpportunityController: CW refresh, company hydration, activities, custom fields
- UserController: cwIdentifier field for CW member linking
- CatalogItemController: category/subcategory fields from CW
- PermissionNodes: sales note/product CRUD nodes, subCategories, collectPermissions
- API routes: procurement categories/filters, sales notes/products, opportunity types
- Global events: UDF and member refresh intervals on startup

Tests (414 passing):
- ActivityController, ForecastProductController, OpportunityController unit tests
- UserController cwIdentifier tests
- catalogCategories, companySites, memberCache, procurement module tests
- activityTypes, opportunityTypes, quoteStatuses type tests
- permissionNodes subCategories and getAllPermissionNodes tests
- Updated test setup with redis mock, API method mocks, and builder helpers
This commit is contained in:
2026-03-01 13:19:00 -06:00
parent 883b648d5e
commit d7b374f8ab
96 changed files with 7752 additions and 205 deletions
+81
View File
@@ -0,0 +1,81 @@
import { describe, test, expect } from "bun:test";
import { QUOTE_STATUSES } from "../../src/types/QuoteStatuses";
import type { QuoteStatus } from "../../src/types/QuoteStatuses";
describe("QuoteStatuses", () => {
test("QUOTE_STATUSES is a non-empty array", () => {
expect(Array.isArray(QUOTE_STATUSES)).toBe(true);
expect(QUOTE_STATUSES.length).toBeGreaterThan(0);
});
test("contains expected status names", () => {
const names = QUOTE_STATUSES.map((s) => s.name);
expect(names).toContain("New");
expect(names).toContain("Won");
expect(names).toContain("Lost");
expect(names).toContain("Active");
expect(names).toContain("Internal Review");
expect(names).toContain("FutureLead");
});
test("each status has required fields", () => {
for (const status of QUOTE_STATUSES) {
expect(typeof status.id).toBe("number");
expect(typeof status.name).toBe("string");
expect(typeof status.wonFlag).toBe("boolean");
expect(typeof status.lostFlag).toBe("boolean");
expect(typeof status.closedFlag).toBe("boolean");
expect(typeof status.inactiveFlag).toBe("boolean");
expect(typeof status.defaultFlag).toBe("boolean");
expect(typeof status.enteredBy).toBe("string");
expect(typeof status.dateEntered).toBe("string");
expect(status._info).toBeDefined();
expect(typeof status._info.lastUpdated).toBe("string");
expect(typeof status._info.updatedBy).toBe("string");
expect(typeof status.connectWiseId).toBe("string");
expect(Array.isArray(status.optimaEquivalency)).toBe(true);
}
});
test("Won status has wonFlag true and closedFlag true", () => {
const won = QUOTE_STATUSES.find((s) => s.name === "Won")!;
expect(won.wonFlag).toBe(true);
expect(won.closedFlag).toBe(true);
expect(won.lostFlag).toBe(false);
});
test("Lost status has lostFlag true and closedFlag true", () => {
const lost = QUOTE_STATUSES.find((s) => s.name === "Lost")!;
expect(lost.lostFlag).toBe(true);
expect(lost.closedFlag).toBe(true);
expect(lost.wonFlag).toBe(false);
});
test("New status is the default", () => {
const newStatus = QUOTE_STATUSES.find((s) => s.name === "New")!;
expect(newStatus.defaultFlag).toBe(true);
});
test("Active status is open (not closed)", () => {
const active = QUOTE_STATUSES.find((s) => s.name === "Active")!;
expect(active.closedFlag).toBe(false);
expect(active.wonFlag).toBe(false);
expect(active.lostFlag).toBe(false);
});
test("each status has unique id", () => {
const ids = QUOTE_STATUSES.map((s) => s.id);
expect(new Set(ids).size).toBe(ids.length);
});
test("each status has non-empty optimaEquivalency array", () => {
for (const status of QUOTE_STATUSES) {
expect(status.optimaEquivalency.length).toBeGreaterThan(0);
}
});
test("only one status has defaultFlag true", () => {
const defaults = QUOTE_STATUSES.filter((s) => s.defaultFlag);
expect(defaults).toHaveLength(1);
});
});