mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
fix(ci): stabilize tests and detect-secrets after dep updates
This commit is contained in:
@@ -1,19 +1,35 @@
|
||||
import type { ClawdbotConfig } from "openclaw/plugin-sdk/feishu";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { monitorFeishuProvider, stopFeishuMonitor } from "./monitor.js";
|
||||
import {
|
||||
createFeishuClientMockModule,
|
||||
createFeishuRuntimeMockModule,
|
||||
} from "./monitor.test-mocks.js";
|
||||
|
||||
const probeFeishuMock = vi.hoisted(() => vi.fn());
|
||||
const feishuClientMockModule = vi.hoisted(() => ({
|
||||
createFeishuWSClient: vi.fn(() => ({ start: vi.fn() })),
|
||||
createEventDispatcher: vi.fn(() => ({ register: vi.fn() })),
|
||||
}));
|
||||
const feishuRuntimeMockModule = vi.hoisted(() => ({
|
||||
getFeishuRuntime: () => ({
|
||||
channel: {
|
||||
debounce: {
|
||||
resolveInboundDebounceMs: () => 0,
|
||||
createInboundDebouncer: () => ({
|
||||
enqueue: async () => {},
|
||||
flushKey: async () => {},
|
||||
}),
|
||||
},
|
||||
text: {
|
||||
hasControlCommand: () => false,
|
||||
},
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("./probe.js", () => ({
|
||||
probeFeishu: probeFeishuMock,
|
||||
}));
|
||||
|
||||
vi.mock("./client.js", () => createFeishuClientMockModule());
|
||||
vi.mock("./runtime.js", () => createFeishuRuntimeMockModule());
|
||||
vi.mock("./client.js", () => feishuClientMockModule);
|
||||
vi.mock("./runtime.js", () => feishuRuntimeMockModule);
|
||||
|
||||
function buildMultiAccountWebsocketConfig(accountIds: string[]): ClawdbotConfig {
|
||||
return {
|
||||
|
||||
@@ -1,13 +1,31 @@
|
||||
import { vi } from "vitest";
|
||||
|
||||
export function createFeishuClientMockModule() {
|
||||
export function createFeishuClientMockModule(): {
|
||||
createFeishuWSClient: () => { start: () => void };
|
||||
createEventDispatcher: () => { register: () => void };
|
||||
} {
|
||||
return {
|
||||
createFeishuWSClient: vi.fn(() => ({ start: vi.fn() })),
|
||||
createEventDispatcher: vi.fn(() => ({ register: vi.fn() })),
|
||||
};
|
||||
}
|
||||
|
||||
export function createFeishuRuntimeMockModule() {
|
||||
export function createFeishuRuntimeMockModule(): {
|
||||
getFeishuRuntime: () => {
|
||||
channel: {
|
||||
debounce: {
|
||||
resolveInboundDebounceMs: () => number;
|
||||
createInboundDebouncer: () => {
|
||||
enqueue: () => Promise<void>;
|
||||
flushKey: () => Promise<void>;
|
||||
};
|
||||
};
|
||||
text: {
|
||||
hasControlCommand: () => boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
} {
|
||||
return {
|
||||
getFeishuRuntime: () => ({
|
||||
channel: {
|
||||
|
||||
@@ -269,7 +269,7 @@ describe("handleZaloWebhookRequest", () => {
|
||||
const saw429 = await postUntilRateLimited({
|
||||
baseUrl,
|
||||
path: "/hook-rate",
|
||||
secret: "secret",
|
||||
secret: "secret", // pragma: allowlist secret
|
||||
});
|
||||
|
||||
expect(saw429).toBe(true);
|
||||
@@ -287,7 +287,7 @@ describe("handleZaloWebhookRequest", () => {
|
||||
const response = await fetch(`${baseUrl}/hook-query-status?nonce=${i}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"x-bot-api-secret-token": "invalid-token",
|
||||
"x-bot-api-secret-token": "invalid-token", // pragma: allowlist secret
|
||||
"content-type": "application/json",
|
||||
},
|
||||
body: "{}",
|
||||
@@ -310,7 +310,7 @@ describe("handleZaloWebhookRequest", () => {
|
||||
const saw429 = await postUntilRateLimited({
|
||||
baseUrl,
|
||||
path: "/hook-query-rate",
|
||||
secret: "secret",
|
||||
secret: "secret", // pragma: allowlist secret
|
||||
withNonceQuery: true,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { OpenClawConfig, PluginRuntime, RuntimeEnv } from "openclaw/plugin-sdk/zalouser";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import "./monitor.send-mocks.js";
|
||||
import { __testing } from "./monitor.js";
|
||||
import { sendMessageZalouserMock } from "./monitor.send-mocks.js";
|
||||
import { setZalouserRuntime } from "./runtime.js";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { OpenClawConfig, PluginRuntime, RuntimeEnv } from "openclaw/plugin-sdk/zalouser";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import "./monitor.send-mocks.js";
|
||||
import { __testing } from "./monitor.js";
|
||||
import {
|
||||
sendDeliveredZalouserMock,
|
||||
|
||||
Reference in New Issue
Block a user