packages/verae-activate is pushable with zapier-platform 19.1.0: local Add Numbers (number1+number2=sum) needs no hosted API. zapier-platform validate is clean (0 warnings). zappier POST /v1/add is a free metered endpoint for the optional hosted path. Tests: verae-activate 7/7, zappier 176/176, verae-zapier 5/5, middleware gate 1 11/11. Morning steps: docs/04-activate/SETUP-ZAPIER-DEVELOPER.md Learned: perform runs on Zapier cloud so arithmetic needs no public URL; CLI and zapier-platform-core majors must match; do not mix zapier-sdk.
93 lines
3.4 KiB
JavaScript
93 lines
3.4 KiB
JavaScript
/**
|
|
* GATE 11 — Zapier package shape tests (no live Zapier CLI required)
|
|
*/
|
|
|
|
const { describe, it } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
const App = require('../index');
|
|
const authentication = require('../authentication');
|
|
const timestampAndWait = require('../creates/timestamp_and_wait');
|
|
const createTimestamp = require('../creates/create_timestamp');
|
|
const verifyTimestamp = require('../creates/verify_timestamp');
|
|
const batchTimestamp = require('../creates/batch_timestamp');
|
|
const jobStatus = require('../searches/job_status');
|
|
const timestampCompleted = require('../triggers/timestamp_completed');
|
|
|
|
describe('verae-zapier app definition', () => {
|
|
it('exports authentication with api_key field', () => {
|
|
assert.equal(authentication.type, 'custom');
|
|
assert.ok(authentication.fields.some((f) => f.key === 'api_key'));
|
|
});
|
|
|
|
it('wires creates, searches, triggers', () => {
|
|
assert.ok(App.creates.add_numbers);
|
|
assert.ok(App.creates.timestamp_and_wait);
|
|
assert.ok(App.creates.create_timestamp);
|
|
assert.ok(App.creates.verify_timestamp);
|
|
assert.ok(App.creates.batch_timestamp);
|
|
assert.ok(App.searches.job_status);
|
|
assert.ok(App.triggers.timestamp_completed);
|
|
});
|
|
|
|
it('create actions target middleware paths', () => {
|
|
process.env.MIDDLEWARE_BASE_URL = 'https://mw.example.com';
|
|
const urls = [];
|
|
const z = {
|
|
request: async (opts) => {
|
|
urls.push(opts.url);
|
|
return { data: { ok: true } };
|
|
},
|
|
};
|
|
const bundle = {
|
|
authData: { api_key: 'zmw_test' },
|
|
inputData: { data: 'x', certificate: 'c', items: 'a\nb', jobId: 'j1' },
|
|
};
|
|
|
|
return Promise.all([
|
|
timestampAndWait.operation.perform(z, bundle),
|
|
createTimestamp.operation.perform(z, bundle),
|
|
verifyTimestamp.operation.perform(z, bundle),
|
|
batchTimestamp.operation.perform(z, bundle),
|
|
jobStatus.operation.perform(z, bundle),
|
|
]).then(() => {
|
|
assert.ok(urls.some((u) => u.endsWith('/zapier/v1/timestamp/wait')));
|
|
assert.ok(urls.some((u) => u.endsWith('/zapier/v1/timestamp')));
|
|
assert.ok(urls.some((u) => u.endsWith('/zapier/v1/verify')));
|
|
assert.ok(urls.some((u) => u.endsWith('/zapier/v1/timestamp/batch')));
|
|
assert.ok(urls.some((u) => u.includes('/zapier/v1/status/')));
|
|
});
|
|
});
|
|
|
|
it('trigger subscribe/unsubscribe shapes', async () => {
|
|
process.env.MIDDLEWARE_BASE_URL = 'https://mw.example.com';
|
|
const calls = [];
|
|
const z = {
|
|
request: async (opts) => {
|
|
calls.push(opts);
|
|
return { data: { id: 'hook-1' } };
|
|
},
|
|
};
|
|
|
|
const id = await timestampCompleted.operation.performSubscribe(z, {
|
|
targetUrl: 'https://hooks.zapier.com/x',
|
|
authData: { api_key: 'k' },
|
|
});
|
|
assert.equal(id, 'hook-1');
|
|
assert.equal(calls[0].method, 'POST');
|
|
assert.match(calls[0].url, /webhooks\/subscribe$/);
|
|
assert.equal(calls[0].body.event, 'timestamp.completed');
|
|
|
|
await timestampCompleted.operation.performUnsubscribe(z, {
|
|
subscribeData: 'hook-1',
|
|
authData: { api_key: 'k' },
|
|
});
|
|
assert.equal(calls[1].method, 'DELETE');
|
|
assert.match(calls[1].url, /webhooks\/unsubscribe$/);
|
|
});
|
|
|
|
it('beforeRequest adds Authorization bearer', () => {
|
|
const req = App.beforeRequest[0]({}, null, { authData: { api_key: 'zmw_abc' } });
|
|
assert.equal(req.headers.Authorization, 'Bearer zmw_abc');
|
|
});
|
|
});
|