Skip to content

Commit a6c3419

Browse files
committed
Add client test
1 parent 5fa10d2 commit a6c3419

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/main/webapp/app/iris/overview/services/iris-chat.service.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
mockUserMessageWithContent,
2323
mockWebsocketServerMessage,
2424
mockWebsocketStatusMessage,
25+
mockWebsocketStatusMessageWithInteralStage,
2526
} from 'test/helpers/sample/iris-sample-data';
2627
import { IrisMessage, IrisUserMessage } from 'app/iris/shared/entities/iris-message.model';
2728
import 'app/shared/util/array.extension';
@@ -233,6 +234,18 @@ describe('IrisChatService', () => {
233234
tick();
234235
}));
235236

237+
it('should handle websocket status message with internal stages', fakeAsync(() => {
238+
jest.spyOn(httpService, 'getCurrentSessionOrCreateIfNotExists').mockReturnValueOnce(of(mockServerSessionHttpResponseWithId(id)));
239+
jest.spyOn(httpService, 'getChatSessions').mockReturnValue(of([]));
240+
jest.spyOn(wsMock, 'subscribeToSession').mockReturnValueOnce(of(mockWebsocketStatusMessageWithInteralStage));
241+
service.switchTo(ChatServiceMode.PROGRAMMING_EXERCISE, id);
242+
243+
service.currentStages().subscribe((stages) => {
244+
expect(stages).toEqual(mockWebsocketStatusMessageWithInteralStage.stages.filter((stage) => !stage.internal));
245+
});
246+
tick();
247+
}));
248+
236249
it('should handle websocket message', fakeAsync(() => {
237250
jest.spyOn(httpService, 'getCurrentSessionOrCreateIfNotExists').mockReturnValueOnce(of(mockServerSessionHttpResponseWithId(id)));
238251
jest.spyOn(httpService, 'getChatSessions').mockReturnValue(of([]));

src/test/javascript/spec/helpers/sample/iris-sample-data.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ export const mockWebsocketStatusMessage = {
8989
],
9090
} as IrisChatWebsocketDTO;
9191

92+
export const mockWebsocketStatusMessageWithInteralStage = {
93+
type: IrisChatWebsocketPayloadType.STATUS,
94+
stages: [
95+
{
96+
name: 'Stage 1',
97+
state: IrisStageStateDTO.IN_PROGRESS,
98+
},
99+
{
100+
name: 'Internal Stage',
101+
state: IrisStageStateDTO.IN_PROGRESS,
102+
internal: true,
103+
},
104+
],
105+
} as IrisChatWebsocketDTO;
106+
92107
export const mockConversation = {
93108
id: 1,
94109
exercise: irisExercise,

0 commit comments

Comments
 (0)