perf(ci): trim preflight setup and stream test waits

This commit is contained in:
Peter Steinberger
2026-04-22 06:10:40 +01:00
parent 812d012b98
commit de616055f7
3 changed files with 24 additions and 22 deletions

View File

@@ -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'

View File

@@ -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:

View File

@@ -1,25 +1,30 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { TeamsHttpStream } from "./streaming-message.js";
async function flushStreamTimer(): Promise<void> {
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<string, unknown>;
@@ -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);