Zapier Platform CLI app (zapier-mem0) with Add Memory / Delete Memory
creates and Search Memories / Get Memories searches against the Mem0 v3
API. Custom API-key auth (Authorization: Token), base-URL + auth
injected via beforeRequest middleware, non-2xx surfaced as errors.
Add Memory polls GET /v1/event/{id}/ for async extraction. Includes an
E2E test suite via createAppTester.
70 lines
1.9 KiB
JavaScript
70 lines
1.9 KiB
JavaScript
'use strict';
|
|
|
|
/* global describe, it, expect, beforeAll */
|
|
|
|
const zapier = require('zapier-platform-core');
|
|
const App = require('../index');
|
|
|
|
const appTester = zapier.createAppTester(App);
|
|
|
|
const authData = {
|
|
apiKey: process.env.MEM0_API_KEY,
|
|
baseUrl: process.env.MEM0_BASE_URL || 'https://api.mem0.ai',
|
|
};
|
|
|
|
const userId = `zapier-e2e-${Date.now()}`;
|
|
|
|
describe('Mem0 Zapier integration (E2E)', () => {
|
|
beforeAll(() => {
|
|
if (!authData.apiKey) throw new Error('MEM0_API_KEY env var is required for E2E tests');
|
|
});
|
|
|
|
it('authentication.test succeeds', async () => {
|
|
const res = await appTester(App.authentication.test, { authData });
|
|
expect(res.status).toBe(200);
|
|
});
|
|
|
|
it('adds, searches, lists, and deletes a memory', async () => {
|
|
// Add (async, wait for completion)
|
|
const added = await appTester(App.creates.add_memory.operation.perform, {
|
|
authData,
|
|
inputData: {
|
|
content: 'I love hiking in the Alps and my favorite food is sushi',
|
|
user_id: userId,
|
|
waitForCompletion: true,
|
|
},
|
|
});
|
|
expect(added.status).toBe('SUCCEEDED');
|
|
|
|
// Search
|
|
const found = await appTester(App.searches.search_memories.operation.perform, {
|
|
authData,
|
|
inputData: { query: 'outdoor activities', user_id: userId, limit: 5 },
|
|
});
|
|
expect(Array.isArray(found)).toBe(true);
|
|
expect(found.length).toBeGreaterThan(0);
|
|
|
|
// Get all
|
|
const all = await appTester(App.searches.get_memories.operation.perform, {
|
|
authData,
|
|
inputData: { user_id: userId },
|
|
});
|
|
expect(Array.isArray(all)).toBe(true);
|
|
expect(all.length).toBeGreaterThan(0);
|
|
|
|
// Cleanup: delete every memory we created
|
|
for (const mem of all) {
|
|
await appTester(App.creates.delete_memory.operation.perform, {
|
|
authData,
|
|
inputData: { memory_id: mem.id },
|
|
});
|
|
}
|
|
|
|
const afterDelete = await appTester(App.searches.get_memories.operation.perform, {
|
|
authData,
|
|
inputData: { user_id: userId },
|
|
});
|
|
expect(afterDelete.length).toBe(0);
|
|
});
|
|
});
|