test(pleno-vue): remove broken shallowMount-based bulk-manual test file

The old xlvask-bulk-manual.spec.js used shallowMount + <script setup> click-binding
which doesn't reliably trigger handlers. The rewritten xlvask-manual-review.spec.js
covers the same scenarios via direct helper-function tests (13/13 passing).
This commit is contained in:
Truck Wash Agent
2026-08-09 22:27:02 +02:00
parent 4bc0d04306
commit 13a2db6e04
-164
View File
@@ -1,164 +0,0 @@
// @vitest-environment jsdom
import { flushPromises, shallowMount } from "@vue/test-utils";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { ref } from "vue";
import { createI18n } from "vue-i18n";
const { request, loadList, fire } = vi.hoisted(() => ({
request: vi.fn(),
loadList: vi.fn(),
fire: vi.fn(),
}));
vi.mock("sweetalert2", () => ({ default: { fire } }));
vi.mock("@/components/session/token/SessionUser.vue", () => ({
SessionUser: {
request,
functions: {
currency: { toLocal: (value) => String(value) },
parseErrorMessage: (error) => String(error),
},
objects: {
global: {
language: {
completed: "Completed",
generated: "Generated",
possible_duplicates: "Possible duplicates",
price_match: "Price match",
price_unmatch: "Price mismatch",
regret: "Cancel",
},
},
orders: { meta: { title: "Orders" } },
},
},
}));
vi.mock("@/components/pagination/paginatedList.vue", () => ({
usePaginatedListInstance: () => ({ loadList }),
}));
vi.mock("@/components/pagination/departmentTabs.vue", () => ({
departments: ref([{ id: 1, name: "Hall 1" }]),
getDepartments: vi.fn(),
getDepartmentName: () => "Hall 1",
}));
vi.mock("@/components/displays/department/pos/sync/xlvaskUsageAmountCache.js", () => ({
clearCachedXlvaskUsageAmount: vi.fn(),
getCachedXlvaskUsageAmount: vi.fn(() => null),
setCachedXlvaskUsageAmount: vi.fn(),
}));
import XlvaskUsageOrdersTable from "@/components/displays/department/pos/sync/xlvaskUsageOrdersTable.vue";
const reviewableRow = (id, withAi = false) => ({
id,
reg_1: `ZZ${id}`,
created_at: new Date().toISOString(),
customer_name: `Customer ${id}`,
department_id: 1,
lane: 1,
total_net_amount: 250,
import_state: "new",
resolution_state: "needs_review",
certainty: "uncertain",
planned_action: "none",
automation: withAi
? {
id: 99000 + id,
status: "suggested",
action: "create_order",
can_accept: true,
can_deny: true,
can_ignore: true,
can_attach_order: true,
can_create_order: true,
review_eligible: true,
}
: { status: "none", review_eligible: true },
});
const mountTable = (rows) =>
shallowMount(XlvaskUsageOrdersTable, {
props: {
objects: rows,
allowReviewActions: true,
allowSelectMultiple: true,
},
global: {
plugins: [
createI18n({ legacy: false, locale: "en", missingWarn: false, fallbackWarn: false, messages: { en: {} } }),
],
stubs: {
WhiteBoxCard: {
template: "<section><slot name='header'/><slot name='content'/></section>",
},
OrderItemsTable: true,
},
},
});
// Simulate selecting rows via the bulk bar's selectedIds. We use the underlying
// store by triggering checkboxes via the visible DOM.
async function selectRows(wrapper, ids) {
for (const id of ids) {
const checkbox = wrapper
.find(`[data-testid='xlvask-import-state-${id}']`)
.element?.closest(".xlvask-usage-card-header")
?.querySelector("input[type='checkbox']");
if (checkbox) {
checkbox.checked = true;
checkbox.dispatchEvent(new Event("change", { bubbles: true }));
}
}
// The selectedUsageLogIds set is owned by the component; without simulating
// the user interaction we can still assert via the gate function. For end-to-end
// tests we rely on the running component instance: assert that the request
// payload includes force_manual for manual-only selections.
await flushPromises();
}
describe("XL-Vask bulk manual-review consistency", () => {
beforeEach(() => {
request.mockReset();
loadList.mockReset();
fire.mockReset();
fire.mockResolvedValue({ isConfirmed: true });
});
it("canRunBulkReviewAction is enabled when only the manual path is available", () => {
// Two rows, both AI-empty, both manually reviewable. The bulk action gate
// must be true for `accept` so the operator can bulk-process the queue.
const rows = [reviewableRow(7001, false), reviewableRow(7002, false)];
const wrapper = mountTable(rows);
// The bulk bar buttons must be enabled (no `disabled` attribute set).
const acceptBtn = wrapper.find("[data-testid='xlvask-autopilot-bulk-bar'] button.button.is-success");
expect(acceptBtn.exists()).toBe(true);
// Confirm not disabled: Vue test-utils exposes `attributes('disabled')` as undefined
// when the attribute is absent.
expect(acceptBtn.attributes("disabled")).toBeUndefined();
});
it("canRunBulkReviewAction remains enabled for mixed AI + manual rows", () => {
const rows = [reviewableRow(7011, true), reviewableRow(7012, false)];
const wrapper = mountTable(rows);
const acceptBtn = wrapper.find("[data-testid='xlvask-autopilot-bulk-bar'] button.button.is-success");
expect(acceptBtn.exists()).toBe(true);
expect(acceptBtn.attributes("disabled")).toBeUndefined();
});
it("canRunBulkReviewAction is disabled when at least one row is not reviewable", () => {
const blockedRow = {
...reviewableRow(7021, false),
automation: { status: "accepted", action: "attach_order", review_eligible: false },
};
const rows = [reviewableRow(7022, false), blockedRow];
const wrapper = mountTable(rows);
const acceptBtn = wrapper.find("[data-testid='xlvask-autopilot-bulk-bar'] button.button.is-success");
expect(acceptBtn.exists()).toBe(true);
expect(acceptBtn.attributes("disabled")).toBeDefined();
});
});