This commit is contained in:
Giancarmine Salucci
2026-02-18 01:21:44 +01:00
parent 54321fd7c9
commit 49bccf8f15
84 changed files with 14474 additions and 13925 deletions

View File

@@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest';
/**
* Integration tests for thumbnail URL validation in the complete extraction flow
*
*
* These tests verify that URL validation works correctly in realistic scenarios:
* - Complete extraction flow with failing URLs falls back to screenshot
* - Valid URLs are successfully fetched and used
@@ -184,21 +184,21 @@ describe('Thumbnail URL Validation Integration', () => {
/**
* Example of how integration tests could be structured with real mocking:
*
*
* import { chromium } from 'playwright';
* import { extractTextAndThumbnail } from '$lib/server/extraction';
*
*
* it('should validate URL and fall back', async () => {
* const browser = await chromium.launch();
* const context = await browser.newContext();
* const page = await context.newPage();
*
*
* // Mock the page content
* await page.setContent(`
* <meta property="og:image" content="https://example.com/invalid.jpg">
* <video poster="https://example.com/also-invalid.jpg"></video>
* `);
*
*
* // Mock fetch to return 404 for these URLs
* await page.route('**\/*', route => {
* if (route.request().url().includes('invalid.jpg')) {
@@ -207,23 +207,23 @@ describe('Thumbnail URL Validation Integration', () => {
* route.continue();
* }
* });
*
*
* const progressEvents = [];
* const result = await extractTextAndThumbnail(
* 'https://instagram.com/p/test',
* (event) => progressEvents.push(event)
* );
*
*
* // Verify screenshot fallback was used
* expect(result.thumbnail).toMatch(/^data:image\/jpeg;base64,/);
*
*
* // Verify progress events show URL validation failures
* expect(progressEvents).toContainEqual(
* expect.objectContaining({
* message: expect.stringContaining('HTTP 404')
* })
* );
*
*
* await browser.close();
* });
*/