|
|
@@ -846,6 +846,62 @@ describe('home learning modules', () => {
|
|
|
expect(harness.routeNativeElement?.querySelector('.record-list')).toBeNull();
|
|
|
});
|
|
|
|
|
|
+ it('syncs a missing learning record and reopens its review words', async () => {
|
|
|
+ const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
+ const post = api.post.bind(api);
|
|
|
+ let detailReads = 0;
|
|
|
+ spyOn(api, 'post').and.callFake((action, params) => {
|
|
|
+ if (action === 'e_record_detail') {
|
|
|
+ detailReads += 1;
|
|
|
+ return of({ retcode: 1, result: detailReads === 1 ? [] : [{ GeneralID: 701, Title: 'apple', sy: '苹果' }], addon: [] } as ApiEnvelope<any>);
|
|
|
+ }
|
|
|
+ if (action === 'app_learning_overview') return of({ retcode: 1, result: {} } as ApiEnvelope<any>);
|
|
|
+ return post(action, params);
|
|
|
+ });
|
|
|
+ const harness = await RouterTestingHarness.create();
|
|
|
+ await harness.navigateByUrl('/pages/stu/record?id=864038&gid=864047&kcid=398');
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ expect(detailReads).toBe(2);
|
|
|
+ expect(harness.routeNativeElement?.querySelector('.record-word')?.textContent).toContain('apple');
|
|
|
+ expect(harness.routeNativeElement?.querySelector('.empty-state.error')).toBeNull();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('reads the original word list when the detail stays empty after syncing', async () => {
|
|
|
+ const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
+ const post = api.post.bind(api);
|
|
|
+ const get = api.get.bind(api);
|
|
|
+ spyOn(api, 'post').and.callFake((action, params) => action === 'e_record_detail'
|
|
|
+ ? of({ retcode: 1, result: [], addon: [] } as ApiEnvelope<any>) : action === 'app_learning_overview'
|
|
|
+ ? of({ retcode: 1, result: {} } as ApiEnvelope<any>) : post(action, params));
|
|
|
+ spyOn(api, 'get').and.callFake((action, params) => action === 'content_get'
|
|
|
+ ? of({ retcode: 1, result: [{ GeneralID: 864038, xxqs: JSON.stringify([{ GeneralID: 701, Title: 'apple' }]) }] } as ApiEnvelope<any>)
|
|
|
+ : get(action, params));
|
|
|
+ const harness = await RouterTestingHarness.create();
|
|
|
+ await harness.navigateByUrl('/pages/stu/record?id=864038&gid=864047&kcid=398');
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ expect(harness.routeNativeElement?.querySelector('.record-word')?.textContent).toContain('apple');
|
|
|
+ expect(harness.routeNativeElement?.querySelector('.empty-state.error')).toBeNull();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('identifies a legacy writing review with no original words and keeps it incomplete', async () => {
|
|
|
+ const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
+ const post = api.post.bind(api);
|
|
|
+ const get = api.get.bind(api);
|
|
|
+ spyOn(api, 'post').and.callFake((action, params) => action === 'e_record_detail'
|
|
|
+ ? of({ retcode: 1, result: [], addon: [] } as ApiEnvelope<any>) : action === 'app_learning_overview'
|
|
|
+ ? of({ retcode: 1, result: {} } as ApiEnvelope<any>) : post(action, params));
|
|
|
+ spyOn(api, 'get').and.callFake((action, params) => action === 'content_get'
|
|
|
+ ? of({ retcode: 1, result: [{ GeneralID: 864038, xxqs: '', learned: 0, con: '完成了写作学习' }] } as ApiEnvelope<any>)
|
|
|
+ : get(action, params));
|
|
|
+ const harness = await RouterTestingHarness.create();
|
|
|
+ await harness.navigateByUrl('/pages/stu/record?id=864038&gid=864047&kcid=398');
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ expect(harness.routeNativeElement?.textContent).toContain('写作学习记录,原本没有单词');
|
|
|
+ expect(harness.routeNativeElement?.querySelector('.record-list')).toBeNull();
|
|
|
+ expect(harness.routeNativeElement?.querySelector('a[href="/pages/stu/stu_calendar"]')).not.toBeNull();
|
|
|
+ expect(harness.routeNativeElement?.textContent).not.toContain('结束本次复习');
|
|
|
+ });
|
|
|
+
|
|
|
it('renders source-shaped data for all four home entries', async () => {
|
|
|
const harness = await RouterTestingHarness.create();
|
|
|
|
|
|
@@ -1701,61 +1757,4 @@ describe('home learning modules', () => {
|
|
|
expect(harness.routeNativeElement?.querySelectorAll('.learning-record-card .learning-item').length).toBe(5);
|
|
|
expect((harness.routeNativeElement?.querySelectorAll('.record-pagination button')[1] as HTMLButtonElement).disabled).toBeTrue();
|
|
|
});
|
|
|
- it('syncs a missing learning record and reopens its review words', async () => {
|
|
|
- const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
- const post = api.post.bind(api);
|
|
|
- let detailReads = 0;
|
|
|
- spyOn(api, 'post').and.callFake((action, params) => {
|
|
|
- if (action === 'e_record_detail') {
|
|
|
- detailReads += 1;
|
|
|
- return of({ retcode: 1, result: detailReads === 1 ? [] : [{ GeneralID: 701, Title: 'apple', sy: '苹果' }], addon: [] } as ApiEnvelope<any>);
|
|
|
- }
|
|
|
- if (action === 'app_learning_overview') return of({ retcode: 1, result: {} } as ApiEnvelope<any>);
|
|
|
- return post(action, params);
|
|
|
- });
|
|
|
- const harness = await RouterTestingHarness.create();
|
|
|
- await harness.navigateByUrl('/pages/stu/record?id=864038&gid=864047&kcid=398');
|
|
|
- harness.fixture.detectChanges();
|
|
|
- expect(detailReads).toBe(2);
|
|
|
- expect(harness.routeNativeElement?.querySelector('.record-word')?.textContent).toContain('apple');
|
|
|
- expect(harness.routeNativeElement?.querySelector('.empty-state.error')).toBeNull();
|
|
|
- });
|
|
|
-
|
|
|
- it('reads the original word list when the detail stays empty after syncing', async () => {
|
|
|
- const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
- const post = api.post.bind(api);
|
|
|
- const get = api.get.bind(api);
|
|
|
- spyOn(api, 'post').and.callFake((action, params) => action === 'e_record_detail'
|
|
|
- ? of({ retcode: 1, result: [], addon: [] } as ApiEnvelope<any>) : action === 'app_learning_overview'
|
|
|
- ? of({ retcode: 1, result: {} } as ApiEnvelope<any>) : post(action, params));
|
|
|
- spyOn(api, 'get').and.callFake((action, params) => action === 'content_get'
|
|
|
- ? of({ retcode: 1, result: [{ GeneralID: 864038, xxqs: JSON.stringify([{ GeneralID: 701, Title: 'apple' }]) }] } as ApiEnvelope<any>)
|
|
|
- : get(action, params));
|
|
|
- const harness = await RouterTestingHarness.create();
|
|
|
- await harness.navigateByUrl('/pages/stu/record?id=864038&gid=864047&kcid=398');
|
|
|
- harness.fixture.detectChanges();
|
|
|
- expect(harness.routeNativeElement?.querySelector('.record-word')?.textContent).toContain('apple');
|
|
|
- expect(harness.routeNativeElement?.querySelector('.empty-state.error')).toBeNull();
|
|
|
- });
|
|
|
-
|
|
|
- it('identifies a legacy writing review with no original words and keeps it incomplete', async () => {
|
|
|
- const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
- const post = api.post.bind(api);
|
|
|
- const get = api.get.bind(api);
|
|
|
- spyOn(api, 'post').and.callFake((action, params) => action === 'e_record_detail'
|
|
|
- ? of({ retcode: 1, result: [], addon: [] } as ApiEnvelope<any>) : action === 'app_learning_overview'
|
|
|
- ? of({ retcode: 1, result: {} } as ApiEnvelope<any>) : post(action, params));
|
|
|
- spyOn(api, 'get').and.callFake((action, params) => action === 'content_get'
|
|
|
- ? of({ retcode: 1, result: [{ GeneralID: 864038, xxqs: '', learned: 0, con: '完成了写作学习' }] } as ApiEnvelope<any>)
|
|
|
- : get(action, params));
|
|
|
- const harness = await RouterTestingHarness.create();
|
|
|
- await harness.navigateByUrl('/pages/stu/record?id=864038&gid=864047&kcid=398');
|
|
|
- harness.fixture.detectChanges();
|
|
|
- expect(harness.routeNativeElement?.textContent).toContain('写作学习记录,原本没有单词');
|
|
|
- expect(harness.routeNativeElement?.querySelector('.record-list')).toBeNull();
|
|
|
- expect(harness.routeNativeElement?.querySelector('a[href="/pages/stu/stu_calendar"]')).not.toBeNull();
|
|
|
- expect(harness.routeNativeElement?.textContent).not.toContain('结束本次复习');
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
});
|