test(pleno-vue): pin historical_primary_product_mismatch flag rendering (#285)

Two regression tests for InvoicingPeriodFlagList.vue covering the historical_primary_product_mismatch flag render path via flagMessageParts() → flag.message fallback. No production FE code change needed.

E2E-pr-{pr,smoke}-chromium jobs hung on Playwright container step (same known flake as #275/#280/#286). Admin override used; all Required CI (format, lint, i18n, build, unit-fast, unit-serial, E2E-pr-changed/ct both browsers, App Store Readiness, Qodana) passed.
This commit is contained in:
Jeppe B
2026-08-11 07:39:17 +02:00
committed by GitHub
parent e4bd3420c6
commit 58adb1bef5
@@ -466,4 +466,64 @@ describe("InvoicingPeriodFlagList", () => {
});
expect(wrapper.emitted("statusChanged")).toHaveLength(2);
});
// Regression test for TBC-105 / error-report #10: a `historical_primary_product_mismatch`
// flag must surface the historical product name (e.g. "Forvogn med hænger") through the
// i18n message_key path. The backend now only emits this flag when the current row's reg_2
// presence matches the historical orders' reg_2 presence, so the FE must render whatever
// the API does send. As of this commit there is no specific handler in flagMessageParts()
// for `historical_primary_product_mismatch`; the component falls back to flag.message.
// This test pins that contract so any future handler addition doesn't regress the
// visible text on existing deployments.
it("renders historical_primary_product_mismatch automatic flags with the historical product name", () => {
const wrapper = mountList([
{
id: "auto-historical-1",
source: "automatic",
fingerprint: "historical-fingerprint-1",
target_type: "order_item",
target_id: 905,
definition_key: "historical_primary_product_mismatch",
message_key: "invoice_period.flags.automatic.historical_primary_product_mismatch",
message_params: {
product: "Forvogn",
expected_product: "Forvogn med hænger",
},
message: "Forvogn differs from the registration number's usual product Forvogn med hænger.",
order_id: 502,
order_item_id: 905,
},
]);
const row = wrapper.get('[data-testid="invoice-period-flag-auto-historical-1"]');
expect(row.text()).toContain("Forvogn");
expect(row.text()).toContain("differs from");
expect(row.text()).toContain("Forvogn med hænger");
// The component does not yet emit an interactive order-item token for this flag type;
// pinning the current behaviour so the eventual handler addition is intentional.
expect(row.findAll(".invoice-period-flag-token")).toHaveLength(0);
});
// Backstop: the API may still send `historical_primary_product_mismatch` with no
// message_params (older API versions, or a row that was cached before the schema bump).
// The FE must not blow up; it should fall back to flag.message verbatim.
it("falls back to flag.message when historical_primary_product_mismatch has no message_params", () => {
const wrapper = mountList([
{
id: "auto-historical-2",
source: "automatic",
fingerprint: "historical-fingerprint-2",
target_type: "order_item",
target_id: 906,
definition_key: "historical_primary_product_mismatch",
message_key: "invoice_period.flags.automatic.historical_primary_product_mismatch",
message: "Spot Free differs from the registration number's usual product Forvogn med hænger.",
},
]);
const row = wrapper.get('[data-testid="invoice-period-flag-auto-historical-2"]');
expect(row.text()).toContain("Spot Free differs from the registration number's usual product Forvogn med hænger.");
// No order-item token because order_id is missing — should fall back to plain text only.
expect(row.findAll(".invoice-period-flag-token")).toHaveLength(0);
});
});