2026-08-12 12:35:32 +08:00
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { describe , expect , it } from 'vitest'
const pages = [
2026-08-13 11:57:44 +08:00
[ 'src/modules/container-loading/pages/ContainersView.vue' , ':loading="loading"' , 'LoadErrorState' , 'empty-text="暂无货柜"' , 'statusText(row.planStatus)' , 'platform:firstleg:container:list' , '@retry="loadRows"' ],
2026-08-12 14:08:33 +08:00
[ 'src/modules/loading-lists/components/LoadingListsView.vue' , ':loading="loading"' , 'LoadErrorState' , ':empty-text="`暂无符合筛选条件的${title}`"' , 'loadingListStatusLabel(row.status)' , 'canView' , '@retry="load"' ],
2026-08-19 16:45:51 +08:00
[ 'src/modules/ocean-bookings/pages/OceanBookingsView.vue' , ':loading="loading"' , 'LoadErrorState' , 'empty-text="暂无符合筛选条件的订舱"' , 'oceanBookingStatusLabel(row.status)' , "{{ row.status === 'DRAFT' ? '编辑' : '查看' }}" , '@retry="load"' ],
2026-09-14 20:03:27 +08:00
[ 'src/modules/trucking/pages/TruckAppointmentsView.vue' , ':loading="loading"' , 'LoadErrorState' , 'empty-text="暂无符合筛选条件的拖车预约"' , 'statusLabel(row.status)' , '@click="openDetail(row as TruckAppointmentResource)">详情</el-button>' , '@retry="load"' ],
2026-08-12 12:35:32 +08:00
] as const
function source ( path : string ) {
return readFileSync ( resolve ( process . cwd (), path ), 'utf8' )
}
describe ( 'domestic outbound list state contracts' , () => {
2026-08-13 11:57:44 +08:00
it . each ( pages )( '%s exposes loading, error, empty, translated status, detail action and retry states' , ( path , loading , error , empty , status , detailAction , retry ) => {
2026-08-12 12:35:32 +08:00
const content = source ( path )
expect ( content ). toContain ( loading )
expect ( content ). toContain ( error )
expect ( content ). toContain ( empty )
expect ( content ). toContain ( status )
2026-08-13 11:57:44 +08:00
expect ( content ). toContain ( detailAction )
2026-08-12 14:08:33 +08:00
expect ( content ). toContain ( retry )
2026-08-12 12:35:32 +08:00
})
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">' )
2026-08-27 21:48:15 +08:00
expect ( layout ). toContain ( ':key="workspace.cacheKey(workspaceRouteId(renderedRoute)) + \':\' + JSON.stringify(renderedRoute.params)"' )
2026-08-12 12:35:32 +08:00
expect ( oceanDetail ). toContain ( "router.push('/ocean-bookings')" )
expect ( truckingDetail ). toContain ( "router.push({ name: 'trucking' })" )
})
})