test: improve frontend test coverage (#163)
- Export DashboardPage helper functions for testability - Add new test files: App, SharedSchedule, AppContext, UnsavedChangesContext, useUnsavedChangesWarning - Expand existing test coverage for Auth, MedDetailModal, MobileEditModal, DashboardPage, MedicationsPage, PlannerPage, and more - Add edge case and error handling tests across components, hooks, and pages
This commit is contained in:
@@ -220,6 +220,9 @@ describe("SchedulePage", () => {
|
||||
});
|
||||
|
||||
it("can change schedule days", () => {
|
||||
const setScheduleDays = vi.fn();
|
||||
mockContextValue = createMockContext({ setScheduleDays });
|
||||
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<SchedulePage />
|
||||
@@ -230,6 +233,7 @@ describe("SchedulePage", () => {
|
||||
expect(select).toBeInTheDocument();
|
||||
|
||||
fireEvent.change(select, { target: { value: "90" } });
|
||||
expect(setScheduleDays).toHaveBeenCalledWith(90);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -485,6 +489,28 @@ describe("SchedulePage with past days", () => {
|
||||
expect(setShowPastDays).toHaveBeenCalledWith(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("collapses past days when already expanded", () => {
|
||||
const setShowPastDays = vi.fn();
|
||||
mockContextValue = createMockContext({
|
||||
pastDays: mockPastDays,
|
||||
showPastDays: true,
|
||||
setShowPastDays,
|
||||
missedPastDoseIds: [],
|
||||
});
|
||||
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<SchedulePage />
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
const toggle = document.querySelector(".past-days-toggle");
|
||||
if (toggle) {
|
||||
fireEvent.click(toggle);
|
||||
expect(setShowPastDays).toHaveBeenCalledWith(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("SchedulePage with expanded past days", () => {
|
||||
|
||||
Reference in New Issue
Block a user