38 lines
2.4 KiB
TypeScript
38 lines
2.4 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
import { resolve } from 'node:path'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
const pages = [
|
|
['src/modules/container-loading/pages/ContainersView.vue', ':loading="loading"', 'LoadErrorState', 'empty-text="暂无货柜"', 'statusText(row.planStatus)', 'platform:firstleg:container:list', '@retry="loadRows"'],
|
|
['src/modules/loading-lists/components/LoadingListsView.vue', ':loading="loading"', 'LoadErrorState', ':empty-text="`暂无符合筛选条件的${title}`"', 'loadingListStatusLabel(row.status)', 'canView', '@retry="load"'],
|
|
['src/modules/ocean-bookings/pages/OceanBookingsView.vue', ':loading="loading"', 'LoadErrorState', 'empty-text="暂无符合筛选条件的订舱"', 'oceanBookingStatusLabel(row.status)', "{{ row.status === 'DRAFT' ? '编辑' : '查看' }}", '@retry="load"'],
|
|
['src/modules/trucking/pages/TruckAppointmentsView.vue', ':loading="loading"', 'LoadErrorState', 'empty-text="暂无符合筛选条件的拖车预约"', 'statusLabel(row.status)', '@click="openDetail(row as TruckAppointmentResource)">详情</el-button>', '@retry="load"'],
|
|
] as const
|
|
|
|
function source(path: string) {
|
|
return readFileSync(resolve(process.cwd(), path), 'utf8')
|
|
}
|
|
|
|
describe('domestic outbound list state contracts', () => {
|
|
it.each(pages)('%s exposes loading, error, empty, translated status, detail action and retry states', (path, loading, error, empty, status, detailAction, retry) => {
|
|
const content = source(path)
|
|
expect(content).toContain(loading)
|
|
expect(content).toContain(error)
|
|
expect(content).toContain(empty)
|
|
expect(content).toContain(status)
|
|
expect(content).toContain(detailAction)
|
|
expect(content).toContain(retry)
|
|
})
|
|
|
|
it('keeps list component state when route details return to the cached workspace list', () => {
|
|
const layout = source('src/app/layouts/AppLayout.vue')
|
|
const oceanDetail = source('src/modules/ocean-bookings/pages/OceanBookingDetailView.vue')
|
|
const truckingDetail = source('src/modules/trucking/pages/TruckAppointmentDetailView.vue')
|
|
|
|
expect(layout).toContain('<KeepAlive :max="MAX_CACHED_WORKSPACE_VIEWS">')
|
|
expect(layout).toContain(':key="workspace.cacheKey(workspaceRouteId(renderedRoute)) + \':\' + JSON.stringify(renderedRoute.params)"')
|
|
expect(oceanDetail).toContain("router.push('/ocean-bookings')")
|
|
expect(truckingDetail).toContain("router.push({ name: 'trucking' })")
|
|
})
|
|
})
|