attachment-store-e2e.test.mjs
65 lines 2.2 KB
Raw
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor ⚠ breaking 11 days ago
1 /**
2 * Tier 3 — E2E: temp vault derivation walkthrough and filtered list/get.
3 *
4 * @see docs/ATTACHMENT-STORE-CONTRACT-2F-b.md §9
5 */
6 import { describe, it, beforeEach, afterEach } from 'node:test';
7 import assert from 'node:assert/strict';
8 import fs from 'node:fs';
9 import path from 'node:path';
10 import { fileURLToPath } from 'node:url';
11 import { handleAttachmentListRequest, handleAttachmentGetRequest } from '../lib/attachments/attachment-handlers.mjs';
12 import { buildAttachmentFixtureVault } from './fixtures/attachment-fixture.mjs';
13
14 const __dirname = path.dirname(fileURLToPath(import.meta.url));
15 const tmpRoot = path.join(__dirname, 'fixtures', 'tmp-attachment-e2e');
16
17 describe('E2E — Attachment read walkthrough', () => {
18 let fx;
19
20 beforeEach(() => {
21 fs.rmSync(tmpRoot, { recursive: true, force: true });
22 fx = buildAttachmentFixtureVault(tmpRoot);
23 });
24
25 afterEach(() => {
26 fs.rmSync(tmpRoot, { recursive: true, force: true });
27 });
28
29 it('derives vault_file, mist_blob, and embedded_url attachments', () => {
30 const list = handleAttachmentListRequest({
31 dataDir: fx.dataDir,
32 vaultPath: fx.vaultPath,
33 vaultId: fx.vaultId,
34 role: 'admin',
35 });
36 assert.equal(list.ok, true);
37 const sources = new Set(list.payload.attachments.map((a) => a.source));
38 assert.ok(sources.has('vault_file'));
39 assert.ok(sources.has('mist_blob'));
40 assert.ok(sources.has('embedded_url'));
41 });
42
43 it('get vault_file returns linked note refs when present; embedded_url filter works', () => {
44 const got = handleAttachmentGetRequest({
45 dataDir: fx.dataDir,
46 vaultPath: fx.vaultPath,
47 vaultId: fx.vaultId,
48 attachmentId: fx.fileId,
49 role: 'admin',
50 });
51 assert.equal(got.ok, true);
52 assert.equal(got.payload.attachment.storage_kind, 'vault_blob');
53
54 const embeddedOnly = handleAttachmentListRequest({
55 dataDir: fx.dataDir,
56 vaultPath: fx.vaultPath,
57 vaultId: fx.vaultId,
58 role: 'admin',
59 source: 'embedded_url',
60 });
61 assert.equal(embeddedOnly.ok, true);
62 assert.ok(embeddedOnly.payload.attachments.every((a) => a.source === 'embedded_url'));
63 assert.ok(embeddedOnly.payload.attachments.some((a) => a.storage_kind === 'external_link'));
64 });
65 });
File History 1 commit
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor 11 days ago