test: add redacted Qoder protocol recorder and replays

Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-08-31 16:14:37 +00:00
co-authored by Simon Shi
parent 1eee02455c
commit 6d5cdfd171
14 changed files with 860 additions and 11 deletions
+30
View File
@@ -5,6 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { updateQoderModelsCache } from "../models.js";
import { autoLoginQoderFromEnvironment, getCachedCredentials, getQoderPatForMode } from "../oauth.js";
import { credentialsFromPat } from "../pat.js";
import { loadLiveFixture } from "./live-fixture.js";
const AUTH_FILE = join(homedir(), ".pi", "agent", "auth.json");
@@ -87,4 +88,33 @@ describe("oauth autoLoginQoderFromEnvironment", () => {
"global",
);
});
it("passes a recorded-format identity into the model catalog refresh", async () => {
const identity = loadLiveFixture("global").interactions.userinfo.response.body as {
id: string;
email: string;
name: string;
};
vi.mocked(credentialsFromPat).mockResolvedValueOnce({
access: "<redacted:job-token>",
refresh: "<redacted:refresh-token>",
expires: Date.now() + 3600000,
userID: identity.id,
email: identity.email,
name: identity.name,
machineID: "<redacted:machine-id>",
type: "oauth",
} as never);
process.env.QODER_PAT = "test-only-pat";
await autoLoginQoderFromEnvironment("qoder-fixture-provider", "global");
expect(updateQoderModelsCache).toHaveBeenCalledWith(
"<redacted:job-token>",
identity.id,
identity.name,
identity.email,
"global",
);
});
});