import test from 'node:test' import assert from 'node:assert/strict' import fs from 'node:fs' import vm from 'node:vm' import { createRequire } from 'node:module' import { buildMinioAttachmentUrl, minioAttachmentPath } from '../src/utils/minioAttachment.js' const base = 'https://files.example.test/attachments/' const path = '/2026/10/09/workOrder/jpg/4649512327058833952.jpg' test('相对路径展示时补 MinIO 基址,存储时保持相对路径', () => { assert.equal(buildMinioAttachmentUrl(path, base), base + path.slice(1)) assert.equal(buildMinioAttachmentUrl(path.slice(1), base), base + path.slice(1)) assert.equal(minioAttachmentPath(base + path.slice(1), base), path) assert.equal(minioAttachmentPath(path, base), path) assert.equal(buildMinioAttachmentUrl('', base), '') assert.equal(buildMinioAttachmentUrl('https://legacy.test/a.jpg', base), 'https://legacy.test/a.jpg') }) test('上传、回显、追加和删除不将展示 URL 回写到工单', () => { const source = fs.readFileSync(new URL('../src/components/ImageUpload/index.vue', import.meta.url), 'utf8') const script = source.match(/