mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 23:56:07 +00:00
test: tighten core helper assertions
This commit is contained in:
@@ -3,7 +3,6 @@ import { fireAndForgetBoundedHook, fireAndForgetHook } from "./fire-and-forget.j
|
||||
|
||||
function requireFirstLog(logger: ReturnType<typeof vi.fn>): string {
|
||||
const message = logger.mock.calls[0]?.[0];
|
||||
expect(message).toBeDefined();
|
||||
if (typeof message !== "string") {
|
||||
throw new Error("expected string log message");
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import { generateSlugViaLLM } from "./llm-slug-generator.js";
|
||||
|
||||
function requireFirstRunOptions(): unknown {
|
||||
const options = runEmbeddedPiAgentMock.mock.calls[0]?.[0];
|
||||
expect(options).toBeDefined();
|
||||
if (!options) {
|
||||
throw new Error("expected embedded Pi agent run options");
|
||||
}
|
||||
|
||||
@@ -48,7 +48,6 @@ const spawnMock = vi.mocked(spawn);
|
||||
|
||||
function requireSpawnArgs(index: number): string[] {
|
||||
const args = spawnMock.mock.calls[index]?.[1] as string[] | undefined;
|
||||
expect(args).toBeDefined();
|
||||
if (!args) {
|
||||
throw new Error("expected ssh spawn args");
|
||||
}
|
||||
|
||||
@@ -180,13 +180,11 @@ describe("runCapability skips tiny audio files", () => {
|
||||
expect(result.decision.outcome).toBe("failed");
|
||||
expect(result.decision.attachments).toHaveLength(1);
|
||||
const attachment = result.decision.attachments[0];
|
||||
expect(attachment).toBeDefined();
|
||||
if (!attachment) {
|
||||
throw new Error("expected failed audio decision attachment");
|
||||
}
|
||||
expect(attachment.attempts).toHaveLength(1);
|
||||
const attempt = attachment.attempts[0];
|
||||
expect(attempt).toBeDefined();
|
||||
if (!attempt) {
|
||||
throw new Error("expected failed audio decision attempt");
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ type CapabilityResult = Awaited<ReturnType<typeof runCapability>>;
|
||||
|
||||
function requireCapabilityOutput(result: CapabilityResult, index: number) {
|
||||
const output = result.outputs[index];
|
||||
expect(output).toBeDefined();
|
||||
if (!output) {
|
||||
throw new Error(`expected media-understanding output at index ${index}`);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ type ChannelSecretContractApi = NonNullable<ReturnType<typeof loadChannelSecretC
|
||||
function requireChannelSecretContractApi(
|
||||
api: ReturnType<typeof loadChannelSecretContractApi>,
|
||||
): ChannelSecretContractApi {
|
||||
expect(api).toBeDefined();
|
||||
if (!api) {
|
||||
throw new Error("expected channel secret contract API");
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ type ValidatedPlanTarget = NonNullable<ReturnType<typeof resolveValidatedPlanTar
|
||||
function requireValidatedPlanTarget(
|
||||
resolved: ReturnType<typeof resolveValidatedPlanTarget>,
|
||||
): ValidatedPlanTarget {
|
||||
expect(resolved).not.toBeNull();
|
||||
if (!resolved) {
|
||||
throw new Error("expected validated secrets plan target");
|
||||
}
|
||||
|
||||
@@ -65,7 +65,6 @@ const pluginRegistryMocks = vi.hoisted(() => {
|
||||
|
||||
function requireLastMetadataSnapshotCall(): unknown[] {
|
||||
const call = pluginRegistryMocks.loadPluginMetadataSnapshot.mock.calls.at(-1);
|
||||
expect(call).toBeDefined();
|
||||
if (!call) {
|
||||
throw new Error("expected plugin metadata snapshot call");
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ function requireTelegramConfig(
|
||||
snapshot: Awaited<ReturnType<typeof prepareSecretsRuntimeSnapshot>>,
|
||||
) {
|
||||
const config = snapshot.config.channels?.telegram;
|
||||
expect(config).toBeDefined();
|
||||
if (!config) {
|
||||
throw new Error("expected Telegram runtime config");
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ describe("secret target registry fast path", () => {
|
||||
it("resolves bundled channel targets by explicit channel id without manifest scans", () => {
|
||||
const target = resolveConfigSecretTargetByPath(["channels", "googlechat", "serviceAccount"]);
|
||||
|
||||
expect(target).toBeDefined();
|
||||
if (!target) {
|
||||
throw new Error("expected googlechat service account target");
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ const ORIGINAL_STATE_DIR = process.env.OPENCLAW_STATE_DIR;
|
||||
|
||||
function requireFirstUpsertParams(upsertTaskWithDeliveryState: ReturnType<typeof vi.fn>): unknown {
|
||||
const params = upsertTaskWithDeliveryState.mock.calls[0]?.[0];
|
||||
expect(params).toBeDefined();
|
||||
if (!params) {
|
||||
throw new Error("expected task upsert params");
|
||||
}
|
||||
|
||||
@@ -78,7 +78,6 @@ type ResolvedWebFetchDefinition = NonNullable<
|
||||
function requireResolvedWebFetch(
|
||||
resolved: ReturnType<Awaited<typeof import("./runtime.js")>["resolveWebFetchDefinition"]>,
|
||||
): ResolvedWebFetchDefinition {
|
||||
expect(resolved).toBeDefined();
|
||||
if (!resolved) {
|
||||
throw new Error("expected resolved web fetch definition");
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
const patternFiles = createPatternFileHelper("openclaw-vitest-unit-config-");
|
||||
|
||||
function requireTestConfig<T extends { test?: unknown }>(config: T): NonNullable<T["test"]> {
|
||||
expect(config.test).toBeDefined();
|
||||
if (!config.test) {
|
||||
throw new Error("expected unit vitest test config");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user