- loaded_qty 仍可改且保留审计 - picked_qty/weight 变更写 picking_qty_edit 审计 - 核货补录不覆盖已有分拣/核货/照片证据 - loading_photos 追加去重,不再覆盖旧照片
89 lines
4.5 KiB
TypeScript
89 lines
4.5 KiB
TypeScript
import { readFileSync } from 'fs';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { inboundInspectionPhotoExistsSql } from '../src/services/deliveryLoadingService';
|
|
|
|
const src = readFileSync(new URL('../src/services/deliveryLoadingService.ts', import.meta.url), 'utf8');
|
|
const photoSrc = readFileSync(new URL('../src/services/deliveryPhotoService.ts', import.meta.url), 'utf8');
|
|
const reviewSrc = readFileSync(new URL('../src/services/inspectionReviewService.ts', import.meta.url), 'utf8');
|
|
const reviewRoute = readFileSync(
|
|
new URL('../src/modules/workflow/routes/inspectionRoutes.ts', import.meta.url),
|
|
'utf8'
|
|
);
|
|
const mobileRoute = readFileSync(
|
|
new URL('../src/routes/mobile/mobileDeliveryRoutes.ts', import.meta.url),
|
|
'utf8'
|
|
);
|
|
|
|
describe('配送核货补拍不混入库照', () => {
|
|
it('入库有照判定走 inspections.inspection_photos,不写验收表', () => {
|
|
const sql = inboundInspectionPhotoExistsSql({
|
|
orderCode: 'pi.order_code',
|
|
orderItemId: 'pi.order_item_id',
|
|
sku: 'pi.sku_code',
|
|
itemName: 'pi.item_name',
|
|
});
|
|
expect(sql).toContain('inspections i');
|
|
expect(sql).toContain('inspection_photos');
|
|
expect(sql).toContain('pi.order_item_id');
|
|
expect(src).toContain('needs_loading_photo');
|
|
expect(src).toContain('attachCategoryPhotoInspectionRequirements');
|
|
expect(src).toContain('array_append(COALESCE(loading_photos, \'{}\'::text[])');
|
|
expect(src).toContain('MAX_LOADING_PHOTOS = 2');
|
|
expect(src).not.toMatch(/UPDATE inspections[\s\S]*inspection_photos/);
|
|
});
|
|
|
|
it('核货列表带补拍标记;上传走独立接口与 delivery-loading 前缀', () => {
|
|
expect(src).toContain('has_inbound_photo');
|
|
expect(src).toContain('loading_photo_count');
|
|
expect(src).toContain("objectPrefix: 'delivery-loading'");
|
|
expect(mobileRoute).toContain('/delivery/loading/photo');
|
|
expect(mobileRoute).toContain('uploadDeliveryLoadingPhoto');
|
|
});
|
|
|
|
it('复核 Tab 用 source=loading_photos 读 picking_items.loading_photos', () => {
|
|
expect(reviewSrc).toContain('export async function listLoadingPhotoReviews');
|
|
expect(reviewSrc).toContain('pi.loading_photos');
|
|
expect(reviewSrc).toContain("'loading_photos'::text AS source_type");
|
|
expect(reviewRoute).toContain("source === 'loading_photos'");
|
|
expect(reviewRoute).toContain('listLoadingPhotoReviews');
|
|
});
|
|
|
|
it('强制补拍:供应商不入仓行不依赖角色权限;分类补拍仍看权限', () => {
|
|
expect(photoSrc).toContain("permission_code = 'delivery_loading_photo'");
|
|
expect(src).toContain('export async function assertDeliveryLoadingPhotosIfRequired');
|
|
expect(src).toContain('item.skip_inbound || item.is_extra_dish || rolePhotoRequired');
|
|
expect(src).toContain('skipInbound || qtyEditEnabled');
|
|
const completeIdx = src.indexOf('export async function assertDeliveryLoadingComplete');
|
|
const photoIdx = src.indexOf('export async function assertDeliveryLoadingPhotosIfRequired');
|
|
expect(completeIdx).toBeGreaterThan(-1);
|
|
expect(photoIdx).toBeGreaterThan(completeIdx);
|
|
const completeFn = src.slice(completeIdx, photoIdx);
|
|
expect(completeFn).not.toContain('loading_photo_required');
|
|
expect(completeFn).not.toContain('assertDeliveryLoadingPhotosIfRequired');
|
|
});
|
|
|
|
it('发车与未发车定位调用补拍断言;已发车定位不拦', () => {
|
|
expect(mobileRoute).toContain('assertDeliveryLoadingPhotosIfRequired');
|
|
expect(mobileRoute).toContain('delivery_loading_photo_required');
|
|
expect(mobileRoute).toMatch(/await assertDeliveryLoadingComplete\(taskCode, personCode\);\s*await assertDeliveryLoadingPhotosIfRequired\(taskCode, personCode\);/);
|
|
expect(mobileRoute).toContain('if (taskStatus < 20)');
|
|
expect(mobileRoute).toContain('await assertDeliveryLoadingPhotosIfRequired(taskCode, personCode)');
|
|
expect(mobileRoute).toContain('assertExtraDishLoadingPhotos');
|
|
});
|
|
|
|
it('开关关闭时小程序不隐藏完成、不展示须拍照', () => {
|
|
const wxml = readFileSync(
|
|
new URL('../../miniprogram/components/delivery-panel/index.wxml', import.meta.url),
|
|
'utf8'
|
|
);
|
|
expect(wxml).toContain(
|
|
'(deliveryLoadingPhotoRequired || row.skip_inbound || row.is_extra_dish) && row.needs_loading_photo'
|
|
);
|
|
expect(wxml).not.toContain('wx:elif="{{!row.needs_loading_photo && loadingMode === \'manual\'');
|
|
expect(wxml).toContain(
|
|
"wx:elif=\"{{loadingMode === 'manual' && (task.task_status != 20 || row.is_extra_dish)}}\""
|
|
);
|
|
expect(wxml).toContain('all_loaded && loadingSummary.loading_photo_required');
|
|
});
|
|
});
|