feat: simplify tube stock editing UI (#357)
* feat: add package amount persistence and backend route support * test: align backend test schemas with medication metadata fields * fix(backend): restore intake usage normalizer for planner endpoint * fix(backend): keep export typing compatible before liquid-unit stack step * feat: simplify tube stock editing in desktop and mobile forms
This commit is contained in:
@@ -8,6 +8,9 @@ const defaultForm: FormState = {
|
||||
name: "",
|
||||
genericName: "",
|
||||
takenBy: [],
|
||||
medicationForm: "tablet",
|
||||
pillForm: "tablet",
|
||||
lifecycleCategory: "refill_when_empty",
|
||||
packageType: "blister",
|
||||
packCount: "1",
|
||||
blistersPerPack: "1",
|
||||
@@ -17,6 +20,8 @@ const defaultForm: FormState = {
|
||||
pillWeightMg: "",
|
||||
doseUnit: "mg",
|
||||
medicationStartDate: "",
|
||||
medicationEndDate: "",
|
||||
autoMarkObsoleteAfterEndDate: true,
|
||||
expiryDate: "",
|
||||
notes: "",
|
||||
intakeRemindersEnabled: false,
|
||||
@@ -235,6 +240,54 @@ describe("MobileEditModal", () => {
|
||||
const header = document.querySelector(".edit-modal-header");
|
||||
expect(header).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("uses plain numeric input for tube amount without stepper controls", () => {
|
||||
render(
|
||||
<MobileEditModal
|
||||
{...defaultProps}
|
||||
form={{
|
||||
...defaultForm,
|
||||
packageType: "tube",
|
||||
medicationForm: "topical",
|
||||
packageAmountValue: "150",
|
||||
packageAmountUnit: "g",
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
const amountInput = screen.getByLabelText("form.packageAmountPerTube") as HTMLInputElement;
|
||||
expect(amountInput).toBeInTheDocument();
|
||||
expect(amountInput.tagName).toBe("INPUT");
|
||||
expect(amountInput).toHaveAttribute("inputmode", "decimal");
|
||||
|
||||
const unitSelect = screen.getByLabelText("form.packageAmountUnitG") as HTMLSelectElement;
|
||||
expect(unitSelect).toBeDisabled();
|
||||
expect(unitSelect.value).toBe("g");
|
||||
});
|
||||
|
||||
it("uses plain numeric input for liquid container package amount", () => {
|
||||
render(
|
||||
<MobileEditModal
|
||||
{...defaultProps}
|
||||
form={{
|
||||
...defaultForm,
|
||||
packageType: "liquid_container",
|
||||
medicationForm: "liquid",
|
||||
packageAmountValue: "250",
|
||||
packageAmountUnit: "ml",
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
const amountInput = screen.getByLabelText("form.packageAmount") as HTMLInputElement;
|
||||
expect(amountInput).toBeInTheDocument();
|
||||
expect(amountInput.tagName).toBe("INPUT");
|
||||
expect(amountInput).toHaveAttribute("inputmode", "decimal");
|
||||
|
||||
const unitSelect = screen.getByLabelText("form.packageAmountUnitMl") as HTMLSelectElement;
|
||||
expect(unitSelect).toBeDisabled();
|
||||
expect(unitSelect.value).toBe("ml");
|
||||
});
|
||||
});
|
||||
|
||||
describe("MobileEditModal with existing people", () => {
|
||||
|
||||
Reference in New Issue
Block a user