mcp-video-resources.test.mjs
63 lines 2.5 KB
Raw
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor ⚠ breaking 12 days 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 ![img](https://ex.com/img.png)');
55 assert.strictEqual(videos.length, 0);
56 });
57
58 it('video inside markdown image syntax is still extracted', () => {
59 const videos = extractVideoUrls('![demo](https://ex.com/demo.mp4)');
60 assert.strictEqual(videos.length, 1);
61 assert.strictEqual(videos[0].mimeType, 'video/mp4');
62 });
63 });
File History 4 commits
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor 12 days ago
sha256:d8c648b20a4d53b2673c5c082ee7edfa7b2fc9b11080832da1f38807b6bf940b fix(7C-L1b): route hosted delegation proposals through cani… Human minor 32 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91 fix: repair endpoint now sets has_active_subscription when … Human minor 51 days ago