Files
wehub-resource-sync 426e9eeabd
Benchmark Bridge Tests / benchmark (bunx @biomejs/biome check packages/lifeops-bench/src, benchmark-lint) (push) Waiting to run
Benchmark Bridge Tests / benchmark (bunx vitest run --config packages/lifeops-bench/vitest.config.ts --root packages/lifeops-bench --passWithNoTests, benchmark-tests) (push) Waiting to run
Build Agent Image / build-and-push (push) Waiting to run
Chat shell gestures / Chat shell gesture + parity e2e (push) Waiting to run
Cloud Gateway Discord / Test (push) Waiting to run
Cloud Gateway Webhook / Test (push) Waiting to run
Cloud Tests / lint-and-types (push) Waiting to run
Cloud Tests / unit-tests (push) Waiting to run
Cloud Tests / integration-tests (push) Waiting to run
Cloud Tests / e2e-tests (push) Blocked by required conditions
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Deploy Apps Worker (Product 2) / Determine environment (push) Waiting to run
Deploy Apps Worker (Product 2) / Deploy apps worker to apps-control host (${{ needs.determine-env.outputs.environment }}) (push) Blocked by required conditions
Deploy Eliza Provisioning Worker / Determine environment (push) Waiting to run
Deploy Eliza Provisioning Worker / Deploy worker to Hetzner host (${{ needs.determine-env.outputs.environment }} @ ${{ needs.determine-env.outputs.deployment_sha }}) (push) Blocked by required conditions
Dev Smoke / Classify changed paths (push) Waiting to run
Dev Smoke / bun run dev onboarding chat (push) Blocked by required conditions
Dev Smoke / Vite HMR dependency-level smoke (push) Blocked by required conditions
Electrobun Submodule Guard / electrobun gitlink is fetchable (push) Waiting to run
Publish @elizaos/example-code / check_npm (push) Waiting to run
Publish @elizaos/example-code / publish_npm (push) Blocked by required conditions
Publish @elizaos/plugin-elizacloud / verify_version (push) Waiting to run
Publish @elizaos/plugin-elizacloud / publish_npm (push) Blocked by required conditions
Sandbox Live Smoke / Sandbox live smoke (push) Waiting to run
Snap Build & Test / Build Snap (amd64) (push) Waiting to run
Snap Build & Test / Build Snap (arm64) (push) Waiting to run
supply-chain / sbom (push) Waiting to run
supply-chain / vulnerability-scan (push) Waiting to run
Build, Push & Deploy to Phala Cloud / build-and-push (push) Waiting to run
Test Packaging / Validate Packaging Configs (push) Waiting to run
Test Packaging / PyPI on Python ${{ matrix.python }} (push) Waiting to run
Test Packaging / Pack & Test JS Tarballs (push) Waiting to run
Test Packaging / elizaos CLI global-install smoke (node + bun) (push) Waiting to run
UI Fixture E2E / ui-fixture-e2e (push) Waiting to run
UI Fixture E2E / fixture-e2e (push) Waiting to run
UI Story Gate / story-gate (push) Waiting to run
vault-ci / test (macos-latest) (push) Waiting to run
vault-ci / test (ubuntu-latest) (push) Waiting to run
vault-ci / test (windows-latest) (push) Waiting to run
vault-ci / app-core wiring tests (push) Waiting to run
verify-patches / verify patches/CHECKSUMS.sha256 (push) Waiting to run
Voice Benchmark Smoke / voice-emotion fixture smoke (push) Waiting to run
Voice Benchmark Smoke / voiceagentbench fixture smoke (push) Waiting to run
Voice Benchmark Smoke / voicebench-quality unit smoke (push) Waiting to run
Voice Benchmark Smoke / voicebench TypeScript unit (no audio) (push) Waiting to run
Voice Benchmark Smoke / voice bench smoke summary (push) Blocked by required conditions
Windows CI / windows ([bun run --cwd packages/app-core test bun run --cwd packages/elizaos test bun run --cwd packages/cloud/shared test], app-and-cli) (push) Waiting to run
Windows CI / windows ([bun run --cwd packages/scenario-runner test bun run --cwd packages/vault test bun run --cwd packages/security test bun run --cwd plugins/plugin-coding-tools test], framework-packages) (push) Waiting to run
Windows CI / windows ([bun run --cwd plugins/plugin-elizacloud test bun run --cwd plugins/plugin-discord test bun run --cwd plugins/plugin-anthropic test bun run --cwd plugins/plugin-openai test bun run --cwd plugins/plugin-app-control test bun run --cwd plugins/pl… (push) Waiting to run
Windows CI / windows ([node packages/scripts/run-turbo.mjs run build --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/agent --concurrency=4 node packages/scripts/run-bash-linux-only.mjs scripts/verify-riscv64-buildpaths.sh node packages/scripts/run… (push) Waiting to run
Windows CI / windows ([node packages/scripts/run-turbo.mjs run typecheck --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/cloud-shared --concurrency=4 bun run --cwd packages/core test bun run --cwd packages/shared test], core-runtime, 75) (push) Waiting to run
Test Packaging / Build & Test PyPI Package (push) Waiting to run
Voice Workbench / headless workbench (mocked backends) (push) Has been cancelled
Voice Workbench / real acoustic lane (nightly, provisioned only) (push) Has been cancelled
ci / test (push) Has been cancelled
ci / lint-and-format (push) Has been cancelled
ci / build (push) Has been cancelled
ci / dev-startup (push) Has been cancelled
gitleaks / gitleaks (push) Has been cancelled
Markdown Links / Relative Markdown Links (push) Has been cancelled
Quality (Extended) / Homepage Build (PR smoke) (push) Has been cancelled
Quality (Extended) / Comment-only diff guard (push) Has been cancelled
Quality (Extended) / Format + Type Safety Ratchet (push) Has been cancelled
Quality (Extended) / Develop Gate (secret scan + UI determinism) (push) Has been cancelled
Quality (Extended) / Develop Gate (lint) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:43:05 +08:00

325 lines
9.5 KiB
TypeScript

/**
* DELETE_APP action tests: the destructive two-phase confirm, the frozen-target guard, and honest partial-failure reporting. The @elizaos/cloud-sdk client is faked (helpers.ts, SDK boundary only); the action runs for real.
*/
import { beforeEach, describe, expect, it, mock } from "bun:test";
import {
captureCallback,
FakeElizaCloudClient,
keyedRuntime,
makeApp,
makeMessage,
resetSdk,
setDeleteApp,
setListApps,
unkeyedRuntime,
} from "./helpers";
mock.module("@elizaos/cloud-sdk", () => ({
ElizaCloudClient: FakeElizaCloudClient,
}));
const { deleteAppAction } = await import("../src/actions/delete-app.ts");
const APP = makeApp({ id: "id-acme", name: "Acme Bot", slug: "acme-bot" });
/** Track delete calls; returns the call count getter. */
function trackDeletes(): { count: () => number } {
let count = 0;
setDeleteApp(() => {
count += 1;
return Promise.resolve({ success: true, message: "deleted" });
});
return { count: () => count };
}
describe("DELETE_APP", () => {
beforeEach(() => {
resetSdk();
setListApps(() => Promise.resolve({ success: true, apps: [APP] }));
});
it("validates only when a Cloud API key is present", async () => {
expect(
await deleteAppAction.validate(keyedRuntime(), makeMessage("x")),
).toBe(true);
expect(
await deleteAppAction.validate(unkeyedRuntime(), makeMessage("x")),
).toBe(false);
});
it("first ask: returns a confirmation prompt and does NOT delete", async () => {
const deletes = trackDeletes();
const cb = captureCallback();
const result = await deleteAppAction.handler(
keyedRuntime(),
makeMessage("delete my Acme Bot app"),
undefined,
undefined,
cb.fn,
);
expect(deletes.count()).toBe(0);
expect((result?.data as { deleted: boolean }).deleted).toBe(false);
expect(
(result?.data as { confirmationRequired: boolean }).confirmationRequired,
).toBe(true);
const prompt = cb.calls[0]?.text ?? "";
expect(prompt).toContain("Acme Bot");
expect(prompt).toContain("tenant database");
expect(prompt.toLowerCase()).toContain("can't be undone");
});
it("explicit confirmation: deletes exactly once", async () => {
const deletes = trackDeletes();
const runtime = keyedRuntime();
const cb = captureCallback();
await deleteAppAction.handler(
runtime,
makeMessage("delete Acme Bot"),
undefined,
undefined,
cb.fn,
);
const result = await deleteAppAction.handler(
runtime,
makeMessage("confirmar"),
undefined,
{ confirm: true },
cb.fn,
);
expect(deletes.count()).toBe(1);
expect(result?.success ?? false).toBe(true);
expect((result?.data as { deleted: boolean }).deleted).toBe(true);
expect(cb.calls.at(-1)?.text).toContain("Deleted");
});
it("partial-cleanup failure: reports partial, does NOT claim the container/DB are gone", async () => {
// The DELETE route returns HTTP 200 with { success:false, errors } when
// cleanup partially fails (continueOnError) — the SDK returns it normally.
setDeleteApp(() =>
Promise.resolve({
success: false,
message: "partial cleanup",
errors: ["tenant_db teardown failed"],
}),
);
const runtime = keyedRuntime();
const cb = captureCallback();
await deleteAppAction.handler(
runtime,
makeMessage("delete Acme Bot"),
undefined,
undefined,
cb.fn,
);
const result = await deleteAppAction.handler(
runtime,
makeMessage("confirm"),
undefined,
{ confirm: true },
cb.fn,
);
expect(result?.success ?? true).toBe(false);
expect((result?.data as { partial?: boolean }).partial).toBe(true);
expect((result?.data as { errors?: string[] }).errors).toContain(
"tenant_db teardown failed",
);
const reply = cb.calls.at(-1)?.text ?? "";
expect(reply).not.toContain("are gone");
expect(reply.toLowerCase()).toContain("dashboard");
});
it("a bare 'yes' is NOT enough to delete (connector-agnostic safety)", async () => {
const deletes = trackDeletes();
const runtime = keyedRuntime();
const cb = captureCallback();
await deleteAppAction.handler(
runtime,
makeMessage("delete Acme Bot"),
undefined,
undefined,
cb.fn,
);
const result = await deleteAppAction.handler(
runtime,
makeMessage("yes"),
undefined,
undefined,
cb.fn,
);
expect(deletes.count()).toBe(0);
expect(
(result?.data as { confirmationRequired: boolean }).confirmationRequired,
).toBe(true);
});
it("a hesitant follow-up does NOT delete", async () => {
const deletes = trackDeletes();
const runtime = keyedRuntime();
await deleteAppAction.handler(
runtime,
makeMessage("delete Acme Bot"),
undefined,
undefined,
captureCallback().fn,
);
const result = await deleteAppAction.handler(
runtime,
makeMessage("hmm not sure, maybe later"),
undefined,
{ confirm: false },
captureCallback().fn,
);
expect(deletes.count()).toBe(0);
expect((result?.data as { canceled: boolean }).canceled).toBe(true);
});
it("structured confirm without a pending prompt does NOT delete", async () => {
const deletes = trackDeletes();
const result = await deleteAppAction.handler(
keyedRuntime(),
makeMessage("confirm"),
undefined,
{ confirm: true },
captureCallback().fn,
);
expect(deletes.count()).toBe(0);
expect((result?.data as { reason: string }).reason).toBe(
"no_pending_confirmation",
);
});
it("returns not-found for an unknown app (no confirmation, no delete)", async () => {
const deletes = trackDeletes();
const cb = captureCallback();
const result = await deleteAppAction.handler(
keyedRuntime(),
makeMessage("delete Zephyr"),
undefined,
undefined,
cb.fn,
);
expect(deletes.count()).toBe(0);
expect((result?.data as { reason: string }).reason).toBe("not_found");
});
it("degrades gracefully with no Cloud API key", async () => {
const cb = captureCallback();
const result = await deleteAppAction.handler(
unkeyedRuntime(),
makeMessage("delete Acme Bot"),
undefined,
undefined,
cb.fn,
);
expect(result?.success).toBe(false);
expect((result?.data as { reason: string }).reason).toBe("no_key");
});
it("confirm naming a DIFFERENT app refuses, deletes nothing, and clears the pending", async () => {
const deletes = trackDeletes();
const runtime = keyedRuntime();
const cb = captureCallback();
await deleteAppAction.handler(
runtime,
makeMessage("delete Acme Bot"),
undefined,
undefined,
cb.fn,
);
// Real planner path: params nested under options.parameters.
const result = await deleteAppAction.handler(
runtime,
makeMessage("actually — yes, delete Beta Dashboard"),
undefined,
{ parameters: { confirm: true, appName: "Beta Dashboard" } },
cb.fn,
);
expect(deletes.count()).toBe(0);
expect(result?.success).toBe(false);
expect((result?.data as { reason: string }).reason).toBe(
"confirm_target_mismatch",
);
const reply = cb.calls.at(-1)?.text ?? "";
expect(reply).toContain("Beta Dashboard");
expect(reply).toContain("Acme Bot");
// The stale pending is cleared: a follow-up bare confirm cannot delete the
// frozen target either.
const followUp = await deleteAppAction.handler(
runtime,
makeMessage("confirm"),
undefined,
{ confirm: true },
cb.fn,
);
expect(deletes.count()).toBe(0);
expect((followUp?.data as { reason: string }).reason).toBe(
"no_pending_confirmation",
);
});
it("confirm re-naming the SAME app (partial name / generic filler) still deletes", async () => {
const deletes = trackDeletes();
const runtime = keyedRuntime();
await deleteAppAction.handler(
runtime,
makeMessage("delete Acme Bot"),
undefined,
undefined,
captureCallback().fn,
);
const result = await deleteAppAction.handler(
runtime,
makeMessage("yes delete acme"),
undefined,
{ parameters: { confirm: true, appName: "acme" } },
captureCallback().fn,
);
expect(deletes.count()).toBe(1);
expect((result?.data as { deleted: boolean }).deleted).toBe(true);
// Generic filler ("my app") is not a target switch either.
await deleteAppAction.handler(
runtime,
makeMessage("delete Acme Bot"),
undefined,
undefined,
captureCallback().fn,
);
const generic = await deleteAppAction.handler(
runtime,
makeMessage("yes delete my app"),
undefined,
{ parameters: { confirm: true, appName: "my app" } },
captureCallback().fn,
);
expect(deletes.count()).toBe(2);
expect((generic?.data as { deleted: boolean }).deleted).toBe(true);
});
it("surfaces a delete API error", async () => {
setDeleteApp(() => Promise.reject(new Error("boom")));
const runtime = keyedRuntime();
const cb = captureCallback();
await deleteAppAction.handler(
runtime,
makeMessage("delete Acme Bot"),
undefined,
undefined,
cb.fn,
);
const result = await deleteAppAction.handler(
runtime,
makeMessage("confirm"),
undefined,
{ confirm: true },
cb.fn,
);
expect(result?.success).toBe(false);
expect((result?.data as { reason: string }).reason).toBe("error");
});
});