fix(housekeeping): restore people partial compatibility

This commit is contained in:
Simo committed 2026-08-29 21:03:43 +02:00
1 parent fcd1dfd96e
commit a6a288d9ff
6 files changed
+412 -11

No files matched your search

@@ -401,6 +401,115 @@ describe("People actionable form contract", () => {
expect(html.match(new RegExp(password, "gu"))).toHaveLength(1);
});
it("renders typed external sync debt with an explicit do-not-retry warning", () => {
const completion = {
status: "partial",
external: "failed",
audit: "persisted",
} as const;
const html = renderToStaticMarkup(
<PeopleCommandResult
result={ok(
{
before: { completed: 0, total: 2, failedIds: [] },
after: {
completed: 2,
total: 2,
failedIds: [],
externalSyncFailures: [
{
userId: 7,
reason:
"Database applied; emulator sync failed. Do not retry automatically.",
},
{
userId: "8",
reason: "unsafe payload from an untyped result",
},
],
debug: "sensitive internal payload",
},
completion,
},
"bulk-sync-debt",
completion,
)}
/>,
);
expect(html).toContain('role="alert"');
expect(html).toContain("Do not retry automatically.");
expect(html).toContain('aria-label="External synchronization debt"');
expect(html).toContain("User #7");
expect(html).toContain("Database applied; emulator sync failed.");
expect(html).not.toContain("unsafe payload from an untyped result");
expect(html).not.toContain("sensitive internal payload");
});
it("keeps form-returned external sync debt visible in the operator result surface", async () => {
const completion = {
status: "partial",
external: "failed",
audit: "persisted",
} as const;
vi.mocked(executeHousekeepingCommand).mockResolvedValue(
ok(
{
before: { completed: 0, total: 1, failedIds: [] },
after: {
completed: 1,
total: 1,
failedIds: [],
externalSyncFailures: [
{
userId: 23,
reason:
"Database applied; emulator sync failed. Do not retry automatically.",
},
],
},
completion,
},
"form-sync-debt",
completion,
),
);
const formData = new FormData();
formData.set("userIds", "23");
formData.set("amount", "100");
formData.set("type", "credits");
formData.set("reason", "Planned grant");
const result = await submitPeopleCommandForm(
{
commandId: "people.users.bulk-currency",
input: {},
fields: [
{ name: "userIds", label: "User IDs", type: "number-list" },
{ name: "amount", label: "Amount", type: "number", min: 1 },
{
name: "type",
label: "Currency",
type: "select",
options: [{ value: "credits", label: "Credits" }],
},
],
requiresReason: true,
},
null,
formData,
);
const html = renderToStaticMarkup(<PeopleCommandResult result={result} />);
expect(executeHousekeepingCommand).toHaveBeenCalledWith({
commandId: "people.users.bulk-currency",
input: { userIds: [23], amount: 100, type: "credits" },
reason: "Planned grant",
});
expect(html).toContain("Do not retry automatically.");
expect(html).toContain("User #23");
});
it("provides a real Next loading boundary", () => {
const source = readFileSync(
"src/app/ase-next/[domain]/[[...segments]]/loading.tsx",