capture-inbox-payload.test.mjs
41 lines 1.8 KB
Raw
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd feat(calendar): enforce agent context tiers in retrieval AP… Human minor ⚠ breaking 2 days ago
1 /**
2 * Pure payload builder for local + hosted capture (stable paths with fixed clock).
3 */
4
5 import { describe, it } from 'node:test';
6 import assert from 'node:assert/strict';
7 import { buildCaptureInboxWritePayload } from '../lib/capture-inbox.mjs';
8
9 describe('buildCaptureInboxWritePayload', () => {
10 /** Fixed instant; path time segment follows local `Date#getHours` like production capture. */
11 const fixed = new Date(Date.UTC(2026, 3, 18, 15, 30, 45));
12 const hh = String(fixed.getHours()).padStart(2, '0');
13 const mm = String(fixed.getMinutes()).padStart(2, '0');
14 const ss = String(fixed.getSeconds()).padStart(2, '0');
15 const tseg = `${hh}${mm}${ss}`;
16
17 it('builds default inbox path, body, and frontmatter', () => {
18 const o = buildCaptureInboxWritePayload('Hello World!', {}, fixed);
19 assert.equal(o.path, `inbox/2026-04-18-${tseg}-hello-world.md`);
20 assert.equal(o.body, 'Hello World!');
21 assert.equal(o.frontmatter.source, 'mcp-capture');
22 assert.equal(o.frontmatter.date, '2026-04-18');
23 assert.equal(o.frontmatter.inbox, true);
24 assert.equal(o.frontmatter.project, undefined);
25 assert.equal(o.frontmatter.tags, undefined);
26 });
27
28 it('honors source, project slug, and tags', () => {
29 const o = buildCaptureInboxWritePayload('Note body', { source: 'slack', project: 'Launch', tags: ['a', ' B '] }, fixed);
30 assert.equal(o.path, `projects/launch/inbox/2026-04-18-${tseg}-note-body.md`);
31 assert.equal(o.body, 'Note body');
32 assert.equal(o.frontmatter.source, 'slack');
33 assert.equal(o.frontmatter.project, 'launch');
34 assert.equal(o.frontmatter.tags, 'a, b');
35 });
36
37 it('uses project inbox directory when project is set', () => {
38 const o = buildCaptureInboxWritePayload('x', { project: 'My-Project' }, fixed);
39 assert.equal(o.path, `projects/my-project/inbox/2026-04-18-${tseg}-x.md`);
40 });
41 });
File History 2 commits
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd feat(calendar): enforce agent context tiers in retrieval AP… Human minor 2 days ago
sha256:9103f98c89257ed2b01c237cea895dabb3e85ea337dccb1161c175e4422355b6 docs: accept Calendar Events v0 spec with Phase 0 security … Human 2 days ago