Skip to content

Commit

Permalink
refactor(TeacherNodeService): Update dependencies and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hirokiterashima committed Dec 18, 2024
1 parent a403863 commit ad2876e
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 28 deletions.
3 changes: 2 additions & 1 deletion src/app/services/studentNodeService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DataService } from './data.service';
import { ProjectService } from '../../assets/wise5/services/projectService';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { Node } from '../../assets/wise5/common/Node';
import { StudentDataService } from '../../assets/wise5/services/studentDataService';

let dataService: DataService;
let dialog: MatDialog;
Expand All @@ -21,7 +22,7 @@ describe('StudentNodeService', () => {
imports: [MatDialogModule, StudentTeacherCommonServicesModule],
providers: [provideHttpClient(withInterceptorsFromDi())]
});
dataService = TestBed.inject(DataService);
dataService = TestBed.inject(StudentDataService);
dialog = TestBed.inject(MatDialog);
service = TestBed.inject(StudentNodeService);
nodeStatusService = TestBed.inject(NodeStatusService);
Expand Down
18 changes: 11 additions & 7 deletions src/app/services/teacherNodeService.spec.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { MatDialogModule } from '@angular/material/dialog';
import { StudentTeacherCommonServicesModule } from '../student-teacher-common-services.module';
import { DataService } from './data.service';
import { ProjectService } from '../../assets/wise5/services/projectService';
import { TeacherNodeService } from '../../assets/wise5/services/teacherNodeService';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { TeacherDataService } from '../../assets/wise5/services/teacherDataService';
import { TeacherProjectService } from '../../assets/wise5/services/teacherProjectService';

let dataService: DataService;
const nodeId1 = 'node1';
const nodeId2 = 'node2';
let projectService: ProjectService;
let service: TeacherNodeService;

describe('TeacherNodeService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [MatDialogModule, StudentTeacherCommonServicesModule],
providers: [TeacherNodeService, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
});
dataService = TestBed.inject(DataService);
projectService = TestBed.inject(ProjectService);
imports: [MatDialogModule, StudentTeacherCommonServicesModule],
providers: [
TeacherNodeService,
TeacherProjectService,
provideHttpClient(withInterceptorsFromDi())
]
});
dataService = TestBed.inject(TeacherDataService);
projectService = TestBed.inject(TeacherProjectService);
service = TestBed.inject(TeacherNodeService);
});
getNextNodeId();
Expand Down
8 changes: 8 additions & 0 deletions src/app/student-teacher-common-services.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ import { CompletionService } from '../assets/wise5/services/completionService';
import { StudentNodeService } from '../assets/wise5/services/studentNodeService';
import { StudentProjectTranslationService } from '../assets/wise5/services/studentProjectTranslationService';
import { AiChatService } from '../assets/wise5/components/aiChat/aiChatService';
import { TeacherNodeService } from '../assets/wise5/services/teacherNodeService';
import { TeacherDataService } from '../assets/wise5/services/teacherDataService';
import { TeacherWebSocketService } from '../assets/wise5/services/teacherWebSocketService';
import { ClassroomStatusService } from '../assets/wise5/services/classroomStatusService';

@NgModule({
providers: [
Expand All @@ -65,6 +69,7 @@ import { AiChatService } from '../assets/wise5/components/aiChat/aiChatService';
AudioOscillatorService,
AudioRecorderService,
BranchService,
ClassroomStatusService,
ClickToSnipImageService,
ConceptMapService,
ConstraintService,
Expand Down Expand Up @@ -111,6 +116,9 @@ import { AiChatService } from '../assets/wise5/components/aiChat/aiChatService';
TableService,
TabulatorDataService,
TagService,
TeacherDataService,
TeacherNodeService,
TeacherWebSocketService,
StudentProjectTranslationService,
VLEProjectService,
WiseLinkService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { NodeService } from '../../services/nodeService';
import { ClassroomStatusService } from '../../services/classroomStatusService';
import { TeacherDataService } from '../../services/teacherDataService';
import { TeacherProjectService } from '../../services/teacherProjectService';
Expand All @@ -9,6 +7,7 @@ import { StepToolsComponent } from './step-tools.component';
import { StudentTeacherCommonServicesModule } from '../../../../app/student-teacher-common-services.module';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { StudentNodeService } from '../../services/studentNodeService';

describe('StepTools', () => {
let component: StepToolsComponent;
Expand All @@ -19,12 +18,11 @@ describe('StepTools', () => {
imports: [NoopAnimationsModule, StepToolsComponent, StudentTeacherCommonServicesModule],
providers: [
ClassroomStatusService,
NodeService,
StudentNodeService,
TeacherDataService,
TeacherProjectService,
TeacherWebSocketService,
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting()
provideHttpClient(withInterceptorsFromDi())
]
});
fixture = TestBed.createComponent(StepToolsComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let fixture: ComponentFixture<EditGraphAdvancedComponent>;
describe('EditGraphAdvancedComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [
declarations: [
EditComponentAddToNotebookButtonComponent,
EditCommonAdvancedComponent,
EditComponentExcludeFromTotalScoreComponent,
Expand All @@ -46,18 +46,25 @@ describe('EditGraphAdvancedComponent', () => {
EditConnectedComponentsAddButtonComponent,
EditConnectedComponentsComponent,
EditGraphAdvancedComponent
],
schemas: [NO_ERRORS_SCHEMA],
imports: [BrowserAnimationsModule,
],
schemas: [NO_ERRORS_SCHEMA],
imports: [
BrowserAnimationsModule,
FormsModule,
MatCheckboxModule,
MatDialogModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
StudentTeacherCommonServicesModule],
providers: [TeacherNodeService, TeacherProjectService, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
}).compileComponents();
StudentTeacherCommonServicesModule
],
providers: [
TeacherNodeService,
TeacherProjectService,
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting()
]
}).compileComponents();
});

beforeEach(() => {
Expand Down
15 changes: 15 additions & 0 deletions src/assets/wise5/services/teacherNodeService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Injectable } from '@angular/core';
import { NodeService } from './nodeService';
import { Subject, Observable } from 'rxjs';
import { TeacherDataService } from './teacherDataService';
import { TeacherProjectService } from './teacherProjectService';
import { MatDialog } from '@angular/material/dialog';
import { ConfigService } from './configService';
import { ConstraintService } from './constraintService';

@Injectable()
export class TeacherNodeService extends NodeService {
Expand All @@ -12,6 +17,16 @@ export class TeacherNodeService extends NodeService {
private starterStateResponseSource: Subject<any> = new Subject<any>();
public starterStateResponse$: Observable<any> = this.starterStateResponseSource.asObservable();

constructor(
protected dataService: TeacherDataService,
protected dialog: MatDialog,
protected configService: ConfigService,
protected constraintService: ConstraintService,
protected projectService: TeacherProjectService
) {
super(dataService, dialog, configService, constraintService, projectService);
}

broadcastComponentShowSubmitButtonValueChanged(args: any): void {
this.componentShowSubmitButtonValueChangedSource.next(args);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ProjectService } from '../../../../services/projectService';
import { StudentDataService } from '../../../../services/studentDataService';
import { StepToolsComponent } from './step-tools.component';
import { StudentTeacherCommonServicesModule } from '../../../../../../app/student-teacher-common-services.module';
import { NodeStatusService } from '../../../../services/nodeStatusService';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { VLEProjectService } from '../../../../vle/vleProjectService';

const nodeId1 = 'node1';
const nodeStatus1 = { icon: '', isCompleted: true };
const nodeStatus2 = { icon: '', isCompleted: false };
let getCurrentNodeIdSpy: jasmine.Spy;

describe('StepToolsComponent', () => {
let component: StepToolsComponent;
let fixture: ComponentFixture<StepToolsComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [NoopAnimationsModule, StepToolsComponent, StudentTeacherCommonServicesModule],
providers: [provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
providers: [provideHttpClient(withInterceptorsFromDi())]
}).compileComponents();
});

Expand All @@ -35,7 +33,9 @@ describe('StepToolsComponent', () => {
spyOn(TestBed.inject(NodeStatusService), 'getNodeStatusByNodeId').and.returnValue({
isCompleted: true
});
spyOn(TestBed.inject(ProjectService), 'nodeHasWork').and.returnValue(true);
const projectService = TestBed.inject(VLEProjectService);
spyOn(projectService, 'nodeHasWork').and.returnValue(true);
spyOn(projectService, 'getNodesByToNodeId').and.returnValue([]);
component = fixture.componentInstance;
fixture.detectChanges();
});
Expand Down
6 changes: 3 additions & 3 deletions src/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -10298,7 +10298,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/shared/top-bar/top-bar.component.html</context>
<context context-type="linenumber">69</context>
<context context-type="linenumber">71</context>
</context-group>
</trans-unit>
<trans-unit id="198c48cd09b7766410bfeca2dad7f3fa08bf8e48" datatype="html">
Expand All @@ -10309,7 +10309,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/shared/top-bar/top-bar.component.html</context>
<context context-type="linenumber">94,96</context>
<context context-type="linenumber">96,98</context>
</context-group>
</trans-unit>
<trans-unit id="d03a265c20b6d1b20ceabc5938d1046689c73891" datatype="html">
Expand All @@ -10320,7 +10320,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/shared/top-bar/top-bar.component.html</context>
<context context-type="linenumber">98,100</context>
<context context-type="linenumber">100,102</context>
</context-group>
</trans-unit>
<trans-unit id="2548722187082258540" datatype="html">
Expand Down

0 comments on commit ad2876e

Please sign in to comment.