diff --git a/src/app/services/cRaterPingService.spec.ts b/src/app/services/cRaterPingService.spec.ts new file mode 100644 index 00000000000..0c6aa052077 --- /dev/null +++ b/src/app/services/cRaterPingService.spec.ts @@ -0,0 +1,40 @@ +import { HttpClient } from '@angular/common/http'; +import { CRaterPingService } from '../../assets/wise5/services/cRaterPingService'; +import { TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { MockProvider } from 'ng-mocks'; +import { of } from 'rxjs'; + +let cRaterPingService: CRaterPingService; +let httpClientMock: jasmine.Spy; +const testId = 'berkeley_test_id'; + +describe('CRaterPingService', () => { + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [MockProvider(HttpClient), CRaterPingService] + }); + cRaterPingService = TestBed.inject(CRaterPingService); + httpClientMock = spyOn(TestBed.inject(HttpClient), 'post').and.returnValue(of({})); + }); + + it('should send ping to endpoint when startPinging() is called', () => { + cRaterPingService.startPinging(testId); + expect(httpClientMock).toHaveBeenCalledTimes(1); + }); + + it('should wait before sending another ping', fakeAsync(() => { + cRaterPingService.startPinging(testId); + tick(294999); + expect(httpClientMock).toHaveBeenCalledTimes(1); + tick(2); + expect(httpClientMock).toHaveBeenCalledTimes(2); + })); + + it('should stop trying to ping when stopPinging()', fakeAsync(() => { + cRaterPingService.startPinging(testId); + expect(httpClientMock).toHaveBeenCalledTimes(1); + cRaterPingService.stopPinging(testId); + tick(500000); + expect(httpClientMock).toHaveBeenCalledTimes(1); + })); +}); diff --git a/src/app/student-teacher-common-services.module.ts b/src/app/student-teacher-common-services.module.ts index 158f6dff01f..98ac36eec2d 100644 --- a/src/app/student-teacher-common-services.module.ts +++ b/src/app/student-teacher-common-services.module.ts @@ -1,64 +1,65 @@ -import { NgModule } from '@angular/core'; +import { AchievementService } from '../assets/wise5/services/achievementService'; +import { AiChatService } from '../assets/wise5/components/aiChat/aiChatService'; +import { AnimationService } from '../assets/wise5/components/animation/animationService'; +import { AnnotationService } from '../assets/wise5/services/annotationService'; +import { AudioOscillatorService } from '../assets/wise5/components/audioOscillator/audioOscillatorService'; +import { AudioRecorderService } from '../assets/wise5/services/audioRecorderService'; +import { BranchService } from '../assets/wise5/services/branchService'; +import { ClassroomStatusService } from '../assets/wise5/services/classroomStatusService'; +import { ClickToSnipImageService } from '../assets/wise5/services/clickToSnipImageService'; +import { CompletionService } from '../assets/wise5/services/completionService'; +import { ComponentService } from '../assets/wise5/components/componentService'; +import { ComponentServiceLookupService } from '../assets/wise5/services/componentServiceLookupService'; +import { ComponentTypeService } from '../assets/wise5/services/componentTypeService'; +import { ComputerAvatarService } from '../assets/wise5/services/computerAvatarService'; +import { ConceptMapService } from '../assets/wise5/components/conceptMap/conceptMapService'; import { ConfigService } from '../assets/wise5/services/configService'; -import { ProjectService } from '../assets/wise5/services/projectService'; -import { ProjectLibraryService } from '../assets/wise5/services/projectLibraryService'; -import { VLEProjectService } from '../assets/wise5/vle/vleProjectService'; +import { ConstraintService } from '../assets/wise5/services/constraintService'; import { CRaterService } from '../assets/wise5/services/cRaterService'; -import { SessionService } from '../assets/wise5/services/sessionService'; -import { StudentAssetService } from '../assets/wise5/services/studentAssetService'; -import { TagService } from '../assets/wise5/services/tagService'; -import { AudioRecorderService } from '../assets/wise5/services/audioRecorderService'; -import { AnnotationService } from '../assets/wise5/services/annotationService'; -import { StudentWebSocketService } from '../assets/wise5/services/studentWebSocketService'; -import { StudentDataService } from '../assets/wise5/services/studentDataService'; -import { AchievementService } from '../assets/wise5/services/achievementService'; -import { SummaryService } from '../assets/wise5/components/summary/summaryService'; -import { TableService } from '../assets/wise5/components/table/tableService'; -import { NotebookService } from '../assets/wise5/services/notebookService'; -import { NotificationService } from '../assets/wise5/services/notificationService'; -import { OutsideURLService } from '../assets/wise5/components/outsideURL/outsideURLService'; -import { MatchService } from '../assets/wise5/components/match/matchService'; -import { MultipleChoiceService } from '../assets/wise5/components/multipleChoice/multipleChoiceService'; -import { OpenResponseService } from '../assets/wise5/components/openResponse/openResponseService'; -import { NodeService } from '../assets/wise5/services/nodeService'; +import { DialogGuidanceService } from '../assets/wise5/components/dialogGuidance/dialogGuidanceService'; import { DiscussionService } from '../assets/wise5/components/discussion/discussionService'; import { DrawService } from '../assets/wise5/components/draw/drawService'; import { EmbeddedService } from '../assets/wise5/components/embedded/embeddedService'; +import { GraphService } from '../assets/wise5/components/graph/graphService'; import { HTMLService } from '../assets/wise5/components/html/htmlService'; import { LabelService } from '../assets/wise5/components/label/labelService'; -import { AnimationService } from '../assets/wise5/components/animation/animationService'; -import { AudioOscillatorService } from '../assets/wise5/components/audioOscillator/audioOscillatorService'; -import { ConceptMapService } from '../assets/wise5/components/conceptMap/conceptMapService'; -import { GraphService } from '../assets/wise5/components/graph/graphService'; -import { ComponentService } from '../assets/wise5/components/componentService'; -import { WiseLinkService } from './services/wiseLinkService'; -import { DialogGuidanceService } from '../assets/wise5/components/dialogGuidance/dialogGuidanceService'; -import { PeerChatService } from '../assets/wise5/components/peerChat/peerChatService'; -import { ShowMyWorkService } from '../assets/wise5/components/showMyWork/showMyWorkService'; -import { ShowGroupWorkService } from '../assets/wise5/components/showGroupWork/showGroupWorkService'; -import { ComputerAvatarService } from '../assets/wise5/services/computerAvatarService'; -import { StudentStatusService } from '../assets/wise5/services/studentStatusService'; +import { MatchService } from '../assets/wise5/components/match/matchService'; +import { MultipleChoiceService } from '../assets/wise5/components/multipleChoice/multipleChoiceService'; +import { NgModule } from '@angular/core'; +import { NodeProgressService } from '../assets/wise5/services/nodeProgressService'; +import { NodeService } from '../assets/wise5/services/nodeService'; +import { NodeStatusService } from '../assets/wise5/services/nodeStatusService'; +import { NotebookService } from '../assets/wise5/services/notebookService'; +import { NotificationService } from '../assets/wise5/services/notificationService'; import { OpenResponseCompletionCriteriaService } from '../assets/wise5/components/openResponse/openResponseCompletionCriteriaService'; -import { ComponentServiceLookupService } from '../assets/wise5/services/componentServiceLookupService'; -import { ComponentTypeService } from '../assets/wise5/services/componentTypeService'; -import { BranchService } from '../assets/wise5/services/branchService'; +import { OpenResponseService } from '../assets/wise5/components/openResponse/openResponseService'; +import { OutsideURLService } from '../assets/wise5/components/outsideURL/outsideURLService'; import { PathService } from '../assets/wise5/services/pathService'; -import { TabulatorDataService } from '../assets/wise5/components/table/tabulatorDataService'; -import { StompService } from '../assets/wise5/services/stompService'; -import { ClickToSnipImageService } from '../assets/wise5/services/clickToSnipImageService'; -import { StudentPeerGroupService } from '../assets/wise5/services/studentPeerGroupService'; -import { ConstraintService } from '../assets/wise5/services/constraintService'; -import { NodeStatusService } from '../assets/wise5/services/nodeStatusService'; +import { PeerChatService } from '../assets/wise5/components/peerChat/peerChatService'; import { PeerGroupService } from '../assets/wise5/services/peerGroupService'; -import { NodeProgressService } from '../assets/wise5/services/nodeProgressService'; -import { CompletionService } from '../assets/wise5/services/completionService'; +import { CRaterPingService } from '../assets/wise5/services/cRaterPingService'; +import { ProjectLibraryService } from '../assets/wise5/services/projectLibraryService'; +import { ProjectService } from '../assets/wise5/services/projectService'; +import { SessionService } from '../assets/wise5/services/sessionService'; +import { ShowGroupWorkService } from '../assets/wise5/components/showGroupWork/showGroupWorkService'; +import { ShowMyWorkService } from '../assets/wise5/components/showMyWork/showMyWorkService'; +import { StompService } from '../assets/wise5/services/stompService'; +import { StudentAssetService } from '../assets/wise5/services/studentAssetService'; +import { StudentDataService } from '../assets/wise5/services/studentDataService'; import { StudentNodeService } from '../assets/wise5/services/studentNodeService'; +import { StudentPeerGroupService } from '../assets/wise5/services/studentPeerGroupService'; import { StudentProjectTranslationService } from '../assets/wise5/services/studentProjectTranslationService'; -import { AiChatService } from '../assets/wise5/components/aiChat/aiChatService'; -import { TeacherNodeService } from '../assets/wise5/services/teacherNodeService'; +import { StudentStatusService } from '../assets/wise5/services/studentStatusService'; +import { StudentWebSocketService } from '../assets/wise5/services/studentWebSocketService'; +import { SummaryService } from '../assets/wise5/components/summary/summaryService'; +import { TableService } from '../assets/wise5/components/table/tableService'; +import { TabulatorDataService } from '../assets/wise5/components/table/tabulatorDataService'; +import { TagService } from '../assets/wise5/services/tagService'; import { TeacherDataService } from '../assets/wise5/services/teacherDataService'; +import { TeacherNodeService } from '../assets/wise5/services/teacherNodeService'; import { TeacherWebSocketService } from '../assets/wise5/services/teacherWebSocketService'; -import { ClassroomStatusService } from '../assets/wise5/services/classroomStatusService'; +import { VLEProjectService } from '../assets/wise5/vle/vleProjectService'; +import { WiseLinkService } from './services/wiseLinkService'; @NgModule({ providers: [ @@ -100,6 +101,7 @@ import { ClassroomStatusService } from '../assets/wise5/services/classroomStatus PathService, PeerChatService, PeerGroupService, + CRaterPingService, ProjectLibraryService, { provide: ProjectService, useExisting: VLEProjectService }, SessionService, diff --git a/src/assets/wise5/common/chat-input/chat-input.component.html b/src/assets/wise5/common/chat-input/chat-input.component.html index d284b34aee1..3edec8608db 100644 --- a/src/assets/wise5/common/chat-input/chat-input.component.html +++ b/src/assets/wise5/common/chat-input/chat-input.component.html @@ -7,6 +7,7 @@ i18n-placeholder [(ngModel)]="response" (keypress)="keyPressed($event)" + (focus)="focusEvent.emit()" >