Files
pleno-vue/tests/unit/pos-department-step-mobile-attachment.spec.js
T
Jeppe Bundgaard 0fa2284e89 Add connectivity issue handling logic and tests
- Add `ConnectivityIssue.vue` component for displaying server connection issues.
- Implement polling logic with retry intervals to check server health.
- Update i18n with new connectivity issue messages.
- Add unit tests to cover connectivity failure and recovery scenarios.
- Update test suite for breadth of coverage, including router contract and timer cleanup.
2026-05-28 18:11:21 +02:00

90 lines
2.7 KiB
JavaScript

// @vitest-environment jsdom
import { mount } from "@vue/test-utils";
import { describe, expect, it, vi } from "vitest";
import PosDepartmentStepMobileAttachment from "@/components/displays/department/pos/steps/mobile/elements/PosDepartmentStepMobileAttachment.vue";
import { createTestI18n } from "./helpers/mountWithApp.js";
const createMessages = () => ({
en: {
admin: {
pos: {
attachment: "Attachment",
attachments_add: "Add attachment",
attachments_download_action: "Download",
attachments_no_preview: "No preview",
attachments_upload_action: "Upload",
attachments_upload_description: "Upload an attachment",
delete: "Delete",
settings_wheel: {
attach_wash_certificate: "Attach wash certificate",
self_serve_customer: "Customer",
self_serve_driver: "Driver",
self_serve_elapsed: "Elapsed",
self_serve_wash_attachment: "Self-serve wash",
},
},
},
common: {
created: "Created",
},
pos: {
license_plate: "License plate",
},
},
});
const mountAttachmentList = (attachments) =>
mount(PosDepartmentStepMobileAttachment, {
props: {
attachments,
getPreviewLink: vi.fn(() => Promise.resolve("https://cdn.example.test/file.pdf")),
},
global: {
plugins: [createTestI18n(createMessages())],
stubs: {
WhiteBoxCard: {
template: "<section><slot name='header' /><slot name='content' /><slot name='footer' /></section>",
},
},
},
});
describe("PosDepartmentStepMobileAttachment", () => {
it("renders self-serve wash object attachments with readable metadata", () => {
const wrapper = mountAttachmentList([
{
id: 501,
object_type: "orders",
object_id: 42,
content: {
image: null,
document: null,
relation: null,
other: {
type: "SELF_SERVE_WASH",
customer_number: 123456,
subuser_id: 77,
subuser: {
name: "Driver One",
},
license_plate: "AB12345",
elapsed_wash_time_seconds: 601,
},
src: null,
},
created_at: "2026-05-28T10:00:00Z",
updated_at: null,
deleted_at: null,
},
]);
expect(wrapper.text()).toContain("Self-serve wash");
expect(wrapper.text()).toContain("Customer: #123456");
expect(wrapper.text()).toContain("Driver: Driver One");
expect(wrapper.text()).toContain("License plate: AB12345");
expect(wrapper.text()).toContain("Elapsed: 11 min");
expect(wrapper.text()).not.toContain("[object Object]");
});
});