mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-23 16:01:17 +00:00
ci: fix workflow sanity gate
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { ChannelMessageActionContext } from "openclaw/plugin-sdk/channel-contract";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
const handleDiscordMessageActionMock = vi.hoisted(() => vi.fn(async () => ({ ok: true })));
|
||||
|
||||
@@ -49,14 +50,7 @@ describe("discordMessageActions", () => {
|
||||
expect(discovery?.capabilities).toEqual(["interactive", "components"]);
|
||||
expect(discovery?.schema).not.toBeNull();
|
||||
expect(discovery?.actions).toEqual(
|
||||
expect.arrayContaining([
|
||||
"send",
|
||||
"poll",
|
||||
"react",
|
||||
"reactions",
|
||||
"emoji-list",
|
||||
"permissions",
|
||||
]),
|
||||
expect.arrayContaining(["send", "poll", "react", "reactions", "emoji-list", "permissions"]),
|
||||
);
|
||||
expect(discovery?.actions).not.toContain("channel-create");
|
||||
expect(discovery?.actions).not.toContain("role-add");
|
||||
@@ -90,10 +84,13 @@ describe("discordMessageActions", () => {
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
const toolContext = { sessionId: "s1" };
|
||||
const toolContext: ChannelMessageActionContext["toolContext"] = {
|
||||
currentChannelProvider: "discord",
|
||||
};
|
||||
const mediaLocalRoots = ["/tmp/media"];
|
||||
|
||||
await discordMessageActions.handleAction?.({
|
||||
channel: "discord",
|
||||
action: "send",
|
||||
params: { to: "channel:123", text: "hello" },
|
||||
cfg,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveDiscordDraftStreamingChunking } from "./draft-chunking.js";
|
||||
|
||||
describe("resolveDiscordDraftStreamingChunking", () => {
|
||||
|
||||
@@ -75,9 +75,7 @@ describe("createDiscordDraftStream", () => {
|
||||
await stream.flush();
|
||||
|
||||
expect(rest.post).not.toHaveBeenCalled();
|
||||
expect(warn).toHaveBeenCalledWith(
|
||||
expect.stringContaining("discord stream preview stopped"),
|
||||
);
|
||||
expect(warn).toHaveBeenCalledWith(expect.stringContaining("discord stream preview stopped"));
|
||||
expect(stream.messageId()).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { ChannelAccountSnapshot } from "openclaw/plugin-sdk/channel-contract";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { collectDiscordStatusIssues } from "./status-issues.js";
|
||||
|
||||
describe("collectDiscordStatusIssues", () => {
|
||||
|
||||
@@ -6,7 +6,7 @@ describe("resolveTelegramAllowedUpdates", () => {
|
||||
it("includes the default update types plus reaction and channel post support", () => {
|
||||
const updates = resolveTelegramAllowedUpdates();
|
||||
|
||||
expect(updates).toEqual(expect.arrayContaining(API_CONSTANTS.DEFAULT_UPDATE_TYPES));
|
||||
expect(updates).toEqual(expect.arrayContaining([...API_CONSTANTS.DEFAULT_UPDATE_TYPES]));
|
||||
expect(updates).toContain("message_reaction");
|
||||
expect(updates).toContain("channel_post");
|
||||
expect(new Set(updates).size).toBe(updates.length);
|
||||
|
||||
@@ -90,11 +90,16 @@ describe("enforceTelegramDmAccess", () => {
|
||||
const sendMessage = vi.fn(async () => undefined);
|
||||
const logger = { info: vi.fn() };
|
||||
createChannelPairingChallengeIssuerMock.mockReturnValueOnce(
|
||||
({ sendPairingReply, onCreated }) =>
|
||||
(async () => {
|
||||
onCreated();
|
||||
await sendPairingReply("Pairing code: 123456");
|
||||
})(),
|
||||
async ({
|
||||
sendPairingReply,
|
||||
onCreated,
|
||||
}: {
|
||||
sendPairingReply: (text: string) => Promise<void>;
|
||||
onCreated: () => void;
|
||||
}) => {
|
||||
onCreated();
|
||||
await sendPairingReply("Pairing code: 123456");
|
||||
},
|
||||
);
|
||||
|
||||
const allowed = await enforceTelegramDmAccess({
|
||||
|
||||
@@ -4,9 +4,7 @@ import { looksLikeTelegramTargetId, normalizeTelegramMessagingTarget } from "./n
|
||||
describe("telegram target normalization", () => {
|
||||
it("normalizes telegram prefixes, group targets, and topic suffixes", () => {
|
||||
expect(normalizeTelegramMessagingTarget("telegram:123456")).toBe("telegram:123456");
|
||||
expect(normalizeTelegramMessagingTarget("tg:group:-100123")).toBe(
|
||||
"telegram:group:-100123",
|
||||
);
|
||||
expect(normalizeTelegramMessagingTarget("tg:group:-100123")).toBe("telegram:group:-100123");
|
||||
expect(normalizeTelegramMessagingTarget("telegram:-100123:topic:99")).toBe(
|
||||
"telegram:-100123:topic:99",
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { ChannelAccountSnapshot } from "openclaw/plugin-sdk/channel-contract";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { collectTelegramStatusIssues } from "./status-issues.js";
|
||||
|
||||
describe("collectTelegramStatusIssues", () => {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { runAsScript } from "./lib/ts-guard-utils.mjs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
function isBinaryBuffer(buffer) {
|
||||
return buffer.includes(0);
|
||||
@@ -77,4 +77,9 @@ export async function main() {
|
||||
process.exitCode = 1;
|
||||
}
|
||||
|
||||
runAsScript(import.meta.url, main);
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user