Files
pleno-vue/tests/unit/superuser-vehicle-view.spec.js
Jeppe Bundgaard b39b458f4f Add .prettierrc.json and refactor test files for improved formatting consistency:
- 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.
2026-04-13 09:13:27 +02:00

85 lines
3.9 KiB
JavaScript

import { readFileSync } from "node:fs";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
const root = process.cwd();
const routerSource = readFileSync(join(root, "src/router.js"), "utf8");
const vehicleViewSource = readFileSync(
join(root, "src/views/dashboards/superUserDashboard/vehicle/Vehicle.vue"),
"utf8"
);
const vehicleUtilsSource = readFileSync(
join(root, "src/views/dashboards/superUserDashboard/vehicle/imports/vehicleViewUtils.js"),
"utf8"
);
describe("superuser vehicle route contract", () => {
it("maps vehicle details route to registrationnumber path parameter", () => {
expect(routerSource).toContain("name: 'vehiclesvehicle'");
expect(routerSource).toContain("path: '/superuser/vehicles/:registrationnumber'");
expect(routerSource).toContain("component: Vehicle");
});
});
describe("superuser vehicle tabbed view contract", () => {
it("renders all required tabs using buefy tabs", () => {
expect(vehicleViewSource).toContain("<b-tabs");
expect(vehicleViewSource).toContain('label="Overview"');
expect(vehicleViewSource).toContain('label="Washes"');
expect(vehicleViewSource).toContain('label="Customers"');
expect(vehicleViewSource).toContain('label="Vehicle details"');
expect(vehicleViewSource).toContain('label="Diagrams"');
});
it("uses OpenAPI-aligned endpoints for vehicle intelligence data", () => {
expect(vehicleViewSource).toContain("'/vehicles'");
expect(vehicleViewSource).toContain("'/vehicles/status'");
expect(vehicleViewSource).toContain("'/vehicles/search'");
expect(vehicleViewSource).toContain("'/modules/xlvask/usageLog'");
expect(vehicleViewSource).toContain("'/modules/xlvask/vehicles'");
expect(vehicleViewSource).toContain("'/modules/xlvask/customers'");
expect(vehicleViewSource).toContain("'/superuser/users-with-vehicle-subscriptions'");
});
it("includes buefy table/filter controls across washes/customers/details", () => {
expect(vehicleViewSource).toContain("<b-table");
expect(vehicleViewSource).toContain("<b-field");
expect(vehicleViewSource).toContain("<b-input");
expect(vehicleViewSource).toContain("<b-select");
expect(vehicleViewSource).toContain("Apply filters");
expect(vehicleViewSource).toContain("Refresh details");
expect(vehicleViewSource).toContain("Download Excel");
});
it("exposes per-table excel exports for washes/customers/details/search", () => {
expect(vehicleViewSource).toContain("exportWashesToExcel");
expect(vehicleViewSource).toContain("exportCustomersToExcel");
expect(vehicleViewSource).toContain("exportSubscriptionUsersToExcel");
expect(vehicleViewSource).toContain("exportVehiclesToExcel");
expect(vehicleViewSource).toContain("exportXlvaskVehiclesToExcel");
expect(vehicleViewSource).toContain("exportSearchResultsToExcel");
});
it("renders all requested diagrams", () => {
expect(vehicleViewSource).toContain('title="Order frequency"');
expect(vehicleViewSource).toContain('title="Order item frequency"');
expect(vehicleViewSource).toContain('title="Department visits"');
expect(vehicleViewSource).toContain("<VehicleAnalyticsChart");
});
});
describe("superuser vehicle openapi filter/options contract", () => {
it("builds usage log and vehicles query objects with page/per_page and filters", () => {
expect(vehicleUtilsSource).toContain("buildUsageLogQuery");
expect(vehicleUtilsSource).toContain("buildVehiclesQuery");
expect(vehicleUtilsSource).toContain("per_page");
expect(vehicleUtilsSource).toContain("perPage");
expect(vehicleUtilsSource).toContain("page");
expect(vehicleUtilsSource).toContain("customer_id");
expect(vehicleUtilsSource).toContain("regNr");
expect(vehicleUtilsSource).toContain("vehicleId");
expect(vehicleUtilsSource).toContain("customerId");
expect(vehicleUtilsSource).toContain("dateFrom");
});
});