mirror of https://github.com/openclaw/openclaw.git
test: update command coverage
This commit is contained in:
parent
d67efbfbd3
commit
67dbb1ad42
|
|
@ -72,6 +72,7 @@ describe("dashboardCommand", () => {
|
|||
formatControlUiSshHintMock.mockClear();
|
||||
copyToClipboardMock.mockClear();
|
||||
delete process.env.OPENCLAW_GATEWAY_TOKEN;
|
||||
delete process.env.CUSTOM_GATEWAY_TOKEN;
|
||||
});
|
||||
|
||||
it("opens and copies the dashboard link by default", async () => {
|
||||
|
|
@ -174,12 +175,10 @@ describe("dashboardCommand", () => {
|
|||
|
||||
it("resolves env-template gateway.auth.token before building dashboard URL", async () => {
|
||||
mockSnapshot("${CUSTOM_GATEWAY_TOKEN}");
|
||||
process.env.CUSTOM_GATEWAY_TOKEN = "resolved-secret-token";
|
||||
copyToClipboardMock.mockResolvedValue(true);
|
||||
detectBrowserOpenSupportMock.mockResolvedValue({ ok: true });
|
||||
openUrlMock.mockResolvedValue(true);
|
||||
resolveSecretRefValuesMock.mockResolvedValue(
|
||||
new Map([["env:default:CUSTOM_GATEWAY_TOKEN", "resolved-secret-token"]]),
|
||||
);
|
||||
|
||||
await dashboardCommand(runtime);
|
||||
|
||||
|
|
|
|||
|
|
@ -154,6 +154,7 @@ async function withEnvVar<T>(key: string, value: string, run: () => Promise<T>):
|
|||
}
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
hasPotentialConfiguredChannels: vi.fn(() => true),
|
||||
loadConfig: vi.fn().mockReturnValue({ session: {} }),
|
||||
loadSessionStore: vi.fn().mockReturnValue({
|
||||
"+1000": createDefaultSessionStoreEntry(),
|
||||
|
|
@ -208,6 +209,14 @@ const mocks = vi.hoisted(() => ({
|
|||
buildPluginCompatibilityNotices: vi.fn((): PluginCompatibilityNotice[] => []),
|
||||
}));
|
||||
|
||||
vi.mock("../channels/config-presence.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("../channels/config-presence.js")>();
|
||||
return {
|
||||
...actual,
|
||||
hasPotentialConfiguredChannels: mocks.hasPotentialConfiguredChannels,
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("../memory/index.js", () => ({
|
||||
getMemorySearchManager: vi.fn(async ({ agentId }: { agentId: string }) => ({
|
||||
manager: {
|
||||
|
|
@ -417,6 +426,8 @@ const runtimeLogMock = runtime.log as Mock<(...args: unknown[]) => void>;
|
|||
|
||||
describe("statusCommand", () => {
|
||||
afterEach(() => {
|
||||
mocks.hasPotentialConfiguredChannels.mockReset();
|
||||
mocks.hasPotentialConfiguredChannels.mockReturnValue(true);
|
||||
mocks.loadConfig.mockReset();
|
||||
mocks.loadConfig.mockReturnValue({ session: {} });
|
||||
mocks.loadSessionStore.mockReset();
|
||||
|
|
@ -477,6 +488,7 @@ describe("statusCommand", () => {
|
|||
});
|
||||
|
||||
it("prints JSON when requested", async () => {
|
||||
mocks.hasPotentialConfiguredChannels.mockReturnValue(false);
|
||||
mocks.buildPluginCompatibilityNotices.mockReturnValue([
|
||||
{
|
||||
pluginId: "legacy-plugin",
|
||||
|
|
|
|||
Loading…
Reference in New Issue