import { describe, it, expect, csrf } from './runner.js?v=4'; describe('Relay: Push API', () => { it('push without config returns error', async () => { const settings = await fetch('api/relay/settings').then(r => r.json()); // The GET endpoint echoes the secret directly as `key` (single-user local app). if (settings.url && settings.key) return; // skip if configured const res = await fetch('api/relay/push', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() }, body: JSON.stringify({ card_id: 1 }), }).then(r => r.json()); expect(res.ok).toBe(false); expect(res.error).toContain('not configured'); }); it('push without card_id returns error', async () => { const res = await fetch('api/relay/push', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf() }, body: JSON.stringify({}), }); expect(res.status).toBe(400); }); }); describe('Relay: Poll API', () => { it('poll without config returns 0 pulled', async () => { const settings = await fetch('api/relay/settings').then(r => r.json()); if (settings.url && settings.key) return; const res = await fetch('api/relay/poll', { method: 'POST', headers: { 'X-CSRF-Token': csrf() }, }).then(r => r.json()); expect(res.ok).toBe(true); expect(res.pulled).toBe(0); }); });