- Introduced `.prettierrc.json` to enforce consistent code formatting across the project. - Updated unit and e2e test files to address formatting issues, improve readability, and ensure alignment with the new Prettier configuration.
76 lines
2.0 KiB
JavaScript
76 lines
2.0 KiB
JavaScript
// @vitest-environment jsdom
|
|
import { mount } from "@vue/test-utils";
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { nextTick } from "vue";
|
|
|
|
const mocks = vi.hoisted(() => ({
|
|
showEditObjectFieldForm: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("@/components/session/token/SessionUser.vue", () => ({
|
|
SessionUser: {
|
|
objects: {
|
|
collectedOrderInvoices: {
|
|
showEditObjectFieldForm: mocks.showEditObjectFieldForm,
|
|
},
|
|
global: {
|
|
language: {
|
|
no_data: "Ingen data",
|
|
},
|
|
},
|
|
},
|
|
functions: {
|
|
currency: {
|
|
toLocal: (value) => `${value}`,
|
|
},
|
|
},
|
|
},
|
|
}));
|
|
|
|
import CollectedOrderInvoiceOverview from "@/views/dashboards/superUserDashboard/collectedOrderInvoice/displays/collectedOrderInvoiceOverview.vue";
|
|
|
|
describe("CollectedOrderInvoiceOverview", () => {
|
|
beforeEach(() => {
|
|
mocks.showEditObjectFieldForm.mockReset();
|
|
});
|
|
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
it("triggers closed_at edit flow and emits updated", async () => {
|
|
mocks.showEditObjectFieldForm.mockImplementation(async (id, column, value, onAfterSubmit) => {
|
|
onAfterSubmit?.();
|
|
return {};
|
|
});
|
|
|
|
const wrapper = mount(CollectedOrderInvoiceOverview, {
|
|
props: {
|
|
invoices: [{ id: 1 }, { id: 2 }],
|
|
total: 2,
|
|
collectedOrderInvoice: {
|
|
id: 14560,
|
|
total_net_amount: 9894,
|
|
closed_at: "2026-04-08 11:43:01",
|
|
external_id: "X-100",
|
|
po_number: null,
|
|
},
|
|
},
|
|
});
|
|
|
|
await wrapper.get('[data-test="edit-closed-at-button"]').trigger("click");
|
|
await nextTick();
|
|
|
|
expect(mocks.showEditObjectFieldForm).toHaveBeenCalledTimes(1);
|
|
expect(mocks.showEditObjectFieldForm).toHaveBeenCalledWith(
|
|
14560,
|
|
"closed_at",
|
|
"2026-04-08 11:43:01",
|
|
expect.any(Function)
|
|
);
|
|
|
|
expect(wrapper.emitted("updated")).toBeTruthy();
|
|
expect(wrapper.emitted("updated").length).toBe(1);
|
|
});
|
|
});
|