|
@@ -18,6 +18,10 @@ class LearningModulesApiService {
|
|
|
lastLearningWordUpdate: Record<string, unknown> = {};
|
|
lastLearningWordUpdate: Record<string, unknown> = {};
|
|
|
lastMemoryParams: Record<string, unknown> = {};
|
|
lastMemoryParams: Record<string, unknown> = {};
|
|
|
lastStandaloneLearningRecord: Record<string, unknown> = {};
|
|
lastStandaloneLearningRecord: Record<string, unknown> = {};
|
|
|
|
|
+ unitRows: Record<string, unknown>[] = [
|
|
|
|
|
+ { NodeID: 811, NodeName: 'Unit 1', yx_word: 1, total: 20 },
|
|
|
|
|
+ { NodeID: 812, NodeName: 'Unit 2', yx_word: 0, total: 18 },
|
|
|
|
|
+ ];
|
|
|
|
|
|
|
|
get<T>(action: string, params: Record<string, unknown> = {}): Observable<ApiEnvelope<T>> {
|
|
get<T>(action: string, params: Record<string, unknown> = {}): Observable<ApiEnvelope<T>> {
|
|
|
if (action === 'e_order_detail') {
|
|
if (action === 'e_order_detail') {
|
|
@@ -75,10 +79,7 @@ class LearningModulesApiService {
|
|
|
}
|
|
}
|
|
|
if (action === 'node_list' && Number(params['pid']) === 801) {
|
|
if (action === 'node_list' && Number(params['pid']) === 801) {
|
|
|
this.lastNodeParams = params;
|
|
this.lastNodeParams = params;
|
|
|
- return this.result<T>([
|
|
|
|
|
- { NodeID: 811, NodeName: 'Unit 1', yx_word: 1, total: 20 },
|
|
|
|
|
- { NodeID: 812, NodeName: 'Unit 2', yx_word: 0, total: 18 },
|
|
|
|
|
- ]);
|
|
|
|
|
|
|
+ return this.result<T>(this.unitRows);
|
|
|
}
|
|
}
|
|
|
if (action === 'e_ck_list') {
|
|
if (action === 'e_ck_list') {
|
|
|
this.lastWordParams = params;
|
|
this.lastWordParams = params;
|
|
@@ -700,6 +701,43 @@ describe('home learning modules', () => {
|
|
|
expect(courseSelect.value).toBe('801');
|
|
expect(courseSelect.value).toBe('801');
|
|
|
expect(courseSelect.selectedOptions[0]?.textContent).toContain('七年级上册');
|
|
expect(courseSelect.selectedOptions[0]?.textContent).toContain('七年级上册');
|
|
|
expect(harness.routeNativeElement?.querySelectorAll('.unit-grid article').length).toBe(2);
|
|
expect(harness.routeNativeElement?.querySelectorAll('.unit-grid article').length).toBe(2);
|
|
|
|
|
+ const unitButtons = harness.routeNativeElement?.querySelectorAll<HTMLButtonElement>('.unit-select');
|
|
|
|
|
+ expect(unitButtons?.[0].textContent).toContain('已学 5%');
|
|
|
|
|
+ expect(unitButtons?.[0].textContent).toContain('1/20 词');
|
|
|
|
|
+ expect(unitButtons?.[1].textContent).toContain('已学 0%');
|
|
|
|
|
+ expect(unitButtons?.[1].textContent).toContain('0/18 词');
|
|
|
|
|
+ expect((unitButtons?.[0].querySelector('.unit-progress-track > span') as HTMLElement).style.width).toBe('5%');
|
|
|
|
|
+ unitButtons?.[0].click();
|
|
|
|
|
+ unitButtons?.[1].click();
|
|
|
|
|
+ harness.fixture.detectChanges();
|
|
|
|
|
+ expect(harness.routeNativeElement?.querySelectorAll('.unit-select[aria-pressed="true"]').length).toBe(2);
|
|
|
|
|
+ expect(unitButtons?.[0].textContent).toContain('已学 5%');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ it('distinguishes completed, empty and unavailable appointment vocabulary progress', async () => {
|
|
|
|
|
+ user.set({ userId: 300, userName: 'coach', honeyName: '张老师', groupId: 3 });
|
|
|
|
|
+ session.groupId.set(3);
|
|
|
|
|
+ const api = TestBed.inject(ApiService) as unknown as LearningModulesApiService;
|
|
|
|
|
+ api.unitRows = [
|
|
|
|
|
+ { NodeID: 811, NodeName: '已学全册', yx_word: '20', total: '20' },
|
|
|
|
|
+ { NodeID: 812, NodeName: '空册', yx_word: 0, total: 0 },
|
|
|
|
|
+ { NodeID: 813, NodeName: '缺少统计' },
|
|
|
|
|
+ { NodeID: 814, NodeName: '异常统计', yx_word: 'invalid', total: 20 },
|
|
|
|
|
+ ];
|
|
|
|
|
+ const harness = await RouterTestingHarness.create();
|
|
|
|
|
+ await harness.navigateByUrl('/pages/shop/get_order?id=901');
|
|
|
|
|
+ await harness.fixture.whenStable();
|
|
|
|
|
+ harness.fixture.detectChanges();
|
|
|
|
|
+
|
|
|
|
|
+ const units = harness.routeNativeElement?.querySelectorAll('.unit-select');
|
|
|
|
|
+ expect(units?.[0].textContent).toContain('已学 100%');
|
|
|
|
|
+ expect(units?.[0].textContent).toContain('20/20 词');
|
|
|
|
|
+ expect(units?.[1].textContent).toContain('已学 0%');
|
|
|
|
|
+ expect(units?.[1].textContent).toContain('暂无单词');
|
|
|
|
|
+ for (const index of [2, 3]) {
|
|
|
|
|
+ expect(units?.[index].textContent).toContain('暂无进度数据');
|
|
|
|
|
+ expect(units?.[index].querySelector('.unit-progress-track')).toBeNull();
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it('counts words marked as known as completed and persists them for the student', async () => {
|
|
it('counts words marked as known as completed and persists them for the student', async () => {
|