|
|
@@ -294,6 +294,55 @@ describe('home learning modules', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ it('silently reveals pending and completed words opened from student learning content', async () => {
|
|
|
+ const play = spyOn(TestBed.inject(PlatformService), 'play');
|
|
|
+ const harness = await RouterTestingHarness.create();
|
|
|
+ await harness.navigateByUrl('/pages/his/his');
|
|
|
+ (harness.routeNativeElement?.querySelector('.current-learning-list button') as HTMLButtonElement).click();
|
|
|
+ await harness.fixture.whenStable();
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ (harness.routeNativeElement?.querySelector('.node-list button') as HTMLButtonElement).click();
|
|
|
+ await harness.fixture.whenStable();
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+
|
|
|
+ expect(TestBed.inject(Router).url).toContain('readonly=1');
|
|
|
+ const learning = harness.fixture.debugElement.query(By.directive(LearningPageComponent)).componentInstance as LearningPageComponent;
|
|
|
+ for (const [index, meaning] of ['n. 香蕉', 'n. 苹果'].entries()) {
|
|
|
+ (harness.routeNativeElement?.querySelectorAll('.word-selection-tabs button')[index] as HTMLButtonElement).click();
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ expect(harness.routeNativeElement?.querySelector('.audio')).toBeNull();
|
|
|
+ expect(harness.routeNativeElement?.textContent).not.toContain('读音');
|
|
|
+ const word = harness.routeNativeElement?.querySelector('.word-reveal') as HTMLButtonElement;
|
|
|
+ word.click();
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ expect(word.textContent).toContain(meaning);
|
|
|
+ expect(word.getAttribute('aria-expanded')).toBe('true');
|
|
|
+ word.click();
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ expect(word.getAttribute('aria-expanded')).toBe('false');
|
|
|
+ }
|
|
|
+ learning.words().forEach((word) => learning.play(word));
|
|
|
+ expect(play).not.toHaveBeenCalled();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('still pronounces pending and completed words when a coach reveals them', async () => {
|
|
|
+ user.set({ userId: 300, userName: 'coach', honeyName: '张老师', groupId: 3 });
|
|
|
+ session.groupId.set(3);
|
|
|
+ session.student.set({ userId: 100, userName: 'student', groupId: 1 });
|
|
|
+ const play = spyOn(TestBed.inject(PlatformService), 'play');
|
|
|
+ const harness = await RouterTestingHarness.create();
|
|
|
+ await harness.navigateByUrl('/pages/stu/stu_abc?nids=811,812&pnid=801');
|
|
|
+ for (const index of [0, 1]) {
|
|
|
+ (harness.routeNativeElement?.querySelectorAll('.word-selection-tabs button')[index] as HTMLButtonElement).click();
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ expect(harness.routeNativeElement?.querySelector('.audio')).not.toBeNull();
|
|
|
+ (harness.routeNativeElement?.querySelector('.word-reveal') as HTMLButtonElement).click();
|
|
|
+ }
|
|
|
+ expect(play).toHaveBeenCalledTimes(2);
|
|
|
+ expect(play.calls.argsFor(0)[0]).toContain('banana.mp3');
|
|
|
+ expect(play.calls.argsFor(1)[0]).toContain('apple.mp3');
|
|
|
+ });
|
|
|
+
|
|
|
it('shows named schedule students below the trigger and closes after selection or Escape', async () => {
|
|
|
user.set({userId:300,userName:'coach',honeyName:'张老师',groupId:3});
|
|
|
const harness=await RouterTestingHarness.create();
|