fix: update loading state handling in CalendarPage and DutyList components

- Set isLoading to false in CalendarPage to prevent unnecessary loading indicators.
- Removed the loading spinner from CalendarHeader and adjusted rendering logic in DutyList to show a placeholder when data is not yet loaded for the month.
- Enhanced tests in DutyList to verify behavior when data is empty and when data is loading, ensuring accurate user feedback during data fetching.
This commit is contained in:
2026-03-03 16:21:27 +03:00
parent 3b68e29d7b
commit 95f65141e1
4 changed files with 38 additions and 34 deletions

View File

@@ -35,17 +35,27 @@ describe("DutyList", () => {
useAppStore.getState().setCurrentMonth(new Date(2025, 1, 1)); // Feb 2025
});
it("renders no duties message when duties empty", () => {
it("renders no duties message when duties empty and data loaded for month", () => {
useAppStore.getState().setDuties([]);
useAppStore.getState().batchUpdate({ dataForMonthKey: "2025-02" });
render(<DutyList />);
expect(screen.getByText(/No duties this month/i)).toBeInTheDocument();
});
it("renders quiet placeholder when data not yet loaded for month", () => {
useAppStore.getState().setDuties([]);
useAppStore.getState().batchUpdate({ dataForMonthKey: null });
render(<DutyList />);
expect(screen.queryByText(/No duties this month/i)).not.toBeInTheDocument();
expect(document.querySelector('[aria-busy="true"]')).toBeInTheDocument();
});
it("renders duty with full_name and time range", () => {
useAppStore.getState().setDuties([
duty("Иванов", "2025-02-25T09:00:00Z", "2025-02-25T18:00:00Z"),
]);
useAppStore.getState().setCurrentMonth(new Date(2025, 1, 1));
useAppStore.getState().batchUpdate({ dataForMonthKey: "2025-02" });
render(<DutyList />);
expect(screen.getByText("Иванов")).toBeInTheDocument();
});
@@ -58,6 +68,7 @@ describe("DutyList", () => {
}),
]);
useAppStore.getState().setCurrentMonth(new Date(2025, 2, 1));
useAppStore.getState().batchUpdate({ dataForMonthKey: "2025-03" });
render(<DutyList />);
expect(screen.getAllByText("Alice").length).toBeGreaterThanOrEqual(1);
expect(document.querySelector('a[href^="tel:"]')).toBeInTheDocument();