mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 08:00:45 +00:00
test: tighten command extension helper assertions
This commit is contained in:
@@ -142,7 +142,6 @@ describe("fetchDiscord", () => {
|
||||
});
|
||||
|
||||
expect(result).toEqual({ id: "42" });
|
||||
expect(request).toBeDefined();
|
||||
if (!request) {
|
||||
throw new Error("expected Discord request init");
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ describe("resolve-allowlist-common", () => {
|
||||
|
||||
it("resolves and filters guilds by id or name", () => {
|
||||
const mainGuild = findDiscordGuildByName(guilds, "Main Guild");
|
||||
expect(mainGuild).toBeDefined();
|
||||
if (!mainGuild) {
|
||||
throw new Error("expected Main Guild lookup result");
|
||||
}
|
||||
|
||||
@@ -83,7 +83,6 @@ describe("firecrawl tools", () => {
|
||||
expect(provider.id).toBe("firecrawl");
|
||||
expect(provider.credentialPath).toBe("plugins.entries.firecrawl.config.webSearch.apiKey");
|
||||
const pluginEntry = applied.plugins?.entries?.firecrawl;
|
||||
expect(pluginEntry).toBeDefined();
|
||||
if (!pluginEntry) {
|
||||
throw new Error("expected Firecrawl plugin entry");
|
||||
}
|
||||
@@ -354,7 +353,6 @@ describe("firecrawl tools", () => {
|
||||
expect(provider.id).toBe("firecrawl");
|
||||
expect(provider.credentialPath).toBe("plugins.entries.firecrawl.config.webFetch.apiKey");
|
||||
const pluginEntry = applied.plugins?.entries?.firecrawl;
|
||||
expect(pluginEntry).toBeDefined();
|
||||
if (!pluginEntry) {
|
||||
throw new Error("expected Firecrawl fetch plugin entry");
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ function jsonResponse(payload: unknown, status = 200) {
|
||||
|
||||
function requireFirstFetchInput(fetchImpl: ReturnType<typeof vi.fn>): RequestInfo | URL {
|
||||
const input = fetchImpl.mock.calls[0]?.[0] as RequestInfo | URL | undefined;
|
||||
expect(input).toBeDefined();
|
||||
if (!input) {
|
||||
throw new Error("expected fetch input");
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ async function expectPostJsonRequest(run: (token: string, fetcher: ZaloFetch) =>
|
||||
await run("test-token", fetcher);
|
||||
expect(fetcher).toHaveBeenCalledTimes(1);
|
||||
const [, init] = fetcher.mock.calls[0] ?? [];
|
||||
expect(init).toBeDefined();
|
||||
if (!init) {
|
||||
throw new Error("expected Zalo request init");
|
||||
}
|
||||
@@ -71,11 +70,9 @@ describe("Zalo API request methods", () => {
|
||||
|
||||
await rejected;
|
||||
const [, init] = fetcher.mock.calls[0] ?? [];
|
||||
expect(init).toBeDefined();
|
||||
if (!init) {
|
||||
throw new Error("expected Zalo chat action request init");
|
||||
}
|
||||
expect(init.signal).toBeDefined();
|
||||
if (!init.signal) {
|
||||
throw new Error("expected Zalo chat action abort signal");
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@ describe("zalo setup wizard", () => {
|
||||
|
||||
expect(result.accountId).toBe("default");
|
||||
const zaloConfig = result.cfg.channels?.zalo;
|
||||
expect(zaloConfig).toBeDefined();
|
||||
if (!zaloConfig) {
|
||||
throw new Error("expected Zalo config");
|
||||
}
|
||||
@@ -123,7 +122,6 @@ describe("zalo setup wizard", () => {
|
||||
|
||||
const next = zaloDmPolicy.setPolicy(cfg, "open");
|
||||
const zaloConfig = next.channels?.zalo;
|
||||
expect(zaloConfig).toBeDefined();
|
||||
if (!zaloConfig) {
|
||||
throw new Error("expected Zalo config");
|
||||
}
|
||||
@@ -131,7 +129,6 @@ describe("zalo setup wizard", () => {
|
||||
const workAccount = next.channels?.zalo?.accounts?.work as
|
||||
| { dmPolicy?: string; allowFrom?: Array<string | number> }
|
||||
| undefined;
|
||||
expect(workAccount).toBeDefined();
|
||||
if (!workAccount) {
|
||||
throw new Error("expected Zalo work account");
|
||||
}
|
||||
@@ -157,7 +154,6 @@ describe("zalo setup wizard", () => {
|
||||
);
|
||||
|
||||
const zaloConfig = next.channels?.zalo;
|
||||
expect(zaloConfig).toBeDefined();
|
||||
if (!zaloConfig) {
|
||||
throw new Error("expected Zalo config");
|
||||
}
|
||||
@@ -165,7 +161,6 @@ describe("zalo setup wizard", () => {
|
||||
const workAccount = next.channels?.zalo?.accounts?.work as
|
||||
| { dmPolicy?: string; allowFrom?: Array<string | number> }
|
||||
| undefined;
|
||||
expect(workAccount).toBeDefined();
|
||||
if (!workAccount) {
|
||||
throw new Error("expected Zalo work account");
|
||||
}
|
||||
|
||||
@@ -33,12 +33,10 @@ describe("zalouser setup wizard", () => {
|
||||
) {
|
||||
expect(result.accountId).toBe("default");
|
||||
const channelConfig = result.cfg.channels?.zalouser;
|
||||
expect(channelConfig).toBeDefined();
|
||||
if (!channelConfig) {
|
||||
throw new Error("expected Zalo Personal channel config");
|
||||
}
|
||||
const pluginEntry = result.cfg.plugins?.entries?.zalouser;
|
||||
expect(pluginEntry).toBeDefined();
|
||||
if (!pluginEntry) {
|
||||
throw new Error("expected Zalo Personal plugin entry");
|
||||
}
|
||||
|
||||
@@ -44,11 +44,11 @@ async function writeIdentityFile(workspace: string, lines: string[]) {
|
||||
|
||||
function getWrittenMainIdentity() {
|
||||
const [written] = configMocks.writeConfigFile.mock.calls[0] ?? [];
|
||||
expect(written).toBeDefined();
|
||||
if (!written) {
|
||||
throw new Error("expected written agent config");
|
||||
}
|
||||
return written.agents?.list?.find((entry) => entry.id === "main")?.identity;
|
||||
const payload = written as ConfigWritePayload;
|
||||
return payload.agents?.list?.find((entry) => entry.id === "main")?.identity;
|
||||
}
|
||||
|
||||
async function runIdentityCommandFromWorkspace(workspace: string, fromIdentity = true) {
|
||||
|
||||
@@ -340,7 +340,6 @@ describe("channels command", () => {
|
||||
function getWrittenConfig<T>(): T {
|
||||
expect(configMocks.writeConfigFile).toHaveBeenCalledTimes(1);
|
||||
const [config] = configMocks.writeConfigFile.mock.calls[0] ?? [];
|
||||
expect(config).toBeDefined();
|
||||
if (config === undefined) {
|
||||
throw new Error("expected written channel config");
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ vi.mock("../plugin-sdk/facade-loader.js", () => ({
|
||||
|
||||
function requireFirstNoteCall(noteFn: ReturnType<typeof vi.fn>): unknown[] {
|
||||
const call = noteFn.mock.calls[0];
|
||||
expect(call).toBeDefined();
|
||||
if (!call) {
|
||||
throw new Error("expected browser doctor note");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user