mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:20:43 +00:00
fix(test): preserve new module exports in mocks
This commit is contained in:
@@ -71,12 +71,17 @@ vi.mock("./external-auth.js", () => ({
|
||||
shouldPersistExternalAuthProfile: () => true,
|
||||
}));
|
||||
|
||||
vi.mock("./external-cli-sync.js", () => ({
|
||||
resolveExternalCliAuthProfiles: () => [],
|
||||
syncExternalCliCredentials: () => false,
|
||||
readManagedExternalCliCredential: () => null,
|
||||
areOAuthCredentialsEquivalent: (a: unknown, b: unknown) => a === b,
|
||||
}));
|
||||
vi.mock("./external-cli-sync.js", async () => {
|
||||
const actual =
|
||||
await vi.importActual<typeof import("./external-cli-sync.js")>("./external-cli-sync.js");
|
||||
return {
|
||||
...actual,
|
||||
syncExternalCliCredentials: () => false,
|
||||
readManagedExternalCliCredential: () => null,
|
||||
resolveExternalCliAuthProfiles: () => [],
|
||||
areOAuthCredentialsEquivalent: (a: unknown, b: unknown) => a === b,
|
||||
};
|
||||
});
|
||||
|
||||
function createExpiredOauthStore(params: {
|
||||
profileId: string;
|
||||
|
||||
@@ -78,12 +78,17 @@ vi.mock("./doctor.js", () => ({
|
||||
formatAuthDoctorHint: async () => undefined,
|
||||
}));
|
||||
|
||||
vi.mock("./external-cli-sync.js", () => ({
|
||||
resolveExternalCliAuthProfiles: () => [],
|
||||
syncExternalCliCredentials: () => false,
|
||||
readManagedExternalCliCredential: () => null,
|
||||
areOAuthCredentialsEquivalent: (a: unknown, b: unknown) => a === b,
|
||||
}));
|
||||
vi.mock("./external-cli-sync.js", async () => {
|
||||
const actual =
|
||||
await vi.importActual<typeof import("./external-cli-sync.js")>("./external-cli-sync.js");
|
||||
return {
|
||||
...actual,
|
||||
syncExternalCliCredentials: () => false,
|
||||
readManagedExternalCliCredential: () => null,
|
||||
resolveExternalCliAuthProfiles: () => [],
|
||||
areOAuthCredentialsEquivalent: (a: unknown, b: unknown) => a === b,
|
||||
};
|
||||
});
|
||||
|
||||
function oauthCred(params: {
|
||||
provider: string;
|
||||
|
||||
@@ -64,12 +64,17 @@ vi.mock("./doctor.js", () => ({
|
||||
// External-CLI sync does real I/O against the user's Codex/MiniMax CLI
|
||||
// credential files; it is slow and can pollute test state. Stub it to a no-op
|
||||
// so the suite only exercises in-repo auth-profile logic.
|
||||
vi.mock("./external-cli-sync.js", () => ({
|
||||
resolveExternalCliAuthProfiles: () => [],
|
||||
syncExternalCliCredentials: () => false,
|
||||
readManagedExternalCliCredential: () => null,
|
||||
areOAuthCredentialsEquivalent: (a: unknown, b: unknown) => a === b,
|
||||
}));
|
||||
vi.mock("./external-cli-sync.js", async () => {
|
||||
const actual =
|
||||
await vi.importActual<typeof import("./external-cli-sync.js")>("./external-cli-sync.js");
|
||||
return {
|
||||
...actual,
|
||||
syncExternalCliCredentials: () => false,
|
||||
readManagedExternalCliCredential: () => null,
|
||||
resolveExternalCliAuthProfiles: () => [],
|
||||
areOAuthCredentialsEquivalent: (a: unknown, b: unknown) => a === b,
|
||||
};
|
||||
});
|
||||
|
||||
function createExpiredOauthStore(params: {
|
||||
profileId: string;
|
||||
|
||||
@@ -75,12 +75,17 @@ vi.mock("./doctor.js", () => ({
|
||||
formatAuthDoctorHint: async () => undefined,
|
||||
}));
|
||||
|
||||
vi.mock("./external-cli-sync.js", () => ({
|
||||
resolveExternalCliAuthProfiles: () => [],
|
||||
syncExternalCliCredentials: () => false,
|
||||
readManagedExternalCliCredential: () => null,
|
||||
areOAuthCredentialsEquivalent: (a: unknown, b: unknown) => a === b,
|
||||
}));
|
||||
vi.mock("./external-cli-sync.js", async () => {
|
||||
const actual =
|
||||
await vi.importActual<typeof import("./external-cli-sync.js")>("./external-cli-sync.js");
|
||||
return {
|
||||
...actual,
|
||||
syncExternalCliCredentials: () => false,
|
||||
readManagedExternalCliCredential: () => null,
|
||||
resolveExternalCliAuthProfiles: () => [],
|
||||
areOAuthCredentialsEquivalent: (a: unknown, b: unknown) => a === b,
|
||||
};
|
||||
});
|
||||
|
||||
function createExpiredOauthStore(params: {
|
||||
profileId: string;
|
||||
|
||||
@@ -9,10 +9,16 @@ vi.mock("../plugins/provider-runtime.js", () => ({
|
||||
resolveExternalAuthProfilesWithPlugins: () => [],
|
||||
}));
|
||||
|
||||
vi.mock("./auth-profiles/external-cli-sync.js", () => ({
|
||||
resolveExternalCliAuthProfiles: () => [],
|
||||
readManagedExternalCliCredential: () => null,
|
||||
}));
|
||||
vi.mock("./auth-profiles/external-cli-sync.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("./auth-profiles/external-cli-sync.js")>(
|
||||
"./auth-profiles/external-cli-sync.js",
|
||||
);
|
||||
return {
|
||||
...actual,
|
||||
readManagedExternalCliCredential: () => null,
|
||||
resolveExternalCliAuthProfiles: () => [],
|
||||
};
|
||||
});
|
||||
|
||||
type AuthProfileStore = Parameters<typeof saveAuthProfileStore>[0];
|
||||
|
||||
|
||||
@@ -38,9 +38,15 @@ vi.mock("./channel-setup/discovery.js", () => ({
|
||||
isCatalogChannelInstalled: discoveryMocks.isCatalogChannelInstalled,
|
||||
}));
|
||||
|
||||
vi.mock("../channels/plugins/bundled.js", () => ({
|
||||
getBundledChannelPlugin: vi.fn(() => undefined),
|
||||
}));
|
||||
vi.mock("../channels/plugins/bundled.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("../channels/plugins/bundled.js")>(
|
||||
"../channels/plugins/bundled.js",
|
||||
);
|
||||
return {
|
||||
...actual,
|
||||
getBundledChannelPlugin: vi.fn(() => undefined),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("./channel-setup/plugin-install.js", () => pluginInstallMocks);
|
||||
|
||||
|
||||
@@ -14,7 +14,10 @@ import {
|
||||
|
||||
let tempRoots: string[] = [];
|
||||
|
||||
vi.mock("../channels/plugins/bundled.js", () => {
|
||||
vi.mock("../channels/plugins/bundled.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("../channels/plugins/bundled.js")>(
|
||||
"../channels/plugins/bundled.js",
|
||||
);
|
||||
function fileExists(filePath: string): boolean {
|
||||
try {
|
||||
return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
|
||||
@@ -88,6 +91,7 @@ vi.mock("../channels/plugins/bundled.js", () => {
|
||||
}
|
||||
|
||||
return {
|
||||
...actual,
|
||||
listBundledChannelLegacySessionSurfaces: vi.fn(() => [
|
||||
{
|
||||
isLegacyGroupSessionKey: (key: string) => /^group:.+@g\.us$/i.test(key.trim()),
|
||||
|
||||
Reference in New Issue
Block a user