test: harden release gate flakes

This commit is contained in:
Peter Steinberger
2026-04-08 11:02:56 +01:00
parent 7311ca743a
commit 592c1e50d9
2 changed files with 27 additions and 15 deletions

View File

@@ -67,7 +67,7 @@ function createMockQaRuntime(): PluginRuntime {
}
describe("qa-channel plugin", () => {
it("roundtrips inbound DM traffic through the qa bus", async () => {
it("roundtrips inbound DM traffic through the qa bus", { timeout: 20_000 }, async () => {
const state = createQaBusState();
const bus = await startQaBusServer({ state });
setQaChannelRuntime(createMockQaRuntime());
@@ -106,7 +106,7 @@ describe("qa-channel plugin", () => {
kind: "message-text",
textIncludes: "qa-echo: hello",
direction: "outbound",
timeoutMs: 5_000,
timeoutMs: 15_000,
});
expect("text" in outbound && outbound.text).toContain("qa-echo: hello");
} finally {

View File

@@ -63,21 +63,33 @@ describe("resolveNonInteractiveApiKey", () => {
it("rejects flag input in secret-ref mode without broad env discovery", async () => {
const runtime = createRuntime();
resolveEnvApiKey.mockReturnValue(null);
const previousXaiApiKey = process.env.XAI_API_KEY;
delete process.env.XAI_API_KEY;
const result = await resolveNonInteractiveApiKey({
provider: "xai",
cfg: {},
flagValue: "xai-flag-key",
flagName: "--xai-api-key",
envVar: "XAI_API_KEY",
runtime: runtime as never,
secretInputMode: "ref",
});
try {
const result = await resolveNonInteractiveApiKey({
provider: "xai",
cfg: {},
flagValue: "xai-flag-key",
flagName: "--xai-api-key",
envVar: "XAI_API_KEY",
runtime: runtime as never,
secretInputMode: "ref",
});
expect(result).toBeNull();
expect(resolveEnvApiKey).not.toHaveBeenCalled();
expect(runtime.exit).toHaveBeenCalledWith(1);
expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("--secret-input-mode ref"));
expect(result).toBeNull();
expect(resolveEnvApiKey).not.toHaveBeenCalled();
expect(runtime.exit).toHaveBeenCalledWith(1);
expect(runtime.error).toHaveBeenCalledWith(
expect.stringContaining("--secret-input-mode ref"),
);
} finally {
if (previousXaiApiKey === undefined) {
delete process.env.XAI_API_KEY;
} else {
process.env.XAI_API_KEY = previousXaiApiKey;
}
}
});
it("falls back to a matching API-key profile after flag and env are absent", async () => {