diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1478f386bf2..ce0ce292138 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,13 +95,6 @@ jobs: node scripts/ci-changed-scope.mjs --base "$BASE" --head HEAD - - name: Setup Node environment - if: steps.docs_scope.outputs.docs_only != 'true' - uses: ./.github/actions/setup-node-env - with: - install-bun: "false" - install-deps: "false" - - name: Detect changed extensions id: changed_extensions if: steps.docs_scope.outputs.docs_only != 'true' && steps.changed_scope.outputs.run_node == 'true' diff --git a/.github/workflows/install-smoke.yml b/.github/workflows/install-smoke.yml index 5c9d0e92198..59c9f8bff9b 100644 --- a/.github/workflows/install-smoke.yml +++ b/.github/workflows/install-smoke.yml @@ -58,13 +58,6 @@ jobs: node scripts/ci-changed-scope.mjs --base "$BASE" --head HEAD - - name: Setup Node environment - if: steps.docs_scope.outputs.docs_only != 'true' - uses: ./.github/actions/setup-node-env - with: - install-bun: "false" - install-deps: "false" - - name: Build install-smoke CI manifest id: manifest env: diff --git a/extensions/msteams/src/streaming-message.test.ts b/extensions/msteams/src/streaming-message.test.ts index 3d255888f41..42704a28d34 100644 --- a/extensions/msteams/src/streaming-message.test.ts +++ b/extensions/msteams/src/streaming-message.test.ts @@ -1,25 +1,30 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import { TeamsHttpStream } from "./streaming-message.js"; +async function flushStreamTimer(): Promise { + await vi.advanceTimersByTimeAsync(1); +} + describe("TeamsHttpStream", () => { afterEach(() => { vi.useRealTimers(); }); it("sends first chunk as typing activity with streaminfo", async () => { + vi.useFakeTimers(); + const sent: unknown[] = []; const stream = new TeamsHttpStream({ sendActivity: vi.fn(async (activity) => { sent.push(activity); return { id: "stream-1" }; }), + throttleMs: 1, }); // Enough text to pass MIN_INITIAL_CHARS threshold stream.update("Hello, this is a test response that is long enough."); - - // Wait for throttle to flush - await new Promise((r) => setTimeout(r, 700)); + await flushStreamTimer(); expect(sent.length).toBeGreaterThanOrEqual(1); const firstActivity = sent[0] as Record; @@ -36,16 +41,19 @@ describe("TeamsHttpStream", () => { }); it("sends final message activity on finalize", async () => { + vi.useFakeTimers(); + const sent: unknown[] = []; const stream = new TeamsHttpStream({ sendActivity: vi.fn(async (activity) => { sent.push(activity); return { id: "stream-1" }; }), + throttleMs: 1, }); stream.update("Hello, this is a complete response for finalization testing."); - await new Promise((r) => setTimeout(r, 700)); + await flushStreamTimer(); await stream.finalize(); @@ -76,11 +84,13 @@ describe("TeamsHttpStream", () => { }); it("does not send below MIN_INITIAL_CHARS", async () => { + vi.useFakeTimers(); + const sendActivity = vi.fn(async () => ({ id: "x" })); - const stream = new TeamsHttpStream({ sendActivity }); + const stream = new TeamsHttpStream({ sendActivity, throttleMs: 1 }); stream.update("Hi"); - await new Promise((r) => setTimeout(r, 700)); + await flushStreamTimer(); expect(sendActivity).not.toHaveBeenCalled(); }); @@ -114,6 +124,8 @@ describe("TeamsHttpStream", () => { }); it("sets feedbackLoopEnabled on final message", async () => { + vi.useFakeTimers(); + const sent: unknown[] = []; const stream = new TeamsHttpStream({ sendActivity: vi.fn(async (activity) => { @@ -121,10 +133,11 @@ describe("TeamsHttpStream", () => { return { id: "stream-1" }; }), feedbackLoopEnabled: true, + throttleMs: 1, }); stream.update("A response long enough to pass the minimum character threshold for streaming."); - await new Promise((r) => setTimeout(r, 700)); + await flushStreamTimer(); await stream.finalize(); const finalActivity = sent.find( @@ -163,17 +176,20 @@ describe("TeamsHttpStream", () => { }); it("informative update establishes streamId for subsequent chunks", async () => { + vi.useFakeTimers(); + const sent: unknown[] = []; const stream = new TeamsHttpStream({ sendActivity: vi.fn(async (activity) => { sent.push(activity); return { id: "stream-1" }; }), + throttleMs: 1, }); await stream.sendInformativeUpdate("Working..."); stream.update("Hello, this is a long enough response for streaming to begin."); - await new Promise((r) => setTimeout(r, 1600)); + await flushStreamTimer(); // Second activity (streaming chunk) should have the streamId from the informative update expect(sent.length).toBeGreaterThanOrEqual(2);