优化
This commit is contained in:
@@ -1,12 +1,37 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
describe('OceanBookingsView', () => { const source = readFileSync(resolve(process.cwd(), 'src/modules/ocean-bookings/pages/OceanBookingsView.vue'), 'utf8'); it('keeps the operation column first and left fixed', () => { expect(source.indexOf("key: 'actions'")).toBeLessThan(source.indexOf("prop: 'bookingNo'")); expect(source).toContain("fixed: 'left'") }); it('renders loading, empty and error through shared components', () => { expect(source).toContain('LoadErrorState'); expect(source).toContain(':loading="loading"'); expect(source).toContain(':total="total"') }); it('keeps real booking creation available without mixing draft rows into the formal list', () => { expect(source).toContain('<template #toolbar-actions>'); expect(source).toContain('新增订舱'); expect(source).toContain("router.push('/ocean-bookings/new')"); expect(source).toContain("access.can('platform:firstleg:ocean-booking:create')"); expect(source).not.toContain('PageToolbar') }); it('shows only the formal booking detail action', () => { expect(source).toContain('<Eye :size="15" />查看'); expect(source).not.toContain('<Pencil :size="15" />编辑'); expect(source).not.toContain('MoreHorizontal') }); it('limits status filters to the frozen formal booking states', () => { expect(source).toContain("['CONFIRMED', 'CHANGE_PENDING', 'RELEASED', 'CANCELLED']"); expect(source).toContain('options: formalStatusOptions'); expect(source).toContain(':status="oceanBookingStatusLabel(row.status)"'); expect(source).not.toContain(':status="row.status"') }) })
|
||||
|
||||
describe('OceanBookingsView prototype field matrix', () => {
|
||||
const source = readFileSync(resolve(process.cwd(), 'src/modules/ocean-bookings/pages/OceanBookingsView.vue'), 'utf8')
|
||||
const source = readFileSync(resolve(process.cwd(), 'src/modules/ocean-bookings/pages/OceanBookingsView.vue'), 'utf8')
|
||||
|
||||
it('keeps the frozen business field sequence after the first action column', () => {
|
||||
describe('OceanBookingsView', () => {
|
||||
it('keeps the operation column first and left fixed', () => {
|
||||
expect(source.indexOf("key: 'actions'")).toBeLessThan(source.indexOf("prop: 'bookingNo'"))
|
||||
expect(source).toContain("fixed: 'left'")
|
||||
})
|
||||
|
||||
it('renders loading, empty and error states and keeps draft creation available', () => {
|
||||
expect(source).toContain('LoadErrorState')
|
||||
expect(source).toContain(':loading="loading"')
|
||||
expect(source).toContain('新增订舱')
|
||||
expect(source).toContain("router.push('/ocean-bookings/new')")
|
||||
})
|
||||
|
||||
it('edits DRAFT rows and views RELEASED rows', () => {
|
||||
expect(source).toContain('<Pencil v-if="row.status === \'DRAFT\'"')
|
||||
expect(source).toContain("row.status === 'DRAFT' ? '编辑' : '查看'")
|
||||
expect(source).not.toContain('MoreHorizontal')
|
||||
})
|
||||
|
||||
it('uses only the frozen DRAFT and RELEASED status options', () => {
|
||||
expect(source).toContain('options: oceanBookingStatusOptions')
|
||||
expect(source).toContain(':status="oceanBookingStatusLabel(row.status)"')
|
||||
expect(source).not.toContain('CONFIRMED')
|
||||
expect(source).not.toContain('CHANGE_PENDING')
|
||||
expect(source).not.toContain('CANCELLED')
|
||||
})
|
||||
|
||||
it('keeps the prototype business field order after actions', () => {
|
||||
const fields = ['bookingNo', 'customerName', 'billOfLadingNo', 'shipperName', 'consigneeName', 'containerCount', 'carrierName', 'bookingAgent', 'vesselName', 'pol', 'pod', 'etd', 'eta', 'status', 'updatedAt']
|
||||
let previous = source.indexOf("key: 'actions'")
|
||||
for (const field of fields) {
|
||||
@@ -16,34 +41,10 @@ describe('OceanBookingsView prototype field matrix', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('formats schedule and update timestamps without adding print actions', () => {
|
||||
expect(source).toContain("prop: 'billOfLadingNo', label: '提单号'")
|
||||
expect(source).toContain("prop: 'containerCount', label: '柜量'")
|
||||
expect(source).toContain('<template #updatedAt="{ row }">{{ formatDateTime(row.updatedAt) }}</template>')
|
||||
expect(source).toContain('<template #etd="{ row }">{{ formatDateTime(row.etd) }}</template>')
|
||||
expect(source).not.toContain('打印')
|
||||
})
|
||||
})
|
||||
|
||||
describe('OceanBookingsView visual action contract', () => {
|
||||
const source = readFileSync(resolve(process.cwd(), 'src/modules/ocean-bookings/pages/OceanBookingsView.vue'), 'utf8')
|
||||
|
||||
it('uses bordered business buttons and stacks them on narrow screens', () => {
|
||||
expect(source).toContain('size="small" type="primary" plain')
|
||||
expect(source).not.toContain('link type="primary" @click="open(row.id)')
|
||||
expect(source).toContain('@media(max-width:420px)')
|
||||
expect(source).toContain('.table-actions')
|
||||
expect(source).toContain(':total="total" stripe preference-key="ocean-bookings"')
|
||||
})
|
||||
})
|
||||
|
||||
describe('OceanBookingsView customer filter contract', () => {
|
||||
const source = readFileSync(resolve(process.cwd(), 'src/modules/ocean-bookings/pages/OceanBookingsView.vue'), 'utf8')
|
||||
it('loads active customers, displays names only and submits customerId', () => {
|
||||
it('loads active customers by name and stays usable on narrow screens', () => {
|
||||
expect(source).toContain("listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' })")
|
||||
expect(source).toContain("customer.status === 'ACTIVE'")
|
||||
expect(source).toContain("label: customer.tenantName")
|
||||
expect(source).toContain("customerId: String(query.customerId || '') || undefined")
|
||||
expect(source).toContain('label: customer.tenantName')
|
||||
expect(source).not.toContain('customer.tenantCode')
|
||||
expect(source).toContain('@media(max-width:420px)')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user