mcp-video-resources.test.mjs
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠ breaking
1 day ago
| 1 | /** |
| 2 | * Tests for Phase 18B: MCP Video Resources — resource registration and URL extraction. |
| 3 | */ |
| 4 | import { describe, it } from 'node:test'; |
| 5 | import assert from 'node:assert'; |
| 6 | import { extractVideoUrls } from '../lib/media-url-extract.mjs'; |
| 7 | |
| 8 | describe('video resource listing structure', () => { |
| 9 | it('extracts videos with correct structure for resource listing', () => { |
| 10 | const body = 'Watch this:\nhttps://example.com/demo.mp4\n\nAlso:\nhttps://example.com/intro.webm'; |
| 11 | const videos = extractVideoUrls(body); |
| 12 | assert.strictEqual(videos.length, 2); |
| 13 | assert.strictEqual(videos[0].url, 'https://example.com/demo.mp4'); |
| 14 | assert.strictEqual(videos[0].mimeType, 'video/mp4'); |
| 15 | assert.strictEqual(videos[1].url, 'https://example.com/intro.webm'); |
| 16 | assert.strictEqual(videos[1].mimeType, 'video/webm'); |
| 17 | }); |
| 18 | |
| 19 | it('resource URI format is correct', () => { |
| 20 | const notePath = 'projects/demo/notes/recording.md'; |
| 21 | const index = 1; |
| 22 | const uri = `knowtation://vault/${notePath}/video/${index}`; |
| 23 | assert.strictEqual(uri, 'knowtation://vault/projects/demo/notes/recording.md/video/1'); |
| 24 | }); |
| 25 | |
| 26 | it('video read returns text content (URL) not blob', () => { |
| 27 | const videos = extractVideoUrls('https://example.com/clip.mp4'); |
| 28 | assert.strictEqual(videos.length, 1); |
| 29 | const vid = videos[0]; |
| 30 | const responseContent = { |
| 31 | uri: 'knowtation://vault/test.md/video/0', |
| 32 | mimeType: vid.mimeType, |
| 33 | text: vid.url, |
| 34 | }; |
| 35 | assert.strictEqual(responseContent.mimeType, 'video/mp4'); |
| 36 | assert.strictEqual(responseContent.text, 'https://example.com/clip.mp4'); |
| 37 | assert.ok(!responseContent.blob, 'Video resources should not include blob data'); |
| 38 | }); |
| 39 | |
| 40 | it('handles .mov as video/quicktime', () => { |
| 41 | const videos = extractVideoUrls('https://example.com/meeting.mov'); |
| 42 | assert.strictEqual(videos.length, 1); |
| 43 | assert.strictEqual(videos[0].mimeType, 'video/quicktime'); |
| 44 | }); |
| 45 | |
| 46 | it('index out of range is detectable', () => { |
| 47 | const videos = extractVideoUrls('https://example.com/clip.mp4'); |
| 48 | assert.strictEqual(videos.length, 1); |
| 49 | const oobIndex = 3; |
| 50 | assert.ok(oobIndex >= videos.length); |
| 51 | }); |
| 52 | |
| 53 | it('no videos returns empty list', () => { |
| 54 | const videos = extractVideoUrls('Just text and '); |
| 55 | assert.strictEqual(videos.length, 0); |
| 56 | }); |
| 57 | |
| 58 | it('video inside markdown image syntax is still extracted', () => { |
| 59 | const videos = extractVideoUrls(''); |
| 60 | assert.strictEqual(videos.length, 1); |
| 61 | assert.strictEqual(videos[0].mimeType, 'video/mp4'); |
| 62 | }); |
| 63 | }); |
File History
2 commits
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠
1 day ago
sha256:9103f98c89257ed2b01c237cea895dabb3e85ea337dccb1161c175e4422355b6
docs: accept Calendar Events v0 spec with Phase 0 security …
Human
1 day ago