feat(round-10): 新增出海潜客多时区最佳联系窗口算法与Stripe回调幂等性防重处理 (79套件957测试全绿)
这个提交包含在:
@@ -0,0 +1,45 @@
|
||||
import {
|
||||
resolveBestContactWindow,
|
||||
ContactWindowInfo,
|
||||
} from '../../src/comm/i18n/geo';
|
||||
|
||||
describe('Point 39: 出海潜客多时区识别与最佳联系时间窗口推荐 (Best Contact Time Window)', () => {
|
||||
describe('1. 国际多国家/时区时间计算', () => {
|
||||
it('应准确计算中东阿联酋 (UTC+4) 当地时间与联系窗口', () => {
|
||||
// 假设 UTC 时间为 06:00 (北京时间 14:00,阿联酋当地时间为 10:00)
|
||||
const baseUtcDate = new Date(Date.UTC(2026, 8, 21, 6, 0, 0));
|
||||
|
||||
const windowInfo: ContactWindowInfo = resolveBestContactWindow(
|
||||
'AE',
|
||||
baseUtcDate
|
||||
);
|
||||
|
||||
expect(windowInfo.localHour).toBe(10);
|
||||
expect(windowInfo.isWorkHour).toBe(true);
|
||||
expect(windowInfo.status).toBe('recommended');
|
||||
expect(windowInfo.suggestionText).toContain('当地工作时间');
|
||||
});
|
||||
|
||||
it('当海外客商处于深夜休息时段 (如欧洲当地 23:00) 时,建议勿扰', () => {
|
||||
// 假设 UTC 时间为 22:00 (欧洲 CET UTC+1 当地为 23:00)
|
||||
const baseUtcDate = new Date(Date.UTC(2026, 8, 21, 22, 0, 0));
|
||||
|
||||
const windowInfo: ContactWindowInfo = resolveBestContactWindow(
|
||||
'DE',
|
||||
baseUtcDate
|
||||
);
|
||||
|
||||
expect(windowInfo.localHour).toBe(23);
|
||||
expect(windowInfo.isWorkHour).toBe(false);
|
||||
expect(windowInfo.status).toBe('do_not_disturb');
|
||||
expect(windowInfo.suggestionText).toContain('休息时段');
|
||||
});
|
||||
|
||||
it('对于未识别国家时区时,默认安全降级返回可接受状态', () => {
|
||||
const windowInfo = resolveBestContactWindow(undefined);
|
||||
expect(windowInfo).toBeDefined();
|
||||
expect(typeof windowInfo.localHour).toBe('number');
|
||||
expect(typeof windowInfo.suggestionText).toBe('string');
|
||||
});
|
||||
});
|
||||
});
|
||||
在新工单中引用
屏蔽一个用户