44 lines
2.3 KiB
TypeScript
44 lines
2.3 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
import { resolve } from 'node:path'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
const source = readFileSync(resolve(process.cwd(), 'src/modules/trucking/components/TruckAttachmentDialog.vue'), 'utf8')
|
|
|
|
describe('TruckAttachmentDialog interaction governance', () => {
|
|
it('shows existing attachments without exposing file-service internals', () => {
|
|
expect(source).toContain('预约附件')
|
|
expect(source).toContain('attachmentTypeLabel(item.attachmentType)')
|
|
expect(source).not.toContain('文件 ID')
|
|
expect(source).not.toContain('item.objectKey')
|
|
})
|
|
|
|
it('provides scoped upload and deletion without exposing manual file ids', () => {
|
|
expect(source).not.toContain("BILL_OF_LADING: '提单文件'")
|
|
expect(source).toContain("DISPATCH_ORDER: '派车单'")
|
|
expect(source).not.toContain('referenceTruckAppointmentAttachment')
|
|
expect(source).not.toContain('输入文件服务 ID')
|
|
expect(source).toContain('uploadTruckAppointmentAttachment')
|
|
expect(source).toContain('上传并关联')
|
|
expect(source).toContain('deleteTruckAppointmentAttachment')
|
|
expect(source).toContain("confirmButtonText: '确认', cancelButtonText: '取消'")
|
|
expect(source).toContain('@click="remove(item)">删除</el-button>')
|
|
expect(source).toContain('size="small" type="danger" plain')
|
|
expect(source).not.toContain(' text type="danger"')
|
|
})
|
|
|
|
it('keeps list-only access read-only and preserves traced mutation failures', () => {
|
|
expect(source).toContain('v-if="props.canManage" class="upload-panel"')
|
|
expect(source).toContain('props.appointmentId && props.canManage && item.id')
|
|
expect(source).toContain('if (busy.value || !props.appointmentId || !selectedFile.value || !props.canManage) return')
|
|
expect(source).toContain('if (busy.value || !props.appointmentId || !item.id || !props.canManage) return')
|
|
expect(source).toContain("getApiErrorDetails(cause, '附件上传失败,请稍后重试')")
|
|
expect(source).toContain("getApiErrorDetails(cause, '附件删除失败,请稍后重试')")
|
|
expect(source).toContain('<ApiErrorMeta :details="error" />')
|
|
})
|
|
|
|
it('wraps long Unicode file names without hiding the actions', () => {
|
|
expect(source).toContain('overflow-wrap:anywhere')
|
|
expect(source).toContain('.attachment-row>div{min-width:0}')
|
|
})
|
|
})
|