Skip to content

Commit 2f1c683

Browse files
Cover ws and wss baseURL protocol rejection
Co-authored-by: Eric Allam <eric@trigger.dev>
1 parent c00d630 commit 2f1c683

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

packages/ai/src/chatTransport.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,28 @@ describe("TriggerChatTransport", function () {
653653
}).toThrowError("baseURL must use http or https protocol");
654654
});
655655

656+
it("throws when baseURL protocol is ws", function () {
657+
expect(function () {
658+
new TriggerChatTransport({
659+
task: "chat-task",
660+
accessToken: "pk_trigger",
661+
baseURL: "ws://example.com",
662+
stream: "chat-stream",
663+
});
664+
}).toThrowError("baseURL must use http or https protocol");
665+
});
666+
667+
it("throws when baseURL protocol is wss", function () {
668+
expect(function () {
669+
new TriggerChatTransport({
670+
task: "chat-task",
671+
accessToken: "pk_trigger",
672+
baseURL: "wss://example.com",
673+
stream: "chat-stream",
674+
});
675+
}).toThrowError("baseURL must use http or https protocol");
676+
});
677+
656678
it("throws when baseURL includes query parameters", function () {
657679
expect(function () {
658680
new TriggerChatTransport({
@@ -2958,6 +2980,28 @@ describe("TriggerChatTransport", function () {
29582980
}).toThrowError("baseURL must use http or https protocol");
29592981
});
29602982

2983+
it("throws from factory when baseURL protocol is ws", function () {
2984+
expect(function () {
2985+
createTriggerChatTransport({
2986+
task: "chat-task",
2987+
accessToken: "pk_trigger",
2988+
baseURL: "ws://example.com",
2989+
stream: "chat-stream",
2990+
});
2991+
}).toThrowError("baseURL must use http or https protocol");
2992+
});
2993+
2994+
it("throws from factory when baseURL protocol is wss", function () {
2995+
expect(function () {
2996+
createTriggerChatTransport({
2997+
task: "chat-task",
2998+
accessToken: "pk_trigger",
2999+
baseURL: "wss://example.com",
3000+
stream: "chat-stream",
3001+
});
3002+
}).toThrowError("baseURL must use http or https protocol");
3003+
});
3004+
29613005
it("throws from factory when baseURL includes query parameters", function () {
29623006
expect(function () {
29633007
createTriggerChatTransport({

0 commit comments

Comments
 (0)