import { describe, expect, it } from "vitest"; import { getAllocationEmptyState, shouldAutoRelaxAllocationFilters } from "./allocationVisibilityState.js"; describe("allocationVisibilityState", () => { it("auto-relaxes default project filters when they hide every available row", () => { expect( shouldAutoRelaxAllocationFilters({ totalAssignments: 8, totalDemands: 2, visibleAssignments: 0, visibleDemands: 0, hidePastProjects: true, hideCompletedProjects: true, hideDraftProjects: false, }), ).toBe(true); }); it("does not auto-relax when there is no underlying allocation data", () => { expect( shouldAutoRelaxAllocationFilters({ totalAssignments: 0, totalDemands: 0, visibleAssignments: 0, visibleDemands: 0, hidePastProjects: true, hideCompletedProjects: true, hideDraftProjects: false, }), ).toBe(false); }); it("builds a filter-aware empty state when rows are hidden", () => { expect( getAllocationEmptyState({ totalAssignments: 5, totalDemands: 1, visibleAssignments: 0, visibleDemands: 0, hidePastProjects: true, hideCompletedProjects: true, hideDraftProjects: false, }), ).toEqual({ title: "No assignments match the active filters.", detail: "5 assignments and 1 demand are hidden by the active project filters.", showResetAction: true, }); }); it("keeps the plain empty state when there is genuinely no data", () => { expect( getAllocationEmptyState({ totalAssignments: 0, totalDemands: 0, visibleAssignments: 0, visibleDemands: 0, hidePastProjects: false, hideCompletedProjects: false, hideDraftProjects: false, }), ).toEqual({ title: "No assignments found.", detail: "Create a planning entry or relax the current project filters once data is available.", showResetAction: false, }); }); });