// @vitest-environment jsdom import { computed, nextTick } from "vue"; import { mount } from "@vue/test-utils"; import { beforeEach, describe, expect, it, vi } from "vitest"; const { sharedVariablesRef, currentViewRef, startDateRef, endDateRef, queueRef, inProgressRef } = vi.hoisted(() => { const { ref } = require("vue"); return { sharedVariablesRef: ref({ types: { all: [] } }), currentViewRef: ref("all"), startDateRef: ref(new Date("2026-04-01T00:00:00.000Z")), endDateRef: ref(new Date("2026-04-30T23:59:59.000Z")), queueRef: ref([]), inProgressRef: ref([]), }; }); vi.mock("@/services/economicTransferQueue.js", () => ({ ECONOMIC_QUEUE_STATUS: { QUEUED: "QUEUED", PROCESSING: "PROCESSING", COMPLETED: "COMPLETED", FAILED: "FAILED", }, })); vi.mock("@/components/session/token/SessionUser.vue", () => ({ SessionUser: { objects: { global: { language: { processing: "Processing", queued: "Queued", all_booked: "All booked", none: "None", invoice_now: "Invoice now", }, }, orders: { meta: { labels: { single: "order", multiple: "orders", }, }, get: { multiple: vi.fn().mockResolvedValue([]), }, }, collectedOrderInvoices: { functions: { createVehicleSubscriptionInvoice: vi.fn(), add_fixed_pricing: vi.fn(), add_vehicle_subscriptions: vi.fn(), }, }, vehicles: { columns: { wash_subscription: { label: "Subscription", }, }, }, }, functions: { currency: { toLocal: (value) => String(value), }, }, }, })); vi.mock( "@/views/dashboards/superUserDashboard/InvoicingBillingPeriod/imports/InvoicingBillingPeriodImportView.vue", () => ({ view: { variables: { currentView: currentViewRef, sharedVariables: sharedVariablesRef, }, computed: { componentName: computed(() => currentViewRef.value), }, functions: { filterExcluded: (transactions = []) => transactions.filter((transaction) => !transaction?.excluded), getCustomerViewTotalNetAmount: (customer) => { const transactions = Array.isArray(customer?.transactions) ? customer.transactions : []; return transactions.reduce((sum, transaction) => sum + Number(transaction?.amount ?? 0), 0); }, }, }, }) ); vi.mock( "@/views/dashboards/superUserDashboard/InvoicingBillingPeriod/imports/InvoicingBillingPeriodImportDates.vue", () => ({ dates: { variables: { start: startDateRef, end: endDateRef, }, }, }) ); vi.mock( "@/views/dashboards/superUserDashboard/InvoicingBillingPeriod/imports/InvoicingBillingPeriodImportInvoiceQueue.vue", () => ({ invoiceQueue: { addInvoiceCollectionsToQueue: vi.fn(), processInvoiceCollectionQueue: vi.fn(), invoiceCollectionQueue: queueRef, invoiceCollectionQueueInProgress: inProgressRef, invoiceCollectionQueueFailed: require("vue").ref([]), invoiceCollectionQueueSuccess: require("vue").ref([]), }, }) ); import InvoicingBillingPeriodViewAll from "@/views/dashboards/superUserDashboard/InvoicingBillingPeriod/views/InvoicingBillingPeriodViewAll.vue"; const mountView = () => mount(InvoicingBillingPeriodViewAll, { global: { stubs: { InvoicingBillingPeriodStatistics: { template: "
" }, InvoicingBillingPeriodFilters: { template: "" }, WhiteBox: { template: "