fix: align frontend types and tests for react 19 (#339)

This commit is contained in:
Daniel Volz
2026-02-27 01:01:48 +01:00
committed by GitHub
parent 6b27d234d9
commit cc22f80209
23 changed files with 166 additions and 74 deletions
@@ -1,5 +1,5 @@
import { fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { Lightbox } from "../../components/Lightbox";
describe("Lightbox", () => {
@@ -55,6 +55,8 @@ const defaultProps = {
onRefillPacksChange: vi.fn(),
refillLoose: 0,
onRefillLooseChange: vi.fn(),
usePrescriptionRefill: false,
onUsePrescriptionRefillChange: vi.fn(),
refillSaving: false,
refillHistory: [] as RefillEntry[],
refillHistoryExpanded: false,
@@ -324,7 +326,7 @@ describe("MedDetailModal with refill modal", () => {
const submitBtn = document.querySelector(".refill-modal .modal-footer .success") as HTMLButtonElement;
fireEvent.click(submitBtn);
expect(onSubmitRefill).toHaveBeenCalledWith(mockMedication.id, undefined);
expect(onSubmitRefill).toHaveBeenCalledWith(mockMedication.id, false);
});
it("disables refill submit button when no pills are entered", () => {
@@ -589,7 +591,7 @@ describe("MedDetailModal with refill history", () => {
it("shows refill history when expanded", () => {
const refillHistory: RefillEntry[] = [
{ id: 1, medicationId: 1, timestamp: new Date().toISOString(), packsAdded: 1, looseAdded: 0 },
{ id: 1, refillDate: new Date().toISOString(), packsAdded: 1, loosePillsAdded: 0 },
];
render(<MedDetailModal {...defaultProps} refillHistory={refillHistory} refillHistoryExpanded={true} />);
@@ -602,7 +604,7 @@ describe("MedDetailModal with refill history", () => {
it("calls onRefillHistoryExpandedChange when toggle clicked", () => {
const onRefillHistoryExpandedChange = vi.fn();
const refillHistory: RefillEntry[] = [
{ id: 1, medicationId: 1, timestamp: new Date().toISOString(), packsAdded: 1, looseAdded: 0 },
{ id: 1, refillDate: new Date().toISOString(), packsAdded: 1, loosePillsAdded: 0 },
];
render(
@@ -1,4 +1,5 @@
import { fireEvent, render, screen } from "@testing-library/react";
import type { FormEvent } from "react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { MobileEditModal } from "../../components/MobileEditModal";
import type { FormState } from "../../types";
@@ -78,6 +79,7 @@ const defaultProps = {
meds: [],
onUploadMedImage: vi.fn(),
onDeleteMedImage: vi.fn(),
imageUploadError: null,
onClose: vi.fn(),
onResetForm: vi.fn(),
onSaveMedication: vi.fn(),
@@ -383,7 +385,7 @@ describe("MobileEditModal form submission", () => {
});
it("calls onSaveMedication when form submitted", () => {
const onSaveMedication = vi.fn((e: Event) => e.preventDefault());
const onSaveMedication = vi.fn((e: FormEvent) => e.preventDefault());
const validForm = { ...defaultForm, name: "TestMed" };
render(<MobileEditModal {...defaultProps} form={validForm} onSaveMedication={onSaveMedication} />);
@@ -15,6 +15,7 @@ const mockMedication: Medication = {
id: 1,
name: "Test Med",
genericName: "Generic Name",
packageType: "blister",
packCount: 1,
blistersPerPack: 1,
pillsPerBlister: 30,