fix: follow-ups of the lot-v018 stack reviews #482
1 changed files with 26 additions and 0 deletions
|
|
@ -313,6 +313,32 @@ describe("useCategories — « Vérifier la hiérarchie » (#393)", () => {
|
|||
expect(getAllCategoriesWithCounts).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
|
||||
it("shows a failed read of the categories in the window, never in the page's banner behind it", async () => {
|
||||
vi.mocked(findOrphanCategories).mockResolvedValueOnce([CYCLE]).mockResolvedValueOnce([]);
|
||||
vi.mocked(reattachCategory).mockResolvedValue(3);
|
||||
let api = await mount();
|
||||
|
||||
// At the opening: the diagnostic does not run on the old categories.
|
||||
vi.mocked(getAllCategoriesWithCounts).mockRejectedValueOnce(new Error("database is locked"));
|
||||
await api.checkHierarchy();
|
||||
let state = harness.render(useCategories).state;
|
||||
expect(state.hierarchyCheck).toEqual({ orphans: null, error: { message: "database is locked" } });
|
||||
expect(state.error).toBeNull();
|
||||
expect(findOrphanCategories).not.toHaveBeenCalled();
|
||||
|
||||
// After a committed reattachment.
|
||||
api = harness.render(useCategories);
|
||||
await api.checkHierarchy();
|
||||
api = harness.render(useCategories);
|
||||
vi.mocked(getAllCategoriesWithCounts).mockRejectedValueOnce(new Error("disk I/O error"));
|
||||
await api.reattachOrphan(CYCLE, null);
|
||||
state = harness.render(useCategories).state;
|
||||
expect(reattachCategory).toHaveBeenCalledWith(3, null);
|
||||
expect(state.hierarchyCheck).toEqual({ orphans: [], error: { message: "disk I/O error" } });
|
||||
expect(state.error).toBeNull();
|
||||
expect(state.isSaving).toBe(false);
|
||||
});
|
||||
|
||||
it("reads the categories once the drag-and-drop's writes are over, never halfway", async () => {
|
||||
let written: () => void = () => undefined;
|
||||
vi.mocked(updateCategorySortOrders).mockReturnValue(new Promise<void>((r) => (written = r)));
|
||||
|
|
|
|||
Loading…
Reference in a new issue