fix(tests): resolve CI test isolation failures in OAuth refresh and ralph-loop
- provider.test.ts: reset discovery cache before/after refresh tests to prevent
cross-test contamination via module-level discoveryCache singleton
- completion-promise-session-negative.test.ts: update negative test case to use
non-oracle agent (hephaestus) since oracle tool_result VERIFIED detection was
intentionally added in 56f2a9df
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { describe, expect, it, beforeEach, afterEach, mock, afterAll } from "bun:test"
|
import { describe, expect, it, beforeEach, afterEach, mock } from "bun:test"
|
||||||
import { createHash, randomBytes } from "node:crypto"
|
import { createHash, randomBytes } from "node:crypto"
|
||||||
import type { OAuthTokenData } from "./storage"
|
import type { OAuthTokenData } from "./storage"
|
||||||
|
import { resetDiscoveryCache } from "./discovery"
|
||||||
|
|
||||||
type ProviderModule = typeof import("./provider")
|
type ProviderModule = typeof import("./provider")
|
||||||
|
|
||||||
@@ -233,6 +234,7 @@ describe("McpOAuthProvider", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
originalFetch = globalThis.fetch
|
originalFetch = globalThis.fetch
|
||||||
originalEnv = process.env.OPENCODE_CONFIG_DIR
|
originalEnv = process.env.OPENCODE_CONFIG_DIR
|
||||||
|
resetDiscoveryCache()
|
||||||
const { mkdirSync } = require("node:fs")
|
const { mkdirSync } = require("node:fs")
|
||||||
const { tmpdir } = require("node:os")
|
const { tmpdir } = require("node:os")
|
||||||
const { join } = require("node:path")
|
const { join } = require("node:path")
|
||||||
@@ -248,6 +250,7 @@ describe("McpOAuthProvider", () => {
|
|||||||
} else {
|
} else {
|
||||||
process.env.OPENCODE_CONFIG_DIR = originalEnv
|
process.env.OPENCODE_CONFIG_DIR = originalEnv
|
||||||
}
|
}
|
||||||
|
resetDiscoveryCache()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("exchanges refresh token and preserves it when the response omits a new one", async () => {
|
it("exchanges refresh token and preserves it when the response omits a new one", async () => {
|
||||||
|
|||||||
@@ -51,14 +51,14 @@ describe("detectCompletionInSessionMessages negative cases", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe("#given promise appears outside assistant text parts", () => {
|
describe("#given promise appears outside assistant text parts", () => {
|
||||||
test("#when VERIFIED appears only in tool_result part #then should NOT detect completion", async () => {
|
test("#when VERIFIED appears only in non-oracle tool_result part #then should NOT detect completion", async () => {
|
||||||
// #given
|
// #given -- oracle tool_result VERIFIED is detectable (56f2a9df); non-oracle is not
|
||||||
const messages = [
|
const messages = [
|
||||||
{
|
{
|
||||||
info: { role: "assistant" },
|
info: { role: "assistant" },
|
||||||
parts: [
|
parts: [
|
||||||
{ type: "tool_result", text: 'Task completed.\n\nAgent: oracle\n\n<promise>VERIFIED</promise>' },
|
{ type: "tool_result", text: 'Task completed.\n\nAgent: hephaestus\n\n<promise>VERIFIED</promise>' },
|
||||||
{ type: "text", text: "Oracle verified the task." },
|
{ type: "text", text: "Hephaestus completed the task." },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user