|
1 | 1 | /* eslint-disable @typescript-eslint/no-unused-vars */
|
2 | 2 | /* eslint-disable @typescript-eslint/require-await */
|
3 |
| -import { describe, expect, spyOn, test } from "bun:test"; |
| 3 | +import { describe, expect, jest, spyOn, test } from "bun:test"; |
4 | 4 | import { serve } from ".";
|
5 | 5 | import {
|
6 | 6 | driveWorkflow,
|
@@ -32,7 +32,7 @@ const someWork = (input: string) => {
|
32 | 32 | const workflowRunId = `wfr${nanoid()}`;
|
33 | 33 | const token = nanoid();
|
34 | 34 |
|
35 |
| -const qstashClient = new Client({ baseUrl: MOCK_QSTASH_SERVER_URL, token }); |
| 35 | +const qstashClient = new Client({ baseUrl: MOCK_QSTASH_SERVER_URL, token, enableTelemetry: false }); |
36 | 36 |
|
37 | 37 | describe("serve", () => {
|
38 | 38 | test("should send create workflow request in initial request", async () => {
|
@@ -409,7 +409,7 @@ describe("serve", () => {
|
409 | 409 | "upstash-workflow-url": WORKFLOW_ENDPOINT,
|
410 | 410 | "upstash-telemetry-framework": "unknown",
|
411 | 411 | "upstash-telemetry-runtime": "unknown",
|
412 |
| - "upstash-telemetry-sdk": "@upstash/[email protected].7", |
| 412 | + "upstash-telemetry-sdk": "@upstash/[email protected].13", |
413 | 413 | },
|
414 | 414 | body: '{"stepId":3,"stepName":"step 3","stepType":"Run","out":"\\"combined results: result 1,result 2\\"","concurrent":1}',
|
415 | 415 | },
|
@@ -458,7 +458,7 @@ describe("serve", () => {
|
458 | 458 | "upstash-workflow-url": WORKFLOW_ENDPOINT,
|
459 | 459 | "upstash-telemetry-framework": "unknown",
|
460 | 460 | "upstash-telemetry-runtime": "unknown",
|
461 |
| - "upstash-telemetry-sdk": "@upstash/[email protected].7", |
| 461 | + "upstash-telemetry-sdk": "@upstash/[email protected].13", |
462 | 462 | },
|
463 | 463 | body: '{"stepId":1,"stepName":"sleep-step","stepType":"SleepFor","sleepFor":1,"concurrent":1}',
|
464 | 464 | },
|
@@ -511,7 +511,7 @@ describe("serve", () => {
|
511 | 511 | "upstash-failure-callback-workflow-url": "https://requestcatcher.com/api",
|
512 | 512 | "upstash-telemetry-framework": "unknown",
|
513 | 513 | "upstash-telemetry-runtime": "unknown",
|
514 |
| - "upstash-telemetry-sdk": "@upstash/[email protected].7", |
| 514 | + "upstash-telemetry-sdk": "@upstash/[email protected].13", |
515 | 515 | },
|
516 | 516 | body: '{"stepId":1,"stepName":"sleep-step","stepType":"SleepFor","sleepFor":1,"concurrent":1}',
|
517 | 517 | },
|
@@ -566,7 +566,7 @@ describe("serve", () => {
|
566 | 566 | "upstash-failure-callback-workflow-url": "https://requestcatcher.com/api",
|
567 | 567 | "upstash-telemetry-framework": "unknown",
|
568 | 568 | "upstash-telemetry-runtime": "unknown",
|
569 |
| - "upstash-telemetry-sdk": "@upstash/[email protected].7", |
| 569 | + "upstash-telemetry-sdk": "@upstash/[email protected].13", |
570 | 570 | },
|
571 | 571 | body: '{"stepId":1,"stepName":"sleep-step","stepType":"SleepFor","sleepFor":1,"concurrent":1}',
|
572 | 572 | },
|
@@ -661,7 +661,7 @@ describe("serve", () => {
|
661 | 661 | "upstash-retries": "4",
|
662 | 662 | "upstash-telemetry-framework": "unknown",
|
663 | 663 | "upstash-telemetry-runtime": "unknown",
|
664 |
| - "upstash-telemetry-sdk": "@upstash/[email protected].7", |
| 664 | + "upstash-telemetry-sdk": "@upstash/[email protected].13", |
665 | 665 | "upstash-timeout": "10",
|
666 | 666 | "upstash-workflow-calltype": "toCallback",
|
667 | 667 | "upstash-workflow-init": "false",
|
@@ -875,7 +875,7 @@ describe("serve", () => {
|
875 | 875 | "Upstash-Workflow-Url": [WORKFLOW_ENDPOINT],
|
876 | 876 | "Upstash-Telemetry-Framework": ["unknown"],
|
877 | 877 | "Upstash-Telemetry-Runtime": ["unknown"],
|
878 |
| - "Upstash-Telemetry-Sdk": ["@upstash/[email protected].7"], |
| 878 | + "Upstash-Telemetry-Sdk": ["@upstash/[email protected].13"], |
879 | 879 | },
|
880 | 880 | timeoutUrl: WORKFLOW_ENDPOINT,
|
881 | 881 | url: WORKFLOW_ENDPOINT,
|
@@ -1017,6 +1017,10 @@ describe("serve", () => {
|
1017 | 1017 |
|
1018 | 1018 | describe("incorrect url will throw", () => {
|
1019 | 1019 | const qstashClient = new Client({ token: process.env.QSTASH_TOKEN! });
|
| 1020 | + qstashClient.batch = jest |
| 1021 | + .fn() |
| 1022 | + .mockReturnValue([{ deduplicatedId: false, messageId: "some-message-id" }]); |
| 1023 | + qstashClient.publish = jest.fn({ deduplicatedId: false, messageId: "some-message-id" }); |
1020 | 1024 | const client = new WorkflowClient({ token: process.env.QSTASH_TOKEN! });
|
1021 | 1025 |
|
1022 | 1026 | test("allow http://", async () => {
|
@@ -1111,6 +1115,7 @@ describe("serve", () => {
|
1111 | 1115 | headers: {
|
1112 | 1116 | [header]: headerValue,
|
1113 | 1117 | },
|
| 1118 | + enableTelemetry: false, |
1114 | 1119 | });
|
1115 | 1120 |
|
1116 | 1121 | const { handler: endpoint } = serve(
|
@@ -1158,7 +1163,7 @@ describe("serve", () => {
|
1158 | 1163 | "upstash-forward-test-header": headerValue,
|
1159 | 1164 | "upstash-telemetry-framework": "unknown",
|
1160 | 1165 | "upstash-telemetry-runtime": "unknown",
|
1161 |
| - "upstash-telemetry-sdk": "@upstash/[email protected].7", |
| 1166 | + "upstash-telemetry-sdk": "@upstash/[email protected].13", |
1162 | 1167 | },
|
1163 | 1168 | body: '{"stepId":1,"stepName":"sleep-step","stepType":"SleepFor","sleepFor":1,"concurrent":1}',
|
1164 | 1169 | },
|
|
0 commit comments