Skip to content

Commit 1dfe346

Browse files
author
smoghe-bw
committed
refactor: remove ConnectStatus enum and connect status fields from ReadyMetadata
1 parent 042d632 commit 1dfe346

3 files changed

Lines changed: 9 additions & 64 deletions

File tree

src/types.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ export enum EndpointType {
2121
PHONE_NUMBER = "PHONE_NUMBER",
2222
}
2323

24-
export enum ConnectStatus {
25-
INITIATED = "INITIATED",
26-
COMPLETED = "COMPLETED",
27-
TIMED_OUT = "TIMED_OUT",
28-
DENIED = "DENIED",
29-
CANCELED = "CANCELED",
30-
FAILED = "FAILED",
31-
}
32-
3324
export type AudioLevelChangeHandler = { (audioLevel: AudioLevel): void };
3425

3526
/**
@@ -59,15 +50,6 @@ export interface ReadyMetadata {
5950
deviceId: string;
6051
territory: string; // TODO enum
6152
region: string; // TODO enum
62-
connectStatus?: ConnectStatus;
63-
accountId?: string;
64-
sessionId?: string;
65-
from?: string;
66-
fromType?: string;
67-
fromTags?: string;
68-
to?: string;
69-
toType?: string;
70-
toTags?: string;
7153
}
7254

7355
export interface OutboundConnectionResult {

src/v1/signaling.test.ts

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -94,47 +94,19 @@ describe("Signaling connect method", () => {
9494
}
9595
});
9696

97-
test("should emit ready with connectStatus fields when gateway sends ready with connect status data", async () => {
97+
test("should emit established when websocket receives established", async () => {
9898
const emitSpy = jest.spyOn(signaling, "emit");
9999

100100
await signaling.connect({ endpointToken: "test-token" });
101101

102-
// Simulate a second ready event from the gateway that includes connect status fields
102+
// Get the websocket instance and trigger established event
103103
const ws = (signaling as any).ws;
104-
const readyCallback = ws.on.mock.calls.find((call: any) => call[0] === "ready")?.[1];
105-
106-
if (readyCallback) {
107-
const readyWithConnectStatus = {
108-
endpointId: "test-endpoint",
109-
deviceId: "device-1",
110-
territory: "US",
111-
region: "us-east-1",
112-
connectStatus: "COMPLETED",
113-
accountId: "9900000",
114-
sessionId: "session-1",
115-
from: "ep-1",
116-
fromType: "ENDPOINT",
117-
fromTags: "tag1",
118-
to: "ep-2",
119-
toType: "ENDPOINT",
120-
toTags: "tag2",
121-
};
122-
readyCallback(readyWithConnectStatus);
123-
expect(emitSpy).toHaveBeenCalledWith(
124-
"ready",
125-
expect.objectContaining({
126-
endpointId: "test-endpoint",
127-
connectStatus: "COMPLETED",
128-
accountId: "9900000",
129-
sessionId: "session-1",
130-
from: "ep-1",
131-
fromType: "ENDPOINT",
132-
fromTags: "tag1",
133-
to: "ep-2",
134-
toType: "ENDPOINT",
135-
toTags: "tag2",
136-
}),
137-
);
104+
const establishedCallback = ws.on.mock.calls.find((call: any) => call[0] === "established")?.[1];
105+
106+
if (establishedCallback) {
107+
const testEvent = { connectionId: "test-connection" };
108+
establishedCallback(testEvent);
109+
expect(emitSpy).toHaveBeenCalledWith("established", testEvent);
138110
}
139111
});
140112
});

src/v1/types.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MediaType, ConnectStatus } from "../types";
1+
import { MediaType } from "../types";
22

33
export interface SetMediaPreferencesWebRtcResponse {
44
endpointId: string;
@@ -69,13 +69,4 @@ export interface ReadyMetadata {
6969
deviceId: string;
7070
territory: string; // TODO enum
7171
region: string; // TODO enum
72-
connectStatus?: ConnectStatus;
73-
accountId?: string;
74-
sessionId?: string;
75-
from?: string;
76-
fromType?: string;
77-
fromTags?: string;
78-
to?: string;
79-
toType?: string;
80-
toTags?: string;
8172
}

0 commit comments

Comments
 (0)