|
|
@@ -200,6 +200,52 @@ describe('排课数据加载提示', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+describe('排课明细与取消', () => {
|
|
|
+ it('实时旧系统排课可查看明细,但不能从新后台单边取消', async () => {
|
|
|
+ const mutate = jasmine.createSpy('mutate');
|
|
|
+ await TestBed.configureTestingModule({
|
|
|
+ imports: [OperationsScheduleComponent],
|
|
|
+ providers: [
|
|
|
+ { provide: OperationsService, useValue: { schedule: async () => ({ appointments: [], members: [], courses: [], coaches: [] }), mutate } },
|
|
|
+ { provide: ActivatedRoute, useValue: { snapshot: { queryParamMap: convertToParamMap({}) } } },
|
|
|
+ ],
|
|
|
+ }).compileComponents();
|
|
|
+ const fixture = TestBed.createComponent(OperationsScheduleComponent);
|
|
|
+ const page = fixture.componentInstance;
|
|
|
+ spyOn(page, 'load').and.resolveTo();
|
|
|
+ fixture.detectChanges();
|
|
|
+ page.openDetails({ generalId: 123, studentName: '学生甲', coachName: '老师乙', courseName: '单词课', readOnly: true, statusCode: 0, cancelled: false, sourceLabel: '旧系统实时数据' } as ScheduleAppointment);
|
|
|
+ fixture.detectChanges();
|
|
|
+ expect(fixture.nativeElement.querySelector('[data-testid="schedule-detail"]')?.textContent).toContain('学生甲');
|
|
|
+ expect(fixture.nativeElement.querySelector('[data-testid="schedule-detail"]')?.textContent).toContain('原业务端取消');
|
|
|
+ await page.cancelFromDetails();
|
|
|
+ expect(mutate).not.toHaveBeenCalled();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('对可写排课填写原因后调用取消接口并刷新', async () => {
|
|
|
+ const mutate = jasmine.createSpy('mutate').and.resolveTo({});
|
|
|
+ await TestBed.configureTestingModule({
|
|
|
+ imports: [OperationsScheduleComponent],
|
|
|
+ providers: [
|
|
|
+ { provide: OperationsService, useValue: { schedule: async () => ({ appointments: [], members: [], courses: [], coaches: [] }), mutate } },
|
|
|
+ { provide: ActivatedRoute, useValue: { snapshot: { queryParamMap: convertToParamMap({}) } } },
|
|
|
+ ],
|
|
|
+ }).compileComponents();
|
|
|
+ const page = TestBed.createComponent(OperationsScheduleComponent).componentInstance;
|
|
|
+ const load = spyOn(page, 'load').and.resolveTo();
|
|
|
+ const item = { targetId: 'appointment-1', updatedAt: '2026-10-04T10:00:00Z', readOnly: false, statusCode: 0, cancelled: false } as ScheduleAppointment;
|
|
|
+ page.openDetails(item);
|
|
|
+ await page.cancelFromDetails();
|
|
|
+ expect(mutate).not.toHaveBeenCalled();
|
|
|
+ expect(page.detailError()).toContain('取消原因');
|
|
|
+ page.cancelReason.set('学员请假');
|
|
|
+ await page.cancelFromDetails();
|
|
|
+ expect(mutate).toHaveBeenCalledOnceWith('ops/appointments/cancel', 'appointment-1', '学员请假', {}, item.updatedAt);
|
|
|
+ expect(page.detail()).toBeNull();
|
|
|
+ expect(load).toHaveBeenCalled();
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
describe('排课表单预检', () => {
|
|
|
async function form(request: () => Promise<Record<string, unknown>>) {
|
|
|
await TestBed.configureTestingModule({
|