优化
This commit is contained in:
@@ -3,6 +3,8 @@ import { join } from 'node:path'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
const source = readFileSync(join(process.cwd(), 'src/modules/fba-pricing/carrier-rates/pages/CarrierRatesView.vue'), 'utf8')
|
||||
const detailSource = readFileSync(join(process.cwd(), 'src/modules/fba-pricing/carrier-rates/pages/CarrierRateDetailView.vue'), 'utf8')
|
||||
const routeSource = readFileSync(join(process.cwd(), 'src/modules/fba-pricing/routes.ts'), 'utf8')
|
||||
const queryToolbarSource = readFileSync(join(process.cwd(), 'src/shared/components/QueryToolbar.vue'), 'utf8')
|
||||
|
||||
describe('CarrierRatesView price-book source contract', () => {
|
||||
@@ -19,13 +21,14 @@ describe('CarrierRatesView price-book source contract', () => {
|
||||
})
|
||||
|
||||
it('uses only the parsed price-book workflow instead of legacy carrier-rate editing', () => {
|
||||
const workflowSource = `${source}\n${detailSource}`
|
||||
for (const capability of [
|
||||
'listPlatformPriceBooks',
|
||||
'getPlatformPriceBook',
|
||||
'uploadPlatformPriceBook',
|
||||
'publishPlatformPriceBook',
|
||||
'downloadPlatformPriceBookSource',
|
||||
]) expect(source).toContain(capability)
|
||||
]) expect(workflowSource).toContain(capability)
|
||||
|
||||
for (const legacyCapability of [
|
||||
'createPlatformCarrierRateVersion',
|
||||
@@ -35,43 +38,47 @@ describe('CarrierRatesView price-book source contract', () => {
|
||||
'编辑价格',
|
||||
'有效期',
|
||||
'生效日期',
|
||||
]) expect(source).not.toContain(legacyCapability)
|
||||
]) expect(workflowSource).not.toContain(legacyCapability)
|
||||
})
|
||||
|
||||
it('keeps uploaded prices immutable and makes confirmation the only edit action', () => {
|
||||
it('opens a formal detail route and keeps uploaded prices immutable', () => {
|
||||
expect(source).toContain('上传并解析')
|
||||
expect(source).toContain('查看并确认')
|
||||
expect(source).toContain('确认并立即生效')
|
||||
expect(source).toContain('价格行不可在页面内修改')
|
||||
expect(source).toContain('confirmPriceBook')
|
||||
expect(source).toContain('publishPlatformPriceBook')
|
||||
expect(source).not.toContain('草稿')
|
||||
expect(source).toContain("name: 'fba-carrier-rate-detail'")
|
||||
expect(routeSource).toContain("path: 'first-leg-pricing/carrier-rates/:versionId'")
|
||||
expect(routeSource).toContain("import('./carrier-rates/pages/CarrierRateDetailView.vue')")
|
||||
expect(detailSource).toContain('返回列表')
|
||||
expect(detailSource).toContain('确认并立即生效')
|
||||
expect(detailSource).toContain('价格行不可在页面内修改')
|
||||
expect(detailSource).toContain('confirmPriceBook')
|
||||
expect(detailSource).toContain('publishPlatformPriceBook')
|
||||
expect(`${source}\n${detailSource}`).not.toContain('草稿')
|
||||
})
|
||||
|
||||
it('shows all source-backed prototype price metadata without inventing cost breakdowns', () => {
|
||||
for (const label of ['渠道', '参考时效', '最晚进仓时间', '船期', '附加费', '备注', '生效状态']) {
|
||||
expect(source).toContain(`label="${label}"`)
|
||||
expect(detailSource).toContain(`label="${label}"`)
|
||||
}
|
||||
for (const field of ['referenceTransit', 'latestWarehouseEntry', 'estimatedDepartureText', 'surchargeDescription', 'remark']) {
|
||||
expect(source).toContain(`selectedChannel?.${field}`)
|
||||
expect(detailSource).toContain(`selectedChannel?.${field}`)
|
||||
}
|
||||
expect(source).not.toContain('AMS+换单费')
|
||||
expect(source).not.toContain('建议报价')
|
||||
expect(detailSource).not.toContain('AMS+换单费')
|
||||
expect(detailSource).not.toContain('建议报价')
|
||||
})
|
||||
|
||||
it('maps only active platform public domestic and overseas warehouses before confirmation', () => {
|
||||
expect(source).toContain('listAllPlatformWarehouses()')
|
||||
expect(source).toContain("warehouse.warehouseType === 'DOMESTIC'")
|
||||
expect(source).toContain("warehouse.warehouseType === 'OVERSEAS'")
|
||||
expect(source).toContain('起运仓映射')
|
||||
expect(source).toContain('海外仓映射')
|
||||
expect(source).toContain('originWarehouseCode')
|
||||
expect(source).toContain('sourceDestinationName')
|
||||
expect(source).toContain('autoSelectExactWarehouseMappings')
|
||||
expect(source).toContain("'DUPLICATE_RATE'")
|
||||
expect(source).toContain('.channel-tabs { width: 100%; min-width: 0;')
|
||||
expect(source).toContain('.channel-preview :deep(.el-table) { width: 100%; max-width: 100%; min-width: 0; }')
|
||||
expect(source).not.toContain('tenantId')
|
||||
expect(detailSource).toContain('listAllPlatformWarehouses()')
|
||||
expect(detailSource).toContain("warehouse.warehouseType === 'DOMESTIC'")
|
||||
expect(detailSource).toContain("warehouse.warehouseType === 'OVERSEAS'")
|
||||
expect(detailSource).toContain('起运仓映射')
|
||||
expect(detailSource).toContain('海外仓映射')
|
||||
expect(detailSource).toContain('originWarehouseCode')
|
||||
expect(detailSource).toContain('sourceDestinationName')
|
||||
expect(detailSource).toContain('autoSelectExactWarehouseMappings')
|
||||
expect(detailSource).toContain("'DUPLICATE_RATE'")
|
||||
expect(detailSource).toContain('.channel-tabs { width: 100%; min-width: 0;')
|
||||
expect(detailSource).toContain('.channel-preview :deep(.el-table) { width: 100%; max-width: 100%; min-width: 0; }')
|
||||
expect(detailSource).not.toContain('tenantId')
|
||||
})
|
||||
|
||||
it('supports public and customer-specific price-book scopes without exposing technical ids', () => {
|
||||
@@ -81,19 +88,19 @@ describe('CarrierRatesView price-book source contract', () => {
|
||||
expect(source).toContain('客户专属')
|
||||
expect(source).toContain('uploadPlatformPriceBook(file, uploadCustomerId.value)')
|
||||
expect(source).toContain('只替换同一报价范围')
|
||||
expect(source).not.toContain('{{ detail.version.customerId }}')
|
||||
expect(detailSource).not.toContain('{{ detail.version.customerId }}')
|
||||
})
|
||||
|
||||
it('shows parsing blockers and a channel-tabbed, read-only preview', () => {
|
||||
expect(source).toContain('nonMappingBlockingIssues')
|
||||
expect(source).toContain('解析与校验')
|
||||
expect(source).toContain('按渠道预览')
|
||||
expect(source).toContain('<el-tabs v-model="selectedChannelCode"')
|
||||
expect(source).toContain('sourceLocation')
|
||||
expect(source).toContain('pricingTaxModeLabel')
|
||||
expect(source).toContain('<el-table :data="selectedChannelRates" size="small" max-height="360" border stripe aria-label="渠道价格行预览">')
|
||||
expect(source).toContain('<el-table v-else :data="detail.issues" size="small" max-height="280" aria-label="价格表解析问题">')
|
||||
expect(source).not.toContain('detail.issues" size="small" max-height="280" border stripe')
|
||||
expect(detailSource).toContain('nonMappingBlockingIssues')
|
||||
expect(detailSource).toContain('解析与校验')
|
||||
expect(detailSource).toContain('按渠道预览')
|
||||
expect(detailSource).toContain('<el-tabs v-model="selectedChannelCode"')
|
||||
expect(detailSource).toContain('sourceLocation')
|
||||
expect(detailSource).toContain('pricingTaxModeLabel')
|
||||
expect(detailSource).toContain('<el-table :data="selectedChannelRates" size="small" max-height="440" border stripe aria-label="渠道价格行预览">')
|
||||
expect(detailSource).toContain('<el-table v-else :data="detail.issues" size="small" max-height="280" aria-label="价格表解析问题">')
|
||||
expect(detailSource).not.toContain('detail.issues" size="small" max-height="280" border stripe')
|
||||
})
|
||||
|
||||
it('accepts only xlsx uploads and retains original-file download', () => {
|
||||
@@ -111,20 +118,20 @@ describe('CarrierRatesView price-book source contract', () => {
|
||||
expect(queryToolbarSource).toContain('flex-wrap: wrap')
|
||||
expect(source).toContain('@media (max-width: 720px)')
|
||||
expect(source).toContain('.table-actions :deep(.el-button) { min-height: 40px; }')
|
||||
expect(source).toContain('@media (max-width: 420px)')
|
||||
expect(source).toContain('.detail-grid { grid-template-columns: 1fr; }')
|
||||
expect(detailSource).toContain('@media (max-width: 720px)')
|
||||
expect(detailSource).toContain('.detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }')
|
||||
})
|
||||
|
||||
it('uses bordered striped tables and explicit semantic business buttons', () => {
|
||||
expect(source).toContain('<DataTable')
|
||||
expect(source).toContain(':columns="columns"')
|
||||
expect(source).toContain('border stripe aria-label="渠道价格行预览"')
|
||||
expect(detailSource).toContain('border stripe aria-label="渠道价格行预览"')
|
||||
expect(source).toContain('<el-button size="small" plain type="primary" @click="openDetail')
|
||||
expect(source).toMatch(/size="small"\r?\n\s+plain\r?\n\s+:loading="downloadingIds\.has/)
|
||||
expect(source).toContain('<Eye :size="15" />{{ detailActionLabel')
|
||||
expect(source).toContain('<Download :size="15" />原文件')
|
||||
expect(source).toContain('<CircleCheck :size="16" />确认并立即生效')
|
||||
expect(source).toContain('.price-book-footer :deep(.el-button) { min-height: 44px; }')
|
||||
expect(detailSource).toContain('<CircleCheck :size="16" />确认并立即生效')
|
||||
expect(detailSource).toContain("import PageToolbar from '@/shared/components/PageToolbar.vue'")
|
||||
expect(source).not.toContain('<el-button link type="primary" @click="openDetail')
|
||||
})
|
||||
|
||||
@@ -143,9 +150,10 @@ describe('CarrierRatesView price-book source contract', () => {
|
||||
expect(source).not.toContain('<template #state>')
|
||||
})
|
||||
|
||||
it('keeps both row actions directly visible without a premature more menu', () => {
|
||||
it('keeps all row actions directly visible without a premature more menu', () => {
|
||||
expect(source).toContain('<Eye :size="15" />{{ detailActionLabel')
|
||||
expect(source).toContain('<Download :size="15" />原文件')
|
||||
expect(source).toContain('<CircleX :size="15" />作废')
|
||||
expect(source).not.toContain('MoreHorizontal')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user