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>
118 lines
3.6 KiB
TypeScript
118 lines
3.6 KiB
TypeScript
import { AllocationStatus } from "@capakraken/shared";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { projectRouter } from "../router/project.js";
|
|
import { createCallerFactory } from "../trpc.js";
|
|
|
|
const createCaller = createCallerFactory(projectRouter);
|
|
|
|
function createProtectedCaller(db: Record<string, unknown>) {
|
|
return createCaller({
|
|
session: {
|
|
user: { email: "user@example.com", name: "User", image: null },
|
|
expires: "2026-03-13T00:00:00.000Z",
|
|
},
|
|
db: db as never,
|
|
dbUser: { id: "user_1", systemRole: "ADMIN", permissionOverrides: null },
|
|
});
|
|
}
|
|
|
|
describe("project router planning counts", () => {
|
|
it("returns planning entry counts in project.list", async () => {
|
|
const db = {
|
|
project: {
|
|
findMany: vi.fn().mockResolvedValue([
|
|
{
|
|
id: "project_1",
|
|
shortCode: "PRJ",
|
|
name: "Project One",
|
|
orderType: "CHARGEABLE",
|
|
allocationType: "PROJECT",
|
|
winProbability: 100,
|
|
budgetCents: 100000,
|
|
startDate: new Date("2026-03-17"),
|
|
endDate: new Date("2026-03-28"),
|
|
status: "ACTIVE",
|
|
responsiblePerson: null,
|
|
dynamicFields: {},
|
|
staffingReqs: [],
|
|
blueprintId: null,
|
|
createdAt: new Date("2026-03-13"),
|
|
updatedAt: new Date("2026-03-13"),
|
|
_count: { allocations: 1 },
|
|
},
|
|
]),
|
|
count: vi.fn().mockResolvedValue(1),
|
|
},
|
|
allocation: {
|
|
findMany: vi.fn().mockResolvedValue([
|
|
{
|
|
id: "legacy_demand",
|
|
resourceId: null,
|
|
projectId: "project_1",
|
|
startDate: new Date("2026-03-17"),
|
|
endDate: new Date("2026-03-18"),
|
|
hoursPerDay: 8,
|
|
percentage: 100,
|
|
role: "FX",
|
|
roleId: "role_fx",
|
|
isPlaceholder: true,
|
|
headcount: 2,
|
|
dailyCostCents: 0,
|
|
status: AllocationStatus.PROPOSED,
|
|
metadata: {},
|
|
createdAt: new Date("2026-03-13"),
|
|
updatedAt: new Date("2026-03-13"),
|
|
},
|
|
]),
|
|
},
|
|
demandRequirement: {
|
|
findMany: vi.fn().mockResolvedValue([
|
|
{
|
|
id: "demand_1",
|
|
projectId: "project_1",
|
|
startDate: new Date("2026-03-17"),
|
|
endDate: new Date("2026-03-18"),
|
|
hoursPerDay: 8,
|
|
percentage: 100,
|
|
role: "FX",
|
|
roleId: "role_fx",
|
|
headcount: 2,
|
|
status: AllocationStatus.PROPOSED,
|
|
metadata: {},
|
|
createdAt: new Date("2026-03-13"),
|
|
updatedAt: new Date("2026-03-13"),
|
|
},
|
|
]),
|
|
},
|
|
assignment: {
|
|
findMany: vi.fn().mockResolvedValue([
|
|
{
|
|
id: "assignment_1",
|
|
demandRequirementId: null,
|
|
resourceId: "resource_1",
|
|
projectId: "project_1",
|
|
startDate: new Date("2026-03-19"),
|
|
endDate: new Date("2026-03-20"),
|
|
hoursPerDay: 8,
|
|
percentage: 100,
|
|
role: "FX Lead",
|
|
roleId: "role_fx",
|
|
dailyCostCents: 32000,
|
|
status: AllocationStatus.ACTIVE,
|
|
metadata: {},
|
|
createdAt: new Date("2026-03-13"),
|
|
updatedAt: new Date("2026-03-13"),
|
|
},
|
|
]),
|
|
},
|
|
};
|
|
|
|
const caller = createProtectedCaller(db);
|
|
const result = await caller.list({ limit: 50, page: 1 });
|
|
|
|
expect(result.total).toBe(1);
|
|
expect(result.projects).toHaveLength(1);
|
|
expect(result.projects[0]?._count.allocations).toBe(2);
|
|
});
|
|
});
|