Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

test(api): follow the agent-subscriptions rename and complete the db mock

nirholas4764c32fd19c
diff --git a/tests/api/security-csrf-gates.test.js b/tests/api/security-csrf-gates.test.js
index 0679441e1..cb0de3f6f 100644
--- a/tests/api/security-csrf-gates.test.js
+++ b/tests/api/security-csrf-gates.test.js
@@ -175,7 +175,7 @@ const { default: keysHandler } = await import('../../api/keys/index.js');
const { default: keyByIdHandler } = await import('../../api/keys/[id].js');
const { default: agentActionsHandler } = await import('../../api/agent-actions.js');
const { default: agentMemoryHandler } = await import('../../api/agent-memory.js');
-const { default: subscriptionsHandler } = await import('../../api/subscriptions.js');
+const { default: subscriptionsHandler } = await import('../../api/agent-subscriptions.js');
const { default: dcaHandler } = await import('../../api/dca-strategies.js');
const { handleWithdraw } = await import('../../api/agents/solana-wallet.js');
const { handleTrade } = await import('../../api/agents/solana-trade.js');
@@ -522,12 +522,12 @@ describe('POST/DELETE /api/agent-memory — CSRF gate', () => {
});
});
-describe('POST/DELETE /api/subscriptions — CSRF gate', () => {
+describe('POST/DELETE /api/agent-subscriptions: CSRF gate', () => {
it('rejects session-authed POST without X-CSRF-Token (403 csrf_missing)', async () => {
authState.session = { id: 'user-1' };
const req = makeReq({
method: 'POST',
- url: '/api/subscriptions',
+ url: '/api/agent-subscriptions',
body: {
agentId: '11111111-1111-1111-1111-111111111111',
delegationId: '22222222-2222-2222-2222-222222222222',
diff --git a/tests/oauth-endpoints.test.js b/tests/oauth-endpoints.test.js
index e2a76fe1a..cb50cd1d7 100644
--- a/tests/oauth-endpoints.test.js
+++ b/tests/oauth-endpoints.test.js
@@ -110,7 +110,15 @@ const sqlMock = vi.fn(async (strings, ...values) => {
}
throw new Error(`unmodeled query: ${text}`);
});
-vi.mock('../api/_lib/db.js', () => ({ sql: (strings, ...values) => sqlMock(strings, ...values) }));
+// http.js's wrap() classifies caught errors with these predicates, so the mock
+// has to export them alongside sql or every handler error becomes a crash
+// inside the catch block instead of the intended status code.
+vi.mock('../api/_lib/db.js', () => ({
+ sql: (strings, ...values) => sqlMock(strings, ...values),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
+ isStoragePressured: () => false,
+}));
const getSessionUser = vi.fn();
vi.mock('../api/_lib/auth.js', async () => {