| import { test, expect } from '@playwright/test'; |
|
|
| test('should transcribe and analyze a video URL', async ({ page }) => { |
| |
| await page.route('**/api/transcribe', async route => { |
| |
| await new Promise(resolve => setTimeout(resolve, 500)); |
| route.fulfill({ |
| status: 200, |
| contentType: 'application/json', |
| body: JSON.stringify({ transcript: 'This is a test transcript.' }), |
| }); |
| }); |
|
|
| |
| 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 => { |
| |
| 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'], |
| }), |
| }, |
| ], |
| }, |
| }, |
| ], |
| }), |
| }); |
| }); |
|
|
| |
| await page.goto('/'); |
|
|
| |
| await page.fill('#urlInput', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'); |
| await page.click('#analyzeBtn'); |
|
|
| |
| await expect(page.locator('#loadingSection')).toBeVisible(); |
| await expect(page.locator('#loadingText')).toHaveText('Transcribing audio...'); |
| await expect(page.locator('#loadingSection')).toBeHidden(); |
|
|
| |
| await expect(page.locator('#transcriptSection')).toBeVisible(); |
| await expect(page.locator('#transcriptContent')).toHaveText('This is a test transcript.'); |
|
|
| |
| 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'); |
| }); |
|
|