cd78f72f33
Complete rename of all technical identifiers across the codebase: Package names (11 packages): - @planarchy/* → @capakraken/* in all package.json, tsconfig, imports Import statements: 277 files, 548 occurrences replaced Database & Docker: - PostgreSQL user/db: planarchy → capakraken - Docker volumes: planarchy_pgdata → capakraken_pgdata - Connection strings updated in docker-compose, .env, CI CI/CD: - GitHub Actions workflow: all filter commands updated - Test database credentials updated Infrastructure: - Redis channel: planarchy:sse → capakraken:sse - Logger service name: planarchy-api → capakraken-api - Anonymization seed updated - Start/stop/restart scripts updated Test data: - Seed emails: @planarchy.dev → @capakraken.dev - E2E test credentials: all 11 spec files updated - Email defaults: @planarchy.app → @capakraken.app - localStorage keys: planarchy_* → capakraken_* Documentation: 30+ .md files updated Verification: - pnpm install: workspace resolution works - TypeScript: only pre-existing TS2589 (no new errors) - Engine: 310/310 tests pass - Staffing: 37/37 tests pass Co-Authored-By: claude-flow <ruv@ruv.net>
113 lines
3.1 KiB
TypeScript
113 lines
3.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { AllocationStatus, type AllocationWithDetails } from "@capakraken/shared";
|
|
import {
|
|
buildSplitAllocationReadModel,
|
|
} from "../index.js";
|
|
|
|
const project = {
|
|
id: "project_1",
|
|
name: "Project One",
|
|
shortCode: "P1",
|
|
status: "ACTIVE",
|
|
startDate: new Date("2026-01-01"),
|
|
endDate: new Date("2026-01-31"),
|
|
orderType: "CHARGEABLE",
|
|
budgetCents: 100_000,
|
|
winProbability: 100,
|
|
staffingReqs: [],
|
|
responsiblePerson: "Alex",
|
|
} satisfies AllocationWithDetails["project"];
|
|
|
|
const resource = {
|
|
id: "resource_1",
|
|
displayName: "Ada Lovelace",
|
|
eid: "E-1",
|
|
lcrCents: 10_000,
|
|
chapter: "Engineering",
|
|
availability: null,
|
|
};
|
|
|
|
const roleEntity = {
|
|
id: "role_1",
|
|
name: "Engineer",
|
|
color: "#123456",
|
|
};
|
|
|
|
describe("buildSplitAllocationReadModel", () => {
|
|
it("builds demand and assignment entries from explicit rows", () => {
|
|
const result = buildSplitAllocationReadModel({
|
|
demandRequirements: [
|
|
{
|
|
id: "demand_1",
|
|
projectId: project.id,
|
|
startDate: new Date("2026-01-06"),
|
|
endDate: new Date("2026-01-10"),
|
|
hoursPerDay: 8,
|
|
percentage: 100,
|
|
role: "Engineer",
|
|
roleId: roleEntity.id,
|
|
headcount: 2,
|
|
status: AllocationStatus.PROPOSED,
|
|
metadata: { source: "explicit-demand" },
|
|
createdAt: new Date("2026-01-01"),
|
|
updatedAt: new Date("2026-01-02"),
|
|
project,
|
|
roleEntity,
|
|
},
|
|
],
|
|
assignments: [
|
|
{
|
|
id: "assignment_1",
|
|
demandRequirementId: "demand_1",
|
|
resourceId: resource.id,
|
|
projectId: project.id,
|
|
startDate: new Date("2026-01-06"),
|
|
endDate: new Date("2026-01-10"),
|
|
hoursPerDay: 8,
|
|
percentage: 100,
|
|
role: "Engineer",
|
|
roleId: roleEntity.id,
|
|
dailyCostCents: 80_000,
|
|
status: AllocationStatus.PROPOSED,
|
|
metadata: { source: "explicit-assignment" },
|
|
createdAt: new Date("2026-01-01"),
|
|
updatedAt: new Date("2026-01-02"),
|
|
resource,
|
|
project,
|
|
roleEntity,
|
|
},
|
|
],
|
|
});
|
|
|
|
expect(result.allocations).toHaveLength(2);
|
|
expect(result.demands).toHaveLength(1);
|
|
expect(result.assignments).toHaveLength(1);
|
|
|
|
expect(result.demands[0]).toMatchObject({
|
|
id: "demand_1",
|
|
entityId: "demand_1",
|
|
sourceAllocationId: "demand_1",
|
|
requestedHeadcount: 2,
|
|
metadata: { source: "explicit-demand" },
|
|
});
|
|
expect(result.assignments[0]).toMatchObject({
|
|
id: "assignment_1",
|
|
entityId: "assignment_1",
|
|
sourceAllocationId: "assignment_1",
|
|
resourceId: resource.id,
|
|
metadata: { source: "explicit-assignment" },
|
|
});
|
|
});
|
|
|
|
it("returns empty arrays when given no inputs", () => {
|
|
const result = buildSplitAllocationReadModel({
|
|
demandRequirements: [],
|
|
assignments: [],
|
|
});
|
|
|
|
expect(result.allocations).toHaveLength(0);
|
|
expect(result.demands).toHaveLength(0);
|
|
expect(result.assignments).toHaveLength(0);
|
|
});
|
|
});
|