Skip to content

Commit 0e49113

Browse files
committed
feat: add tests for code prediction and stream connection with xCortiRetentionPolicy
1 parent 17dac5a commit 0e49113

2 files changed

Lines changed: 118 additions & 0 deletions

File tree

tests/custom/codes.predict.integration.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,54 @@ describe("cortiClient.codes.predict", () => {
156156
expect(consoleWarnSpy).not.toHaveBeenCalled();
157157
});
158158

159+
it("should predict codes with system icd10int-outpatient without errors or warnings", async () => {
160+
expect.assertions(2);
161+
162+
const result = await cortiClient.codes.predict({
163+
system: ["icd10int-outpatient"],
164+
context: [{ type: "text", text: faker.lorem.sentence() }],
165+
});
166+
167+
expect(result).toBeDefined();
168+
expect(consoleWarnSpy).not.toHaveBeenCalled();
169+
});
170+
171+
it("should predict codes with system icd10int-inpatient without errors or warnings", async () => {
172+
expect.assertions(2);
173+
174+
const result = await cortiClient.codes.predict({
175+
system: ["icd10int-inpatient"],
176+
context: [{ type: "text", text: faker.lorem.sentence() }],
177+
});
178+
179+
expect(result).toBeDefined();
180+
expect(consoleWarnSpy).not.toHaveBeenCalled();
181+
});
182+
183+
it("should predict codes with system icd10uk-outpatient without errors or warnings", async () => {
184+
expect.assertions(2);
185+
186+
const result = await cortiClient.codes.predict({
187+
system: ["icd10uk-outpatient"],
188+
context: [{ type: "text", text: faker.lorem.sentence() }],
189+
});
190+
191+
expect(result).toBeDefined();
192+
expect(consoleWarnSpy).not.toHaveBeenCalled();
193+
});
194+
195+
it("should predict codes with system icd10uk-inpatient without errors or warnings", async () => {
196+
expect.assertions(2);
197+
198+
const result = await cortiClient.codes.predict({
199+
system: ["icd10uk-inpatient"],
200+
context: [{ type: "text", text: faker.lorem.sentence() }],
201+
});
202+
203+
expect(result).toBeDefined();
204+
expect(consoleWarnSpy).not.toHaveBeenCalled();
205+
});
206+
159207
it("should predict codes with multiple systems without errors or warnings", async () => {
160208
expect.assertions(2);
161209

tests/custom/stream.connect.integration.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ describe("cortiClient.stream.connect", () => {
5252
id: interactionId,
5353
awaitConfiguration: false,
5454
configuration: {
55+
xCortiRetentionPolicy: "retain",
5556
transcription: {
5657
primaryLanguage: "en",
5758
isDiarization: true,
@@ -95,6 +96,7 @@ describe("cortiClient.stream.connect", () => {
9596
streamSocket.sendConfiguration({
9697
type: "config",
9798
configuration: {
99+
xCortiRetentionPolicy: "retain",
98100
transcription: {
99101
primaryLanguage: "en",
100102
isDiarization: true,
@@ -125,6 +127,74 @@ describe("cortiClient.stream.connect", () => {
125127
});
126128
});
127129

130+
describe("should connect with all xCortiRetentionPolicy enum values", () => {
131+
it("should connect with xCortiRetentionPolicy retain without errors or warnings", async () => {
132+
expect.assertions(2);
133+
134+
const interactionId = await createTestInteraction(cortiClient, createdInteractionIds);
135+
136+
const streamSocket = await cortiClient.stream.connect({
137+
id: interactionId,
138+
awaitConfiguration: false,
139+
configuration: {
140+
xCortiRetentionPolicy: "retain",
141+
transcription: {
142+
primaryLanguage: "en",
143+
participants: [
144+
{
145+
channel: 0,
146+
role: "doctor",
147+
},
148+
],
149+
},
150+
mode: {
151+
type: "facts",
152+
outputLocale: "en-US",
153+
},
154+
},
155+
});
156+
activeSockets.push(streamSocket);
157+
158+
await waitForWebSocketMessage(streamSocket, "CONFIG_ACCEPTED", { rejectOnWrongMessage: true });
159+
160+
expect(streamSocket.socket.readyState).toBe(1); // OPEN
161+
expect(consoleWarnSpy).not.toHaveBeenCalled();
162+
});
163+
164+
it("should connect with xCortiRetentionPolicy none without errors or warnings", async () => {
165+
expect.assertions(2);
166+
167+
const interactionId = await createTestInteraction(cortiClient, createdInteractionIds);
168+
169+
const streamSocket = await cortiClient.stream.connect({
170+
id: interactionId,
171+
awaitConfiguration: false,
172+
configuration: {
173+
xCortiRetentionPolicy: "none",
174+
transcription: {
175+
primaryLanguage: "en",
176+
participants: [
177+
{
178+
channel: 0,
179+
role: "doctor",
180+
},
181+
],
182+
},
183+
mode: {
184+
type: "facts",
185+
outputLocale: "en-US",
186+
},
187+
},
188+
});
189+
activeSockets.push(streamSocket);
190+
191+
await waitForWebSocketMessage(streamSocket, "CONFIG_ACCEPTED", { rejectOnWrongMessage: true });
192+
193+
expect(streamSocket.socket.readyState).toBe(1); // OPEN
194+
expect(consoleWarnSpy).not.toHaveBeenCalled();
195+
});
196+
});
197+
128198
describe("should connect with different participant roles", () => {
129199
it("should connect with doctor role", async () => {
130200
expect.assertions(2);

0 commit comments

Comments
 (0)