|
|
@@ -23,6 +23,7 @@ class LearningModulesApiService {
|
|
|
lastMemoryParams: Record<string, unknown> = {};
|
|
|
lastStandaloneLearningRecord: Record<string, unknown> = {};
|
|
|
appointmentStatus = 0;
|
|
|
+ historyWordAudio = '';
|
|
|
completionRequests: Record<string, unknown>[] = [];
|
|
|
completionResponse = new Subject<ApiEnvelope<unknown>>();
|
|
|
lastAppointmentRecordParams: Record<string, unknown> = {};
|
|
|
@@ -252,7 +253,7 @@ class LearningModulesApiService {
|
|
|
if (action === 'e_record_detail') {
|
|
|
return of({
|
|
|
retcode: 1,
|
|
|
- result: [{ GeneralID: 701, Title: 'apple', detail: [{ GeneralID: 701, Title: 'apple', sy: '苹果', yp: '' }] }],
|
|
|
+ result: [{ GeneralID: 701, Title: 'apple', detail: [{ GeneralID: 701, Title: 'apple', sy: '苹果', yp: this.historyWordAudio }] }],
|
|
|
addon: [{ if_writing: '0', if_writing_tips: '先回忆单词,再查看释义' }],
|
|
|
} as unknown as ApiEnvelope<T>);
|
|
|
}
|
|
|
@@ -325,6 +326,48 @@ describe('home learning modules', () => {
|
|
|
expect(play).not.toHaveBeenCalled();
|
|
|
});
|
|
|
|
|
|
+ it('plays student history words on click without changing learning records or enabling unit preview audio', async () => {
|
|
|
+ const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
+ api.historyWordAudio = 'apple.mp3';
|
|
|
+ const post = spyOn(api, 'post').and.callThrough();
|
|
|
+ const platform = TestBed.inject(PlatformService);
|
|
|
+ const play = spyOn(platform, 'play');
|
|
|
+ const stopAudio = spyOn(platform, 'stopAudio');
|
|
|
+ const harness = await RouterTestingHarness.create();
|
|
|
+ await harness.navigateByUrl('/pages/his/his');
|
|
|
+ (harness.routeNativeElement?.querySelector('.learning-record-card .learning-item') as HTMLElement).click();
|
|
|
+ await harness.fixture.whenStable();
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ expect(TestBed.inject(Router).url).toBe('/pages/his/his_words?id=201');
|
|
|
+ expect(play).not.toHaveBeenCalled();
|
|
|
+ post.calls.reset();
|
|
|
+ const button = harness.routeNativeElement?.querySelector('.history-word-audio') as HTMLButtonElement;
|
|
|
+ expect(button.disabled).toBeFalse();
|
|
|
+ expect(button.getAttribute('aria-label')).toBe('播放单词读音:apple');
|
|
|
+ button.querySelector('strong')!.click();
|
|
|
+ (button.querySelector('lucide-icon') as HTMLElement).click();
|
|
|
+ expect(play).toHaveBeenCalledTimes(2);
|
|
|
+ expect(play.calls.mostRecent().args[0]).toContain('apple.mp3');
|
|
|
+ expect(post).not.toHaveBeenCalled();
|
|
|
+
|
|
|
+ const learning = harness.fixture.debugElement.query(By.directive(LearningPageComponent)).componentInstance as LearningPageComponent;
|
|
|
+ learning.words.update((words) => words.map((word) => ({ ...word, audio: '' })));
|
|
|
+ harness.fixture.detectChanges();
|
|
|
+ expect(button.disabled).toBeTrue();
|
|
|
+ expect(harness.routeNativeElement?.textContent).toContain('暂无音频');
|
|
|
+ button.click();
|
|
|
+ expect(play).toHaveBeenCalledTimes(2);
|
|
|
+
|
|
|
+ stopAudio.calls.reset();
|
|
|
+ await harness.navigateByUrl('/pages/home/index');
|
|
|
+ expect(stopAudio).toHaveBeenCalled();
|
|
|
+ await harness.navigateByUrl('/pages/stu/stu_con?nid=811&readonly=1');
|
|
|
+ expect(harness.routeNativeElement?.querySelector('.history-word-audio')).toBeNull();
|
|
|
+ const preview = harness.fixture.debugElement.query(By.directive(LearningPageComponent)).componentInstance as LearningPageComponent;
|
|
|
+ preview.words().forEach((word) => preview.play(word));
|
|
|
+ expect(play).toHaveBeenCalledTimes(2);
|
|
|
+ });
|
|
|
+
|
|
|
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);
|