feat: dashboard overhaul, chargeability reports, dispo import enhancements, UI polish
Dashboard: expanded chargeability widget, resource/project table widgets with sorting and filters, stat cards with formatMoney integration. Chargeability: new report client with filtering, chargeability-bookings use case, updated dashboard overview logic. Dispo import: TBD project handling, parse-dispo-matrix improvements, stage-dispo-projects resource value scores, new tests. Estimates: CommercialTermsEditor component, commercial-terms engine module, expanded estimate schemas and types. UI: AppShell navigation updates, timeline filter/toolbar enhancements, role management improvements, signin page redesign, Tailwind/globals polish, SystemSettings SMTP section, anonymization support. Tests: new router tests (anonymization, chargeability, effort-rule, entitlement, estimate, experience-multiplier, notification, resource, staffing, vacation). Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
getDashboardChargeabilityOverview,
|
||||
getDashboardDemand,
|
||||
getDashboardOverview,
|
||||
getDashboardPeakTimes,
|
||||
@@ -26,6 +27,7 @@ describe("dashboard use-cases", () => {
|
||||
shortCode: "ALPHA",
|
||||
status: "ACTIVE",
|
||||
orderType: "FIXED",
|
||||
dynamicFields: null,
|
||||
},
|
||||
resource: {
|
||||
id: "res_1",
|
||||
@@ -342,6 +344,175 @@ describe("dashboard use-cases", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps proposed allocations out of actual chargeability by default but can include them", async () => {
|
||||
const db = {
|
||||
assignment: {
|
||||
findMany: vi.fn().mockResolvedValue([
|
||||
{
|
||||
id: "assign_1",
|
||||
projectId: "proj_1",
|
||||
resourceId: "res_1",
|
||||
status: "PROPOSED",
|
||||
startDate: new Date("2026-03-03T00:00:00.000Z"),
|
||||
endDate: new Date("2026-03-03T00:00:00.000Z"),
|
||||
hoursPerDay: 8,
|
||||
dailyCostCents: 0,
|
||||
project: {
|
||||
id: "proj_1",
|
||||
name: "Alpha",
|
||||
shortCode: "ALPHA",
|
||||
status: "ACTIVE",
|
||||
orderType: "FIXED",
|
||||
},
|
||||
resource: {
|
||||
id: "res_1",
|
||||
displayName: "Alice",
|
||||
chapter: "CGI",
|
||||
},
|
||||
},
|
||||
]),
|
||||
},
|
||||
resource: {
|
||||
findMany: vi.fn().mockResolvedValue([
|
||||
{
|
||||
id: "res_1",
|
||||
eid: "alice",
|
||||
displayName: "Alice",
|
||||
chapter: "CGI",
|
||||
chargeabilityTarget: 80,
|
||||
availability: { monday: 8, tuesday: 8, wednesday: 8, thursday: 8, friday: 8 },
|
||||
},
|
||||
]),
|
||||
},
|
||||
};
|
||||
|
||||
const strict = await getDashboardChargeabilityOverview(db as never, {
|
||||
now: new Date("2026-03-15T00:00:00.000Z"),
|
||||
topN: 10,
|
||||
watchlistThreshold: 15,
|
||||
});
|
||||
const withProposed = await getDashboardChargeabilityOverview(db as never, {
|
||||
includeProposed: true,
|
||||
now: new Date("2026-03-15T00:00:00.000Z"),
|
||||
topN: 10,
|
||||
watchlistThreshold: 15,
|
||||
});
|
||||
|
||||
expect(strict.top[0]?.actualChargeability).toBe(0);
|
||||
expect(strict.top[0]?.expectedChargeability).toBe(5);
|
||||
expect(withProposed.top[0]?.actualChargeability).toBe(5);
|
||||
expect(withProposed.top[0]?.expectedChargeability).toBe(5);
|
||||
});
|
||||
|
||||
it("filters chargeability overview by departed state and country", async () => {
|
||||
const db = {
|
||||
assignment: {
|
||||
findMany: vi.fn().mockResolvedValue([]),
|
||||
},
|
||||
resource: {
|
||||
findMany: vi.fn().mockResolvedValue([
|
||||
{
|
||||
id: "res_1",
|
||||
eid: "alice",
|
||||
displayName: "Alice",
|
||||
chapter: "CGI",
|
||||
countryId: "country_de",
|
||||
departed: false,
|
||||
chargeabilityTarget: 80,
|
||||
availability: { monday: 8, tuesday: 8, wednesday: 8, thursday: 8, friday: 8 },
|
||||
},
|
||||
]),
|
||||
},
|
||||
};
|
||||
|
||||
const result = await getDashboardChargeabilityOverview(db as never, {
|
||||
now: new Date("2026-03-15T00:00:00.000Z"),
|
||||
topN: 10,
|
||||
watchlistThreshold: 15,
|
||||
countryIds: ["country_de"],
|
||||
departed: false,
|
||||
});
|
||||
|
||||
expect(db.resource.findMany).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
where: expect.objectContaining({
|
||||
isActive: true,
|
||||
countryId: { in: ["country_de"] },
|
||||
departed: false,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
expect(result.top).toHaveLength(1);
|
||||
expect(result.top[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
id: "res_1",
|
||||
countryId: "country_de",
|
||||
departed: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("includes imported TBD draft projects in actual chargeability only when proposed work is enabled", async () => {
|
||||
const db = {
|
||||
assignment: {
|
||||
findMany: vi.fn().mockResolvedValue([
|
||||
{
|
||||
id: "assign_tbd",
|
||||
projectId: "proj_tbd",
|
||||
resourceId: "res_1",
|
||||
status: "PROPOSED",
|
||||
startDate: new Date("2026-03-03T00:00:00.000Z"),
|
||||
endDate: new Date("2026-03-03T00:00:00.000Z"),
|
||||
hoursPerDay: 8,
|
||||
dailyCostCents: 0,
|
||||
project: {
|
||||
id: "proj_tbd",
|
||||
name: "TBD: AMG",
|
||||
shortCode: "TBD-AMG",
|
||||
status: "DRAFT",
|
||||
orderType: "CLIENT",
|
||||
dynamicFields: { dispoImport: { isTbd: true } },
|
||||
},
|
||||
resource: {
|
||||
id: "res_1",
|
||||
displayName: "Alice",
|
||||
chapter: "CGI",
|
||||
},
|
||||
},
|
||||
]),
|
||||
},
|
||||
resource: {
|
||||
findMany: vi.fn().mockResolvedValue([
|
||||
{
|
||||
id: "res_1",
|
||||
eid: "alice",
|
||||
displayName: "Alice",
|
||||
chapter: "CGI",
|
||||
chargeabilityTarget: 80,
|
||||
availability: { monday: 8, tuesday: 8, wednesday: 8, thursday: 8, friday: 8 },
|
||||
},
|
||||
]),
|
||||
},
|
||||
};
|
||||
|
||||
const strict = await getDashboardChargeabilityOverview(db as never, {
|
||||
now: new Date("2026-03-15T00:00:00.000Z"),
|
||||
topN: 10,
|
||||
watchlistThreshold: 15,
|
||||
});
|
||||
const withProposed = await getDashboardChargeabilityOverview(db as never, {
|
||||
includeProposed: true,
|
||||
now: new Date("2026-03-15T00:00:00.000Z"),
|
||||
topN: 10,
|
||||
watchlistThreshold: 15,
|
||||
});
|
||||
|
||||
expect(strict.top[0]?.actualChargeability).toBe(0);
|
||||
expect(strict.top[0]?.expectedChargeability).toBe(5);
|
||||
expect(withProposed.top[0]?.actualChargeability).toBe(5);
|
||||
expect(withProposed.top[0]?.expectedChargeability).toBe(5);
|
||||
});
|
||||
|
||||
it("returns distinct resource counts for chapter demand grouping", async () => {
|
||||
const db = {
|
||||
demandRequirement: {
|
||||
|
||||
Reference in New Issue
Block a user