const { callTool, ensureServer } = require('../helpers');
describe('get_youtube_transcript', () => {
beforeAll(async () => {
if (!process.env.BYPASS_AUTH_FOR_TESTS) {
throw new Error('BYPASS_AUTH_FOR_TESTS is not set. Set it in your .env to run tests.');
}
await ensureServer();
}, 60000);
test('returns timestamped segments', async () => {
const resp = await callTool('get_youtube_transcript', { videoId: 'dQw4w9WgXcQ' });
if (resp.error) throw new Error(resp.error.message);
const arr = JSON.parse(resp.result?.content?.[0]?.text || 'null');
expect(Array.isArray(arr)).toBe(true);
expect(arr.length).toBeGreaterThan(0);
// Check that segments have text and timing information
const seg = arr[0];
expect(typeof seg.text).toBe('string');
expect(seg.text.length).toBeGreaterThan(0);
// Check that timing information is present
const hasTimestamp = (typeof seg.startMs === 'number') ||
(typeof seg.startSeconds === 'number') ||
(typeof seg.start === 'string');
expect(hasTimestamp).toBe(true);
}, 60000);
});