Files
syops/frontend/src/features/chat/components/shipping-review/ReviewUnsavedSwitchDialog.spec.ts
T
hugoandCursor 84a881b554 feat(shipping-notice): 落地 XFA 统一视觉拆分确认门禁与处理投影收敛
闭合拆分预览令牌单次消费、样本 checksum 绑定与确认审计;正式提取改为 bindings-only。
同步统一标注工作台交互,并补齐进度投影/任务中心与迁移文档。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 10:21:25 +08:00

49 lines
1.6 KiB
TypeScript

/**
* features/chat/components/shipping-review/ReviewUnsavedSwitchDialog.spec.ts
* 用途:验收切换 OT 未保存硬拦截三按钮。
*/
import { describe, expect, it } from 'vitest';
import { mount } from '@vue/test-utils';
import { createI18n } from 'vue-i18n';
import ReviewUnsavedSwitchDialog from './ReviewUnsavedSwitchDialog.vue';
const i18n = createI18n({
legacy: false,
locale: 'zh-CN',
messages: {
'zh-CN': {
chat: {
shippingOrderReview: {
unsavedSwitch: {
title: '有未保存的修改',
message: '当前订单有 {count} 项修改尚未保存。',
cancel: '取消',
discard: '放弃修改',
saveAndSwitch: '保存后切换',
},
},
},
},
},
});
describe('ReviewUnsavedSwitchDialog', () => {
it('emits cancel / discard / save-and-switch', async () => {
const wrapper = mount(ReviewUnsavedSwitchDialog, {
props: { open: true, unsavedCount: 2 },
global: {
plugins: [i18n],
stubs: { Teleport: { template: '<div><slot /></div>' } },
},
});
expect(wrapper.find('[data-testid="review-unsaved-switch-dialog"]').exists()).toBe(true);
await wrapper.get('[data-testid="review-unsaved-cancel"]').trigger('click');
expect(wrapper.emitted('cancel')).toBeTruthy();
await wrapper.get('[data-testid="review-unsaved-discard"]').trigger('click');
expect(wrapper.emitted('discard')).toBeTruthy();
await wrapper.get('[data-testid="review-unsaved-save-switch"]').trigger('click');
expect(wrapper.emitted('save-and-switch')).toBeTruthy();
});
});