fix: keep unassigned purchases visible in budget
Continuous Integration / lint-and-test (push) Successful in 12s
Continuous Integration / docker-build-and-push (push) Successful in 32s

This commit is contained in:
Lucas Winther committed 2026-09-30 16:35:44 +02:00
1 parent f02c452d6c
commit dfbe584874
8 files changed
+80 -8

No files matched your search

+22 -1
View File
@@ -6,7 +6,7 @@ import { act } from "react";
import { createRoot } from "react-dom/client";
import { MemoryRouter } from "react-router";
import { createSeedDataset } from "../../domain/seed.ts";
import { addBudgetFolder, addRecurringCost, confirmOccurrence, placeRecurringUnderPost } from "../../store/actions.ts";
import { addBudgetFolder, addPurchase, addRecurringCost, confirmOccurrence, placeRecurringUnderPost } from "../../store/actions.ts";
import { monthView } from "../../domain/views.ts";
import { store } from "../../store/index.ts";
import { PostTableLegend } from "./PostTable.tsx";
@@ -81,3 +81,24 @@ test("bills beneath a post are hidden until its post is expanded", () => {
act(() => root.unmount()); container.remove(); Object.assign(store, original);
}
});
test("Unassigned is a permanent Budget section with a create-post action", () => {
const data = createSeedDataset("2026-09");
const purchase = addPurchase(data, { date: "2026-09", description: "Train ticket", total: { amount: 50, currency: "DKK" }, splitMode: "percent", splits: [], schedule: null });
const original = { get: store.get, subscribe: store.subscribe };
store.get = () => data;
store.subscribe = () => () => {};
const container = document.createElement("div"); document.body.append(container);
const root = createRoot(container);
try {
act(() => root.render(<MemoryRouter><BudgetTree monthId="2026-09" rows={monthView(data, "2026-09").rows} /></MemoryRouter>));
for (const scope of [container.querySelector("table")!, container.querySelector("ul")!]) {
expect(scope.textContent).toContain("Unassigned");
const row = scope.querySelector(`[data-budget-item="${purchase.id}"]`)!;
expect(row.textContent).toContain("Train ticket");
expect(row.querySelector("button[aria-label='Create post for Train ticket']")).not.toBeNull();
}
} finally {
act(() => root.unmount()); container.remove(); Object.assign(store, original);
}
});