|
|
@@ -8,6 +8,34 @@ const source = gatewaySource.match(/const LEGACY_APPOINTMENT_PULLS=new Map\(\),L
|
|
|
.replace(/\nconst APP_LIVE_SCOPES=[\s\S]*$/, '');
|
|
|
assert.ok(source, '未找到旧系统预约拉取实现');
|
|
|
|
|
|
+test('老师排课和运营排课投影保留交付方式,并识别历史线下标签', () => {
|
|
|
+ const pick = name => gatewaySource.match(new RegExp('function '+name+'\\(.*?\\) \\{[\\s\\S]*?\\n\\}'))?.[0];
|
|
|
+ const mobile = vm.createContext({ number: Number, firstValue: (...values) => values.find(value => value != null && value !== '') });
|
|
|
+ vm.runInContext(pick('appOverviewScheduleRow'), mobile);
|
|
|
+ const booking = { generalId: 12, deliveryMode: 'offline', jffs: '线下' };
|
|
|
+ assert.equal(mobile.appOverviewScheduleRow(booking).deliveryMode, 'offline');
|
|
|
+ assert.equal(mobile.appOverviewScheduleRow({ ...booking, deliveryMode: undefined, jffs: '上门' }).jffs, '上门');
|
|
|
+
|
|
|
+ const admin = vm.createContext({
|
|
|
+ number: (value, fallback = 0) => Number(value ?? fallback),
|
|
|
+ text: value => String(value ?? '').trim(),
|
|
|
+ appointmentDate: () => new Date('2026-12-02T00:00:00Z'),
|
|
|
+ durationMinutes: () => 60,
|
|
|
+ legacyOf: () => ({}),
|
|
|
+ classType: () => '60 分钟',
|
|
|
+ statusLabel: () => '待开始',
|
|
|
+ dateIso: () => '',
|
|
|
+ });
|
|
|
+ const deliveryFunctions = gatewaySource.match(/function deliveryMode\([^\n]+\nfunction deliveryLabel\([^\n]+/)?.[0];
|
|
|
+ vm.runInContext(deliveryFunctions+'\n'+pick('appointmentProjection'), admin);
|
|
|
+ assert.equal(admin.appointmentProjection({ ...booking, deliveryMode: 'online' }).deliveryMode, 'online');
|
|
|
+ assert.equal(admin.appointmentProjection({ jffs: '线上' }).deliveryMode, 'online');
|
|
|
+ for (const jffs of ['线下', '上门', '机构']) {
|
|
|
+ assert.equal(admin.appointmentProjection({ jffs }).deliveryMode, 'offline');
|
|
|
+ }
|
|
|
+ assert.equal(admin.appointmentProjection({}).deliveryMode, undefined);
|
|
|
+});
|
|
|
+
|
|
|
function contextFor(rows) {
|
|
|
const context = {
|
|
|
console,
|