From ee5cd575bf134b2c2127f4b5da12b415eff1f92b Mon Sep 17 00:00:00 2001 From: Egor Mikheev Date: Tue, 25 Nov 2025 07:16:40 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D1=81=D0=BA=D1=80?= =?UTF-8?q?=D0=B5=D0=B9=D0=BF=D1=82=D0=B8=D0=BD=D0=B3=D0=B0=20=D0=BC=D0=B5?= =?UTF-8?q?=D0=B4=D0=B8=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/backend/src/tests/e2e/scraper.test.ts | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 apps/backend/src/tests/e2e/scraper.test.ts diff --git a/apps/backend/src/tests/e2e/scraper.test.ts b/apps/backend/src/tests/e2e/scraper.test.ts new file mode 100644 index 0000000..22c14c6 --- /dev/null +++ b/apps/backend/src/tests/e2e/scraper.test.ts @@ -0,0 +1,88 @@ +// apps/backend/src/tests/e2e/scraper.test.ts +// Path: apps/backend/src/tests/e2e/scraper.test.ts + +import { describe, expect, test, beforeAll } from 'bun:test'; + +describe('E2E: Scraper Integration', () => { + let authCookie: string; + + beforeAll(async () => { + const signUpResponse = await fetch('http://localhost:3000/auth/api/sign-up/email', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + name: 'Scraper Test User', + email: `scraper-test-${Date.now()}@example.com`, + password: 'TestPassword123!', + }), + }); + + authCookie = signUpResponse.headers.get('set-cookie') || ''; + }); + + test('should save from direct image URL', async () => { + const response = await fetch('http://localhost:3000/saves/external', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Cookie': authCookie, + }, + body: JSON.stringify({ + url: 'https://mrqiz.ru/', + name: 'Direct Image Test', + visibility: 'public', + }), + }); + + expect(response.status).toBe(200); + + const data = await response.json(); + expect(data.type).toBe('image'); + expect(data.name).toBe('Direct Image Test'); + }); + + // Эти тесты требуют реальных URL + test.skip('should save from Pinterest URL (manual test)', async () => { + // Замените на актуальный Pinterest URL + const pinterestUrl = 'https://www.pinterest.com/pin/ACTUAL_PIN_ID/'; + + const response = await fetch('http://localhost:3000/saves/external', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Cookie': authCookie, + }, + body: JSON.stringify({ + url: pinterestUrl, + visibility: 'link', + }), + }); + + expect(response.status).toBe(200); + + const data = await response.json(); + expect(['image', 'video', 'gif']).toContain(data.type); + }); + + test.skip('should save from Tenor GIF (manual test)', async () => { + // Замените на актуальный Tenor URL + const tenorUrl = 'https://tenor.com/view/ACTUAL_GIF_ID'; + + const response = await fetch('http://localhost:3000/saves/external', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Cookie': authCookie, + }, + body: JSON.stringify({ + url: tenorUrl, + visibility: 'link', + }), + }); + + expect(response.status).toBe(200); + + const data = await response.json(); + expect(data.type).toBe('gif'); + }); +});