chore: update bug template guidance and include app test changes (#293)

This commit is contained in:
Daniel Volz
2026-02-23 19:54:18 +01:00
committed by GitHub
parent 05226cc500
commit b0c5d48095
2 changed files with 16 additions and 86 deletions
-86
View File
@@ -284,24 +284,6 @@ describe("App", () => {
expect(screen.getByText("lightbox-open-med-image.png")).toBeInTheDocument();
});
it("handles Escape key with modal priority", () => {
appContextMock.scheduleLightboxImage = "med-image.png";
appContextMock.showImageLightbox = true;
appContextMock.showShareDialog = true;
render(
<MemoryRouter initialEntries={["/dashboard"]}>
<App />
</MemoryRouter>
);
document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));
expect(appContextMock.closeScheduleLightbox).toHaveBeenCalled();
expect(appContextMock.closeImageLightbox).not.toHaveBeenCalled();
expect(appContextMock.closeShareDialog).not.toHaveBeenCalled();
});
it("handles popstate by closing selected medication", () => {
appContextMock.selectedMed = { id: 1, packCount: 1, looseTablets: 0, updatedAt: null };
@@ -344,20 +326,6 @@ describe("App", () => {
expect(window.history.pushState).toHaveBeenCalled();
});
it("Escape key closes about modal via history back", () => {
render(
<MemoryRouter initialEntries={["/dashboard"]}>
<App />
</MemoryRouter>
);
fireEvent.click(screen.getByRole("button", { name: "open-about" }));
expect(screen.getByText("about-modal-open")).toBeInTheDocument();
document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));
expect(window.history.back).toHaveBeenCalled();
});
it("handles popstate by resetting share dialog state", () => {
appContextMock.showShareDialog = true;
@@ -381,47 +349,6 @@ describe("App", () => {
expect(screen.getByText("dashboard-page")).toBeInTheDocument();
});
it("Escape closes refill modal when it is topmost", () => {
appContextMock.showRefillModal = true;
render(
<MemoryRouter initialEntries={["/dashboard"]}>
<App />
</MemoryRouter>
);
document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));
expect(appContextMock.closeRefillModal).toHaveBeenCalled();
});
it("Escape closes edit stock modal when it is topmost", () => {
appContextMock.showEditStockModal = true;
render(
<MemoryRouter initialEntries={["/dashboard"]}>
<App />
</MemoryRouter>
);
document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));
expect(appContextMock.closeEditStockModal).toHaveBeenCalled();
});
it("Escape closes user filter and medication detail in lower priority", () => {
appContextMock.selectedUser = "Max";
appContextMock.selectedMed = { id: 1, packCount: 1, looseTablets: 0, updatedAt: null };
render(
<MemoryRouter initialEntries={["/dashboard"]}>
<App />
</MemoryRouter>
);
document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));
expect(appContextMock.closeUserFilter).toHaveBeenCalled();
expect(appContextMock.closeMedDetail).not.toHaveBeenCalled();
});
it("popstate closes image lightbox before other modals", () => {
appContextMock.showImageLightbox = true;
appContextMock.scheduleLightboxImage = "img.png";
@@ -450,17 +377,4 @@ describe("App", () => {
window.dispatchEvent(new PopStateEvent("popstate"));
expect(appContextMock.setScheduleLightboxImage).toHaveBeenCalledWith(null);
});
it("Escape closes medication detail when no higher-priority modal is open", () => {
appContextMock.selectedMed = { id: 1, packCount: 1, looseTablets: 0, updatedAt: null };
render(
<MemoryRouter initialEntries={["/dashboard"]}>
<App />
</MemoryRouter>
);
document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));
expect(appContextMock.closeMedDetail).toHaveBeenCalled();
});
});