|
|
@@ -248,7 +248,7 @@ class LearningModulesApiService {
|
|
|
if (action === 'app_review_page') {
|
|
|
this.lastMemoryParams=params;
|
|
|
if (this.reviewPageResponse) return this.reviewPageResponse as Observable<ApiEnvelope<T>>;
|
|
|
- const items=[
|
|
|
+ const items=params['scope']==='today' ? [{ GeneralID: 102, Title: '张雅茜@任务', kc_title: '高中英语复习', kywsj: String(params['date'])+' 09:00', fxzt: 0, yhid: 100, xxjlid: 900 }] : [
|
|
|
{ GeneralID: 100, Title: '张雅茜@历史任务', kc_title: '历史复习', kywsj: '2026-05-15 09:00', learned_at: '2026-05-01T01:15:00.000Z', fxzt: 1, yhid: 100, xxjlid: 900 },
|
|
|
{ GeneralID: 101, Title: '张雅茜@任务', kc_title: '初中英语复习', kywsj: '2026-08-01 09:00', learned_at: '2026-07-20T02:20:00.000Z', fxzt: 1, yhid: 100, xxjlid: 900 },
|
|
|
{ GeneralID: 102, Title: '张雅茜@任务', kc_title: '高中英语复习', kywsj: '2026-08-02 09:00', learned_at: '2026-07-20T02:20:00.000Z', fxzt: 0, yhid: 100, xxjlid: 900 },
|
|
|
@@ -300,6 +300,7 @@ describe('home learning modules', () => {
|
|
|
};
|
|
|
|
|
|
beforeEach(() => {
|
|
|
+ sessionStorage.removeItem('xiaoshu.learning.teacherTodayReview');
|
|
|
spyOn(window, 'confirm').and.returnValue(true);
|
|
|
// Route tests do not depend on remote audio availability or its error-toast timer.
|
|
|
spyOn(HTMLMediaElement.prototype, 'play').and.returnValue(Promise.resolve());
|
|
|
@@ -317,6 +318,36 @@ describe('home learning modules', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ it('keeps all today tasks cached across navigation and visibility', async () => {
|
|
|
+ user.set({ userId: 300, userName: 'coach', honeyName: '张老师', groupId: 3 });
|
|
|
+ session.groupId.set(3);
|
|
|
+ const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
+ const originalPost = api.post.bind(api);
|
|
|
+ const post = spyOn(api, 'post').and.callFake((action, params) => {
|
|
|
+ if (action !== 'app_review_page') return originalPost(action, params);
|
|
|
+ return of({ retcode: 1, result: {
|
|
|
+ items: Array.from({length: 7}, (_, i) => ({ GeneralID: 100+i, yhid: 100, Title: '今日学员', kywsj: params?.['date'], fxzt: i === 6 ? 1 : 0 })),
|
|
|
+ page: { itemCount: 7, pageCount: 1 }, summary: { total: 7, completed: 1, due: 6, today: 7, income: 0 }, dates: [],
|
|
|
+ } }) as never;
|
|
|
+ });
|
|
|
+ const count = () => post.calls.allArgs().filter(([name]) => name === 'app_review_page').length;
|
|
|
+ const harness = await RouterTestingHarness.create();
|
|
|
+ await harness.navigateByUrl('/pages/home/index');
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ expect(harness.routeNativeElement?.querySelectorAll('.coach-memory-list article').length).toBe(7);
|
|
|
+ expect(harness.routeNativeElement?.querySelectorAll('.coach-memory-footer').length).toBe(1);
|
|
|
+ expect(harness.routeNativeElement?.textContent).not.toContain('查看今日全部任务');
|
|
|
+ document.dispatchEvent(new Event('visibilitychange'));
|
|
|
+ await harness.navigateByUrl('/pages/member/starshop');
|
|
|
+ await harness.navigateByUrl('/pages/home/index');
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ expect(count()).toBe(1);
|
|
|
+ expect(harness.routeNativeElement?.querySelector('.coach-memory-state')).toBeNull();
|
|
|
+ (harness.routeNativeElement?.querySelector('.coach-memory-refresh') as HTMLButtonElement).click();
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ expect(count()).toBe(2);
|
|
|
+ });
|
|
|
+
|
|
|
it('loads the review calendar once per login and refreshes only on an explicit request', async () => {
|
|
|
const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
const originalPost = api.post.bind(api);
|
|
|
@@ -1205,8 +1236,8 @@ describe('home learning modules', () => {
|
|
|
await harness.navigateByUrl('/pages/home/index');
|
|
|
response.next({ retcode: 1, result: {
|
|
|
items: [
|
|
|
- { GeneralID: 102, yhid: 100, honeyName: '', Title: '旧姓名@复习', kywsj: '2025-07-19', fxzt: 0, xxjlid: 900 },
|
|
|
- { GeneralID: 103, yhid: '101', honeyName: ' ', HoneyName: '', kywsj: '2025-07-15', fxzt: 0, xxjlid: 901 },
|
|
|
+ { GeneralID: 102, yhid: 100, honeyName: '', Title: '旧姓名@复习', kywsj: String(api.lastMemoryParams['date']), fxzt: 0, xxjlid: 900 },
|
|
|
+ { GeneralID: 103, yhid: '101', honeyName: ' ', HoneyName: '', kywsj: String(api.lastMemoryParams['date']), fxzt: 0, xxjlid: 901 },
|
|
|
],
|
|
|
students: [{ id: '101', name: '李同学', taskCount: 1 }, { id: '100', name: '张雅茜', taskCount: 1 }],
|
|
|
page: { itemCount: 2, pageCount: 1 },
|
|
|
@@ -1243,11 +1274,11 @@ describe('home learning modules', () => {
|
|
|
expect(coachAccountTab?.textContent).toContain('我的');
|
|
|
expect(harness.routeNativeElement?.querySelector('.content-section')).toBeNull();
|
|
|
const memoryApi = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
- expect(memoryApi.lastMemoryParams).toEqual(jasmine.objectContaining({ uid: 300, pageSize:4, scope:'today', includeMetadata:false, includeIncome:false }));
|
|
|
+ expect(memoryApi.lastMemoryParams).toEqual(jasmine.objectContaining({ uid: 300, pageSize:100, scope:'today', includeMetadata:false, includeIncome:false }));
|
|
|
expect(harness.routeNativeElement?.querySelector('.coach-memory-board')?.textContent).toContain('抗遗忘带练');
|
|
|
expect(harness.routeNativeElement?.querySelector('.coach-memory-board')?.textContent).toContain('张雅茜');
|
|
|
- expect(harness.routeNativeElement?.querySelector('.coach-memory-list article.ready > button')?.textContent).toContain('带学生复习');
|
|
|
- expect(harness.routeNativeElement?.querySelector('.coach-memory-footer')?.getAttribute('href')).toContain('/pages/stu/stu_calendar?date=');
|
|
|
+ expect(harness.routeNativeElement?.querySelector('.coach-memory-list article.ready > button')?.textContent).toContain('查看计划');
|
|
|
+ expect(harness.routeNativeElement?.querySelector('.coach-memory-footer')?.getAttribute('href')).toBe('/pages/stu/stu_calendar');
|
|
|
(harness.routeNativeElement?.querySelector('.coach-memory-list article.ready > button') as HTMLButtonElement).click();
|
|
|
await harness.fixture.whenStable();
|
|
|
expect(TestBed.inject(Router).url).toContain('/pages/stu/record?id=900&gid=102');
|