37 lines
1.8 KiB
TypeScript
37 lines
1.8 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|||
|
|
import { readFileSync } from 'node:fs'
|
||
|
|
import { resolve } from 'node:path'
|
||
|
|
|
||
|
|
const source = readFileSync(resolve(process.cwd(), 'src/modules/loading-lists/components/LoadingListsView.vue'), 'utf8')
|
||
|
|
const detailSource = readFileSync(resolve(process.cwd(), 'src/modules/loading-lists/components/LoadingListDetailDrawer.vue'), 'utf8')
|
||
|
|
|
||
|
|
describe('LoadingListsView', () => {
|
||
|
|
it('keeps the operation column first and fixed left in both lists', () => {
|
||
|
|
const actionColumns = [...source.matchAll(/key: 'actions', label: '操作', fixed: 'left'/g)]
|
||
|
|
expect(actionColumns).toHaveLength(2)
|
||
|
|
expect(source.indexOf("key: 'actions'")).toBeLessThan(source.indexOf("key: 'preloadNo'"))
|
||
|
|
expect(source.indexOf("key: 'actions'", source.indexOf("key: 'actions'") + 1)).toBeLessThan(source.indexOf("key: 'loadingListNo'"))
|
||
|
|
})
|
||
|
|
|
||
|
|
it('requires a warehouse before sending a list request', () => {
|
||
|
|
expect(source).toContain("if (!warehouseId) return null")
|
||
|
|
expect(source).toContain("ElMessage.warning('请先选择仓库')")
|
||
|
|
expect(source).toContain("'请先选择仓库后查询'")
|
||
|
|
})
|
||
|
|
|
||
|
|
it('uses the shared query, table, drawer, dialog and error components', () => {
|
||
|
|
expect(source).toContain('QueryToolbar')
|
||
|
|
expect(source).toContain('DataTable')
|
||
|
|
expect(source).toContain('AppDialog')
|
||
|
|
expect(source).toContain('LoadErrorState')
|
||
|
|
expect(source).toContain('ApiErrorMeta')
|
||
|
|
expect(detailSource).toContain('AppDrawer')
|
||
|
|
})
|
||
|
|
|
||
|
|
it('only exposes transport editing for LOADING preload details', () => {
|
||
|
|
expect(detailSource).toContain("mode === 'preload' && canEdit && summary.status === 'LOADING'")
|
||
|
|
expect(detailSource).toContain('装柜完成后清单、明细和运输信息永久只读')
|
||
|
|
expect(source).toContain('expectedVersion: detail.value.summary.version')
|
||
|
|
})
|
||
|
|
})
|