capture-inbox-payload.test.mjs
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠ breaking
11 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
4 commits
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf
mirror: GitHub Phase A durable MCP OAuth (#270)
Human
minor
⚠
11 days ago
sha256:d8c648b20a4d53b2673c5c082ee7edfa7b2fc9b11080832da1f38807b6bf940b
fix(7C-L1b): route hosted delegation proposals through cani…
Human
minor
⚠
31 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91
fix: repair endpoint now sets has_active_subscription when …
Human
minor
⚠
50 days ago
sha256:6a102aafafdfe7e70a24f4e59740200f0ee713ce7915f1b53e9d4ba5ee8b4410
Initial Muse snapshot
Human
83 days ago