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:
@@ -0,0 +1,129 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { getAnonymizationDirectory } from "../lib/anonymization.js";
|
||||
|
||||
describe("anonymization directory", () => {
|
||||
it("persists aliases so existing resources keep the same identity when new resources appear", async () => {
|
||||
let storedAliases: Record<string, { displayName: string; eid: string }> = {
|
||||
resource_a: {
|
||||
displayName: "Iron Man",
|
||||
eid: "iron.man",
|
||||
},
|
||||
};
|
||||
|
||||
const resourcesRoundOne = [
|
||||
{
|
||||
id: "resource_a",
|
||||
eid: "alice",
|
||||
displayName: "Alice",
|
||||
email: "alice@example.com",
|
||||
lcrCents: 14000,
|
||||
},
|
||||
{
|
||||
id: "resource_b",
|
||||
eid: "bob",
|
||||
displayName: "Bob",
|
||||
email: "bob@example.com",
|
||||
lcrCents: 11000,
|
||||
},
|
||||
];
|
||||
|
||||
const resourcesRoundTwo = [
|
||||
...resourcesRoundOne,
|
||||
{
|
||||
id: "resource_c",
|
||||
eid: "carol",
|
||||
displayName: "Carol",
|
||||
email: "carol@example.com",
|
||||
lcrCents: 12500,
|
||||
},
|
||||
];
|
||||
|
||||
const db = {
|
||||
systemSettings: {
|
||||
findUnique: vi.fn(async () => ({
|
||||
anonymizationEnabled: true,
|
||||
anonymizationDomain: "superhartmut.de",
|
||||
anonymizationSeed: "stable-seed",
|
||||
anonymizationMode: "global",
|
||||
anonymizationAliases: storedAliases,
|
||||
})),
|
||||
update: vi.fn(async ({ data }: { data: { anonymizationAliases: typeof storedAliases } }) => {
|
||||
storedAliases = data.anonymizationAliases;
|
||||
return {};
|
||||
}),
|
||||
},
|
||||
resource: {
|
||||
findMany: vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce(resourcesRoundOne)
|
||||
.mockResolvedValueOnce(resourcesRoundTwo),
|
||||
},
|
||||
};
|
||||
|
||||
const firstDirectory = await getAnonymizationDirectory(db as never);
|
||||
const secondDirectory = await getAnonymizationDirectory(db as never);
|
||||
|
||||
expect(firstDirectory?.byResourceId.get("resource_a")).toMatchObject({
|
||||
displayName: "Iron Man",
|
||||
eid: "iron.man",
|
||||
email: "iron.man@superhartmut.de",
|
||||
});
|
||||
expect(firstDirectory?.byResourceId.get("resource_b")).toBeDefined();
|
||||
expect(secondDirectory?.byResourceId.get("resource_a")).toMatchObject({
|
||||
displayName: "Iron Man",
|
||||
eid: "iron.man",
|
||||
email: "iron.man@superhartmut.de",
|
||||
});
|
||||
expect(secondDirectory?.byResourceId.get("resource_b")).toEqual(
|
||||
firstDirectory?.byResourceId.get("resource_b"),
|
||||
);
|
||||
expect(secondDirectory?.byResourceId.get("resource_c")).toBeDefined();
|
||||
expect(db.systemSettings.update).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it("regenerates legacy aliases with digits into stable aliases without numeric characters", async () => {
|
||||
let storedAliases: Record<string, { displayName: string; eid: string }> = {
|
||||
resource_a: {
|
||||
displayName: "Baloo 16",
|
||||
eid: "baloo.16",
|
||||
},
|
||||
};
|
||||
|
||||
const db = {
|
||||
systemSettings: {
|
||||
findUnique: vi.fn(async () => ({
|
||||
anonymizationEnabled: true,
|
||||
anonymizationDomain: "superhartmut.de",
|
||||
anonymizationSeed: "stable-seed",
|
||||
anonymizationMode: "global",
|
||||
anonymizationAliases: storedAliases,
|
||||
})),
|
||||
update: vi.fn(async ({ data }: { data: { anonymizationAliases: typeof storedAliases } }) => {
|
||||
storedAliases = data.anonymizationAliases;
|
||||
return {};
|
||||
}),
|
||||
},
|
||||
resource: {
|
||||
findMany: vi.fn().mockResolvedValue([
|
||||
{
|
||||
id: "resource_a",
|
||||
eid: "alice",
|
||||
displayName: "Alice",
|
||||
email: "alice@example.com",
|
||||
lcrCents: 6000,
|
||||
},
|
||||
]),
|
||||
},
|
||||
};
|
||||
|
||||
const directory = await getAnonymizationDirectory(db as never);
|
||||
const alias = directory?.byResourceId.get("resource_a");
|
||||
|
||||
expect(alias).toBeDefined();
|
||||
expect(alias?.displayName).not.toContain("16");
|
||||
expect(alias?.eid).not.toContain("16");
|
||||
expect(alias?.displayName).toMatch(/^[A-Za-z]+(?: [A-Za-z]+)*$/);
|
||||
expect(alias?.eid).toMatch(/^[a-z]+(?:\.[a-z]+)*$/);
|
||||
expect(db.systemSettings.update).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user