Files
mealie/frontend/app/components/Domain/Recipe/RecipeStepAllocationEditor.test.ts
T
jfmcarreira 8dad430650
Release Drafter / auto_label (push) Skipped
Release Drafter / draft_release (push) Canceled after 0s
CodeQL / Analyze (javascript-typescript) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
Backend Lint and Test / tests (sqlite) (push) Canceled after 0s
Backend Lint and Test / tests (postgres) (push) Canceled after 0s
Docker Nightly Production / Backend Server Tests (push) Canceled after 0s
Frontend Lint and Test / lint (push) Canceled after 0s
Docker Nightly Production / Frontend Tests (push) Canceled after 0s
Build Package / Build frontend and wheel (push) Canceled after 0s
Docker Nightly Production / Build Package (push) Canceled after 0s
Docker Nightly Production / Build E2E Image Cache (push) Canceled after 0s
Docker Nightly Production / Build Tagged Release (push) Canceled after 0s
Docker Nightly Production / Notify Discord (push) Canceled after 0s
feat(recipe): add step quantities and appliance settings
2026-12-01 13:05:50 +00:00

50 lines
2.7 KiB
TypeScript

import { mount } from "@vue/test-utils";
import { describe, expect, test } from "vitest";
import { createVuetify } from "vuetify";
import * as components from "vuetify/components";
import * as directives from "vuetify/directives";
import RecipeStepAllocationEditor from "./RecipeStepAllocationEditor.vue";
describe("allocation intent editor", () => {
test("does not change legacy quantities on mount and never infers scale activation", () => {
const wrapper = mount(RecipeStepAllocationEditor, {
props: { modelValue: { referenceId: "flour", quantity: null } },
global: { plugins: [createVuetify({ components, directives })] },
});
expect(wrapper.findComponent(components.VSelect).props("modelValue")).toBe("full");
expect(wrapper.emitted("update:modelValue")).toBeUndefined();
});
test("selects unknown safely and retains the association identity", async () => {
const wrapper = mount(RecipeStepAllocationEditor, {
props: { modelValue: { allocationId: "allocation", referenceId: "flour", quantity: 20, weighing: "weigh" } },
global: { plugins: [createVuetify({ components, directives })] },
});
await wrapper.findComponent(components.VSelect).vm.$emit("update:modelValue", "unknown");
expect(wrapper.emitted("update:modelValue")?.at(-1)).toEqual([{
allocationId: "allocation", referenceId: "flour", quantity: 0, quantityKind: "unknown", weighing: "unspecified",
}]);
});
test("edits partial portions and weighing independently", async () => {
const wrapper = mount(RecipeStepAllocationEditor, {
props: { modelValue: { allocationId: "allocation", referenceId: "flour", quantityKind: "partial", quantity: 0 } },
global: { plugins: [createVuetify({ components, directives })] },
});
await wrapper.findComponent(components.VNumberInput).vm.$emit("update:modelValue", 0.5);
expect(wrapper.emitted("update:modelValue")?.at(-1)?.[0]).toMatchObject({ quantity: 0.5, quantityKind: "partial" });
const weighing = wrapper.findAllComponents(components.VSelect)[1]!;
await weighing.vm.$emit("update:modelValue", "manual");
expect(wrapper.emitted("update:modelValue")?.at(-1)?.[0]).toMatchObject({ quantity: 0, weighing: "manual" });
});
test("requires a portion to be entered when an unknown amount is changed to partial", async () => {
const wrapper = mount(RecipeStepAllocationEditor, {
props: { modelValue: { referenceId: "flour", quantityKind: "unknown", quantity: 0 } },
global: { plugins: [createVuetify({ components, directives })] },
});
await wrapper.findComponent(components.VSelect).vm.$emit("update:modelValue", "partial");
expect(wrapper.emitted("update:modelValue")?.at(-1)?.[0]).toMatchObject({ quantityKind: "partial", quantity: null });
});
});