refactor(shipping-notice): 统一料号字段,移除过时的 SKU 相关字段,更新相关逻辑以支持新字段命名

This commit is contained in:
hugo committed 2026-07-16 20:02:33 +08:00
1 parent dde25344ca
commit 46eb63f5bb
111 files changed
+3116 -1250

No files matched your search

@@ -20,6 +20,7 @@ const uploadChatFileMock = vi.mocked(uploadChatFile);
function createAttachments() {
return useChatAttachments({
deps: {
t: ((key: string, params?: Record<string, unknown>) => `${key}${params ? JSON.stringify(params) : ''}`),
msg: { warning: vi.fn() },
} as unknown as ChatDeps,
currentAgentId: computed(() => 7),
@@ -38,7 +39,7 @@ function createAttachments() {
function selectLocalFile(api: ReturnType<typeof createAttachments>, name = 'order.pdf') {
const file = new File(['content'], name, { type: 'application/pdf' });
api.handleLocalFilesSelected({ target: { files: [file], value: 'selected' } } as unknown as Event);
return api.attachments.value[0];
return api.attachments.value.at(-1);
}
describe('useChatAttachments upload states', () => {
@@ -86,6 +87,41 @@ describe('useChatAttachments upload states', () => {
expect(attachment && 'errorMessage' in attachment ? attachment.errorMessage : undefined).toBeUndefined();
});
it('explicitly retries only the selected failed attachment', async () => {
const api = createAttachments();
const first = selectLocalFile(api, 'first.pdf');
const second = selectLocalFile(api, 'second.pdf');
if (first?.kind === 'local') first.uploadStatus = 'failed';
if (second?.kind === 'local') {
second.uploadStatus = 'uploaded';
second.uploadFileId = 'upload-second';
}
uploadChatFileMock.mockResolvedValueOnce({ id: 'upload-first-retry' });
await expect(api.retryAttachment(first?.id || '')).resolves.toBe(true);
expect(uploadChatFileMock).toHaveBeenCalledOnce();
expect(uploadChatFileMock).toHaveBeenCalledWith(7, first && 'file' in first ? first.file : undefined);
expect(first).toMatchObject({ uploadStatus: 'uploaded', uploadFileId: 'upload-first-retry' });
expect(second).toMatchObject({ uploadStatus: 'uploaded', uploadFileId: 'upload-second' });
});
it('keeps explicit retry failures available for another retry', async () => {
const api = createAttachments();
const attachment = selectLocalFile(api);
if (attachment?.kind === 'local') attachment.uploadStatus = 'failed';
uploadChatFileMock.mockRejectedValueOnce(new Error('still unavailable'));
await expect(api.retryAttachment(attachment?.id || '')).resolves.toBe(false);
expect(attachment).toMatchObject({
uploadStatus: 'failed',
uploadProgress: 0,
errorMessage: 'still unavailable',
});
expect(api.attachments.value).toHaveLength(1);
});
it('reuses earlier successful files when a later file failed', async () => {
const api = createAttachments();
selectLocalFile(api, 'first.pdf');