28 lines
1.6 KiB
TypeScript
28 lines
1.6 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
const source = (relativePath: string) => readFileSync(path.resolve(process.cwd(), relativePath), 'utf8')
|
|
const palletsApi = source('src/modules/overseas-warehouse/api/pallets.ts')
|
|
const palletsPage = source('src/modules/overseas-warehouse/pages/PalletsView.vue')
|
|
const iamApi = source('src/modules/iam/api/platformIam.ts')
|
|
|
|
describe('Admin pallet warehouse routing contract', () => {
|
|
it('loads ACTIVE OVERSEAS receiving warehouse candidates from domestic Warehouse only', () => {
|
|
expect(palletsApi).toContain("import { listSharedReceivingOverseasWarehouseOptions } from '@/modules/iam'")
|
|
expect(palletsApi).toContain('await listSharedReceivingOverseasWarehouseOptions()')
|
|
expect(palletsPage).toContain('listReceivingOverseasWarehouses()')
|
|
expect(iamApi).toContain("'/platform/v1/warehouse-admin'")
|
|
for (const filter of ["tenantId: '0'", "capabilityCode: 'RECEIVING'", "warehouseType: 'OVERSEAS'", "status: 'ACTIVE'"]) {
|
|
expect(iamApi).toContain(filter)
|
|
}
|
|
})
|
|
|
|
it('never calls the nonexistent overseas warehouse-admin root and always scopes pallet calls by warehouseId', () => {
|
|
expect(palletsApi).not.toMatch(/http\.get[^\n]*\(\s*['"]\/platform\/v1\/warehouse-admin['"]/)
|
|
expect(palletsApi).not.toContain('listCustomerWarehouses')
|
|
expect(palletsApi).toContain('`/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets`')
|
|
expect(palletsApi).toContain('`/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`')
|
|
})
|
|
})
|