Files
pleno-vue/tests/unit/admin-orders-pagination-contract.spec.js
T
2026-07-16 11:45:08 +02:00

54 lines
2.8 KiB
JavaScript

import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
const root = process.cwd();
const departmentOrdersPaginationSource = readFileSync(
join(root, "src/components/displays/pagination/models/DepartmentPos/OrdersPagination.vue"),
"utf8"
);
const invoiceOrdersPaginationSource = readFileSync(
join(root, "src/components/displays/pagination/models/SuperUserDashboard/InvoiceOrdersPagination.vue"),
"utf8"
);
const tableLabeledPaginationSource = readFileSync(
join(root, "src/components/displays/pagination/TableLabeledPagination.vue"),
"utf8"
);
describe("admin orders pagination filter reuse", () => {
it("delegates department order lists to the shared filtered pagination", () => {
expect(departmentOrdersPaginationSource).toContain("<InvoiceOrdersPagination");
expect(departmentOrdersPaginationSource).toContain(':apply-default-filters="false"');
expect(departmentOrdersPaginationSource).toContain(':show-department-filter="false"');
expect(departmentOrdersPaginationSource).toContain(':show-label="false"');
expect(departmentOrdersPaginationSource).toContain(':invoice-view="false"');
expect(departmentOrdersPaginationSource).toContain(':allow-select-multiple="false"');
});
it("forwards the history and draft constraints through the adapter", () => {
expect(departmentOrdersPaginationSource).toContain(
':only-from-invoice-collection="props.onlyFromInvoiceCollection"'
);
expect(departmentOrdersPaginationSource).toContain(':set-customer-filter="props.setCustomerFilter"');
expect(departmentOrdersPaginationSource).toContain(
':show-draft-assignment-actions="props.showDraftAssignmentActions"'
);
expect(departmentOrdersPaginationSource).toContain(':hide-search="props.hideSearch"');
expect(departmentOrdersPaginationSource).toContain(':auto-load="props.autoLoad"');
});
it("keeps the shared pagination configurable without changing superuser defaults", () => {
expect(invoiceOrdersPaginationSource).toContain("showDepartmentFilter:");
expect(invoiceOrdersPaginationSource).toContain("showLabel:");
expect(invoiceOrdersPaginationSource).toContain("allowSelectMultiple:");
expect(invoiceOrdersPaginationSource).toContain('v-if="props.showDepartmentFilter"');
expect(invoiceOrdersPaginationSource).toContain(':show-label="props.showLabel"');
expect(invoiceOrdersPaginationSource).toContain(':allowSelectMultiple="props.allowSelectMultiple"');
expect(invoiceOrdersPaginationSource).toContain("const currentDepartmentId = resolveDepartmentId();");
expect(invoiceOrdersPaginationSource).toContain('setFilter("department_id", currentDepartmentId, false);');
expect(tableLabeledPaginationSource).toContain("showLabel:");
expect(tableLabeledPaginationSource).toContain('v-if="props.showLabel"');
});
});