|
|
@@ -20,20 +20,20 @@ describe('跨日期预约批量管理',()=>{
|
|
|
});
|
|
|
it('按姓名跨日期查询,全选所有匹配页,排除已取消和训练中课程,并可取消单项',async()=>{
|
|
|
const c=TestBed.createComponent(ScheduleBulkManagerComponent).componentInstance;c.searchInput='杨珍';await c.searchAppointments();
|
|
|
- expect(ops.list).toHaveBeenCalledWith('appointments',1,25,'杨珍',{dateFrom:'',dateTo:''});await c.selectAllMatching();expect(c.selected().size).toBe(199);expect(c.selected().has('a199')).toBeFalse();expect(c.selected().has('a200')).toBeFalse();
|
|
|
+ expect(ops.list).toHaveBeenCalledWith('appointments',1,25,'杨珍',{dateFrom:'',dateTo:'',excludeCancelled:true});await c.selectAllMatching();expect(c.selected().size).toBe(199);expect(c.selected().has('a199')).toBeFalse();expect(c.selected().has('a200')).toBeFalse();
|
|
|
c.toggleRow(rows[0] as any);expect(c.selected().size).toBe(198);
|
|
|
});
|
|
|
it('批量请求附带版本和未开始保护,部分失败保留待核对项',async()=>{
|
|
|
const c=TestBed.createComponent(ScheduleBulkManagerComponent).componentInstance;c.searchInput='杨珍';await c.searchAppointments();c.toggleRow(rows[0] as any);c.toggleRow(rows[1] as any);
|
|
|
- spyOn(window,'confirm').and.returnValue(true);ops.mutate.and.callFake(async(_op,id)=>{if(id==='a1')throw Error('预约已变更');return {} as any;});
|
|
|
+ spyOn(window,'confirm').and.returnValue(true);ops.mutate.and.callFake(async(_op,id)=>{if(id==='a1')throw Error('预约已变更');ops.list.and.resolveTo({items:rows.slice(1,26),total:199} as any);return {} as any;});
|
|
|
await c.cancelSelected();expect(ops.mutate.calls.count()).toBe(2);expect(ops.mutate.calls.allArgs()[0]).toEqual(['ops/appointments/cancel','a0','批量调整排课',{onlyUnstarted:true},rows[0].updatedAt]);
|
|
|
expect(c.selected().has('a0')).toBeFalse();expect(c.selected().has('a1')).toBeTrue();expect(c.message()).toContain('1');expect(c.error()).toContain('预约已变更');
|
|
|
- expect(c.rows()[0].cancelled).toBeTrue();expect(c.canSelect({...rows[0],statusUnverified:true} as any)).toBeFalse();
|
|
|
+ expect(c.rows().some(row=>row.targetId==='a0')).toBeFalse();expect(c.canSelect({...rows[0],statusUnverified:true} as any)).toBeFalse();
|
|
|
});
|
|
|
it('查询、翻页、每页条数与跨页全选使用已应用的预约日期范围',async()=>{
|
|
|
const c=TestBed.createComponent(ScheduleBulkManagerComponent).componentInstance as any;
|
|
|
c.searchInput='杨珍';c.dateFromInput='2026-11-01';c.dateToInput='2026-11-30';await c.searchAppointments();
|
|
|
- const filters={dateFrom:'2026-11-01',dateTo:'2026-11-30'};
|
|
|
+ const filters={dateFrom:'2026-11-01',dateTo:'2026-11-30',excludeCancelled:true};
|
|
|
expect(ops.list).toHaveBeenCalledWith('appointments',1,25,'杨珍',filters);
|
|
|
await c.changePage(2);expect(ops.list).toHaveBeenCalledWith('appointments',2,25,'杨珍',filters);
|
|
|
await c.changePageSize(50);expect(ops.list).toHaveBeenCalledWith('appointments',1,50,'杨珍',filters);
|
|
|
@@ -61,7 +61,7 @@ describe('跨日期预约批量管理',()=>{
|
|
|
c.searchInput='杨珍';c.dateFromInput='2026-11-01';c.dateToInput='2026-11-30';await c.searchAppointments();c.toggleRow(rows[0] as any);
|
|
|
await c.resetFilters();
|
|
|
expect(c.searchInput).toBe('');expect(c.dateFromInput).toBe('');expect(c.dateToInput).toBe('');expect(c.selected().size).toBe(0);
|
|
|
- expect(ops.list).toHaveBeenCalledWith('appointments',1,25,'',{dateFrom:'',dateTo:''});
|
|
|
+ expect(ops.list).toHaveBeenCalledWith('appointments',1,25,'',{dateFrom:'',dateTo:'',excludeCancelled:true});
|
|
|
});
|
|
|
it('新日期查询失败后不能勾选或取消旧列表中的预约',async()=>{
|
|
|
const c=TestBed.createComponent(ScheduleBulkManagerComponent).componentInstance;
|