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
232 lines
7.0 KiB
TypeScript
232 lines
7.0 KiB
TypeScript
/**
|
|
* UPDATE_APP tests covering the pure parseUpdateAppIntent parser and the action. 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 type { UpdateAppInput } from "@elizaos/cloud-sdk";
|
|
import {
|
|
captureCallback,
|
|
FakeElizaCloudClient,
|
|
keyedRuntime,
|
|
makeApp,
|
|
makeMessage,
|
|
resetSdk,
|
|
setListApps,
|
|
setUpdateApp,
|
|
unkeyedRuntime,
|
|
} from "./helpers";
|
|
|
|
mock.module("@elizaos/cloud-sdk", () => ({
|
|
ElizaCloudClient: FakeElizaCloudClient,
|
|
}));
|
|
|
|
const { updateAppAction } = await import("../src/actions/update-app.ts");
|
|
const { parseUpdateAppIntent } = await import("../src/actions/update-app.ts");
|
|
const { cloudAppsProvider } = await import("../src/providers/cloud-apps.ts");
|
|
|
|
const APP = makeApp({ id: "id-acme", name: "Acme Bot", slug: "acme-bot" });
|
|
|
|
/** Track updateApp calls; echoes the patch into the returned app. */
|
|
function trackUpdates(): {
|
|
calls: Array<{ id: string; patch: UpdateAppInput }>;
|
|
} {
|
|
const calls: Array<{ id: string; patch: UpdateAppInput }> = [];
|
|
setUpdateApp((id, patch) => {
|
|
calls.push({ id, patch });
|
|
return Promise.resolve({
|
|
success: true,
|
|
app: makeApp({
|
|
id: "id-acme",
|
|
slug: "acme-bot",
|
|
name: patch.name ?? "Acme Bot",
|
|
description: patch.description ?? null,
|
|
logo_url: patch.logo_url ?? null,
|
|
}),
|
|
});
|
|
});
|
|
return { calls };
|
|
}
|
|
|
|
describe("parseUpdateAppIntent", () => {
|
|
it("parses a rename into a reference + name patch", () => {
|
|
const intent = parseUpdateAppIntent("rename Acme Bot to Zephyr");
|
|
expect(intent.reference).toBe("Acme Bot");
|
|
expect(intent.patch.name).toBe("Zephyr");
|
|
});
|
|
|
|
it("parses a description set with an explicit app", () => {
|
|
const intent = parseUpdateAppIntent(
|
|
"set the description of Acme Bot to a friendly support bot",
|
|
);
|
|
expect(intent.reference).toBe("Acme Bot");
|
|
expect(intent.patch.description).toBe("a friendly support bot");
|
|
});
|
|
|
|
it("prefers planner options over text", () => {
|
|
const intent = parseUpdateAppIntent("change something", {
|
|
appName: "Acme Bot",
|
|
name: "Beta",
|
|
});
|
|
expect(intent.reference).toBe("Acme Bot");
|
|
expect(intent.patch.name).toBe("Beta");
|
|
});
|
|
|
|
it("returns an empty patch when nothing is parseable", () => {
|
|
const intent = parseUpdateAppIntent("do something to my app");
|
|
expect(Object.keys(intent.patch)).toHaveLength(0);
|
|
});
|
|
});
|
|
|
|
describe("UPDATE_APP", () => {
|
|
beforeEach(() => {
|
|
resetSdk();
|
|
setListApps(() => Promise.resolve({ success: true, apps: [APP] }));
|
|
});
|
|
|
|
it("validates only when a Cloud API key is present", async () => {
|
|
expect(
|
|
await updateAppAction.validate(keyedRuntime(), makeMessage("x")),
|
|
).toBe(true);
|
|
expect(
|
|
await updateAppAction.validate(unkeyedRuntime(), makeMessage("x")),
|
|
).toBe(false);
|
|
});
|
|
|
|
it("renames an app: calls updateApp with the name patch and confirms", async () => {
|
|
const updates = trackUpdates();
|
|
const cb = captureCallback();
|
|
const result = await updateAppAction.handler(
|
|
keyedRuntime(),
|
|
makeMessage("rename Acme Bot to Zephyr"),
|
|
undefined,
|
|
undefined,
|
|
cb.fn,
|
|
);
|
|
|
|
expect(updates.calls).toHaveLength(1);
|
|
expect(updates.calls[0]?.id).toBe("id-acme");
|
|
expect(updates.calls[0]?.patch).toEqual({ name: "Zephyr" });
|
|
expect(result?.success).toBe(true);
|
|
expect(cb.calls[0]?.text).toContain("Zephyr");
|
|
expect((result?.data as { updated: string[] }).updated).toEqual(["name"]);
|
|
});
|
|
|
|
it("updates a description", async () => {
|
|
const updates = trackUpdates();
|
|
const cb = captureCallback();
|
|
const result = await updateAppAction.handler(
|
|
keyedRuntime(),
|
|
makeMessage("set the description of Acme Bot to a helpful bot"),
|
|
undefined,
|
|
undefined,
|
|
cb.fn,
|
|
);
|
|
expect(updates.calls[0]?.patch).toEqual({ description: "a helpful bot" });
|
|
expect(result?.success).toBe(true);
|
|
expect(cb.calls[0]?.text?.toLowerCase()).toContain("description updated");
|
|
});
|
|
|
|
it("rejects a malformed logo URL before calling the API", async () => {
|
|
const updates = trackUpdates();
|
|
const cb = captureCallback();
|
|
const result = await updateAppAction.handler(
|
|
keyedRuntime(),
|
|
makeMessage("set the logo of Acme Bot to not-a-url"),
|
|
undefined,
|
|
undefined,
|
|
cb.fn,
|
|
);
|
|
expect(updates.calls).toHaveLength(0);
|
|
expect((result?.data as { reason: string }).reason).toBe("invalid_url");
|
|
});
|
|
|
|
it("asks what to change when no field is parseable", async () => {
|
|
const updates = trackUpdates();
|
|
const cb = captureCallback();
|
|
const result = await updateAppAction.handler(
|
|
keyedRuntime(),
|
|
makeMessage("update my app"),
|
|
undefined,
|
|
{ appName: "Acme Bot" },
|
|
cb.fn,
|
|
);
|
|
expect(updates.calls).toHaveLength(0);
|
|
expect((result?.data as { reason: string }).reason).toBe("no_change");
|
|
});
|
|
|
|
it("returns not-found for an unknown app", async () => {
|
|
const updates = trackUpdates();
|
|
const cb = captureCallback();
|
|
const result = await updateAppAction.handler(
|
|
keyedRuntime(),
|
|
makeMessage("rename Zephyr to Gamma"),
|
|
undefined,
|
|
undefined,
|
|
cb.fn,
|
|
);
|
|
expect(updates.calls).toHaveLength(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 updateAppAction.handler(
|
|
unkeyedRuntime(),
|
|
makeMessage("rename Acme Bot to Zephyr"),
|
|
undefined,
|
|
undefined,
|
|
cb.fn,
|
|
);
|
|
expect(result?.success).toBe(false);
|
|
expect((result?.data as { reason: string }).reason).toBe("no_key");
|
|
});
|
|
|
|
it("surfaces an update API error", async () => {
|
|
setUpdateApp(() => Promise.reject(new Error("boom")));
|
|
const cb = captureCallback();
|
|
const result = await updateAppAction.handler(
|
|
keyedRuntime(),
|
|
makeMessage("rename Acme Bot to Zephyr"),
|
|
undefined,
|
|
undefined,
|
|
cb.fn,
|
|
);
|
|
expect(result?.success).toBe(false);
|
|
expect((result?.data as { reason: string }).reason).toBe("error");
|
|
});
|
|
|
|
it("invalidates the CLOUD_APPS provider cache after a successful update", async () => {
|
|
const runtime = keyedRuntime();
|
|
trackUpdates();
|
|
|
|
const primed = await cloudAppsProvider.get(
|
|
runtime,
|
|
makeMessage("my apps"),
|
|
{} as never,
|
|
);
|
|
expect(primed.text).toContain("Acme Bot");
|
|
|
|
const result = await updateAppAction.handler(
|
|
runtime,
|
|
makeMessage("rename Acme Bot to Zephyr"),
|
|
undefined,
|
|
undefined,
|
|
captureCallback().fn,
|
|
);
|
|
expect(result?.success).toBe(true);
|
|
|
|
setListApps(() =>
|
|
Promise.resolve({
|
|
success: true,
|
|
apps: [makeApp({ id: "id-acme", slug: "acme-bot", name: "Zephyr" })],
|
|
}),
|
|
);
|
|
const after = await cloudAppsProvider.get(
|
|
runtime,
|
|
makeMessage("my apps"),
|
|
{} as never,
|
|
);
|
|
expect(after.text).toContain("Zephyr");
|
|
expect(after.text).not.toContain("Acme Bot");
|
|
});
|
|
});
|