videoscriber-backend / tests /e2e.spec.js
Rimas Kavaliauskas
Switch Space to Docker backend and sync Videoscriber post-processing
6782be3
import { test, expect } from '@playwright/test';
test('should transcribe and analyze a video URL', async ({ page }) => {
// Mock the API responses
await page.route('**/api/transcribe', async route => {
// Simulate network delay
await new Promise(resolve => setTimeout(resolve, 500));
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ transcript: 'This is a test transcript.' }),
});
});
// App loads archive inbox on startup; keep test isolated from local API proxy.
await page.route('**/api/archive/list**', async route => {
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ items: [], next_cursor: null }),
});
});
await page.route('**/v1beta/models/*:generateContent**', async route => {
// Simulate network delay
await new Promise(resolve => setTimeout(resolve, 500));
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
candidates: [
{
content: {
parts: [
{
text: JSON.stringify({
summary: 'This is a test summary.',
keyPoints: ['Point 1', 'Point 2', 'Point 3'],
}),
},
],
},
},
],
}),
});
});
// Navigate to the app
await page.goto('/');
// Input a URL and click the analyze button
await page.fill('#urlInput', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ');
await page.click('#analyzeBtn');
// Wait for the loading indicators to appear and disappear
await expect(page.locator('#loadingSection')).toBeVisible();
await expect(page.locator('#loadingText')).toHaveText('Transcribing audio...');
await expect(page.locator('#loadingSection')).toBeHidden();
// Check for the transcript
await expect(page.locator('#transcriptSection')).toBeVisible();
await expect(page.locator('#transcriptContent')).toHaveText('This is a test transcript.');
// Check for the analysis
await expect(page.locator('#analysisSection')).toBeVisible();
await expect(page.locator('#descriptionContent')).toHaveText('This is a test summary.');
await expect(page.locator('#keyPointsList li')).toHaveCount(3);
await expect(page.locator('#keyPointsList li').nth(0)).toHaveText('Point 1');
await expect(page.locator('#keyPointsList li').nth(1)).toHaveText('Point 2');
await expect(page.locator('#keyPointsList li').nth(2)).toHaveText('Point 3');
});