test: seed auto-reply auth profiles through store

This commit is contained in:
Vincent Koc
2026-06-04 03:43:57 +02:00
parent 45f4875613
commit dcfd033746

View File

@@ -14,6 +14,7 @@ import {
expectBareNewOrResetAcknowledged,
withTempHome,
} from "../../test/helpers/auto-reply/trigger-handling-test-harness.js";
import { saveAuthProfileStore } from "../agents/auth-profiles/store.js";
import { loadSessionStore, resolveSessionKey } from "../config/sessions.js";
import { registerGroupIntroPromptCases } from "./reply.triggers.group-intro-prompts.cases.js";
import { registerTriggerHandlingUsageSummaryCases } from "./reply.triggers.trigger-handling.filters-usage-summary-current-model-provider.cases.js";
@@ -770,41 +771,30 @@ describe("trigger handling", () => {
runEmbeddedAgentMock.mockReset();
const storePath = requireSessionStorePath(cfg);
const authDir = join(home, ".openclaw", "agents", "main", "agent");
await fs.mkdir(authDir, { recursive: true });
await fs.writeFile(
join(authDir, "auth-profiles.json"),
JSON.stringify(
{
version: 1,
profiles: {
[TEST_PRIMARY_PROFILE_ID]: {
type: "oauth",
provider: "openai",
access: "oauth-access-token-josh",
},
[TEST_SECONDARY_PROFILE_ID]: {
type: "oauth",
provider: "openai",
access: "oauth-access-token",
},
saveAuthProfileStore(
{
version: 1,
profiles: {
[TEST_PRIMARY_PROFILE_ID]: {
type: "oauth",
provider: "openai",
access: "oauth-access-token-josh",
refresh: "oauth-refresh-token-josh",
expires: Date.now() + 60_000,
},
[TEST_SECONDARY_PROFILE_ID]: {
type: "oauth",
provider: "openai",
access: "oauth-access-token",
refresh: "oauth-refresh-token",
expires: Date.now() + 60_000,
},
},
null,
2,
),
);
await fs.writeFile(
join(authDir, "auth-state.json"),
JSON.stringify(
{
version: 1,
order: {
openai: [TEST_PRIMARY_PROFILE_ID],
},
order: {
openai: [TEST_PRIMARY_PROFILE_ID],
},
null,
2,
),
},
authDir,
);
const slashSessionKey = "telegram:slash:111";