test(库存): 真实删除批次回归用例
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const read = (rel: string) => readFileSync(new URL(`../${rel}`, import.meta.url), 'utf8');
|
||||
const svc = read('src/services/inventoryBatchHardDeleteService.ts');
|
||||
const route = read('src/modules/workflow/routes/inventoryRoutes.ts');
|
||||
const migration = read('../migrations/20261090_inventory_hard_delete.sql');
|
||||
const page = readFileSync(new URL('../../src/pages/inventory/InventoryManagement.tsx', import.meta.url), 'utf8');
|
||||
|
||||
describe('库存批次真实删除(方案 A)', () => {
|
||||
it('仅 available<=0 可删;有可用库存拒绝', () => {
|
||||
expect(svc).toContain('available > 1e-9');
|
||||
expect(svc).toContain('batch_has_available');
|
||||
expect(svc).toContain('DELETE FROM inventory');
|
||||
});
|
||||
|
||||
it('活动抵扣/未出库分拣引用拒绝', () => {
|
||||
expect(svc).toContain('cover_batches');
|
||||
expect(svc).toContain('batch_in_active_cover');
|
||||
expect(svc).toContain('outbound_batches');
|
||||
expect(svc).toContain('batch_in_active_picking');
|
||||
});
|
||||
|
||||
it('保留流水/报告,业务单据只置空 inventory_id', () => {
|
||||
expect(svc).toContain('inventory_batch_report_matches');
|
||||
expect(svc).toContain('self_purchase_stock_inbounds SET inventory_id = NULL');
|
||||
expect(svc).toContain('processing_task_outputs SET inventory_id = NULL');
|
||||
expect(svc).not.toContain('DELETE FROM inventory_logs');
|
||||
});
|
||||
|
||||
it('迁移触发器只阻止有可用库存的批次', () => {
|
||||
expect(migration).toContain('available_qty, 0) > 1e-9');
|
||||
expect(migration).toContain('trg_inventory_prevent_delete_when_occupied');
|
||||
});
|
||||
|
||||
it('路由权限 + 前端真实删除入口', () => {
|
||||
expect(route).toContain('/inventory/batches/:inventoryId/hard-delete');
|
||||
expect(route).toContain("['inventory_adjust']");
|
||||
expect(page).toContain('hardDeleteInventoryBatchApi');
|
||||
expect(page).toContain('inventory.action.hardDelete');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user