simplify
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Integration tests for SSE extraction endpoint
|
||||
*
|
||||
*
|
||||
* Tests the real-time progress streaming from extraction to frontend
|
||||
*/
|
||||
|
||||
@@ -11,31 +11,31 @@ describe('SSE Extraction Endpoint', () => {
|
||||
it('should stream progress events for successful extraction', async () => {
|
||||
// Mock Instagram URL (would need real URL for full e2e test)
|
||||
const testUrl = 'https://www.instagram.com/p/test123/';
|
||||
|
||||
|
||||
const events: ProgressEvent[] = [];
|
||||
|
||||
|
||||
// Note: This is a structure test. Real testing requires:
|
||||
// 1. Running server
|
||||
// 2. Valid Instagram URL
|
||||
// 3. Browser context available
|
||||
|
||||
|
||||
// Expected event flow
|
||||
const expectedEventTypes = [
|
||||
'status', // Starting extraction
|
||||
'status', // Loading page
|
||||
'method', // Trying first method
|
||||
'status', // Success or next method
|
||||
'status', // Parsing recipe
|
||||
'complete' // Final result
|
||||
'status', // Starting extraction
|
||||
'status', // Loading page
|
||||
'method', // Trying first method
|
||||
'status', // Success or next method
|
||||
'status', // Parsing recipe
|
||||
'complete' // Final result
|
||||
];
|
||||
|
||||
|
||||
expect(expectedEventTypes).toBeDefined();
|
||||
});
|
||||
|
||||
it('should handle errors gracefully', async () => {
|
||||
// Test with invalid URL
|
||||
const invalidUrl = 'not-a-valid-url';
|
||||
|
||||
|
||||
// Expected: error event should be sent
|
||||
expect(invalidUrl).toBeTruthy();
|
||||
});
|
||||
@@ -92,14 +92,14 @@ describe('SSE Extraction Endpoint', () => {
|
||||
describe('Frontend SSE Parser', () => {
|
||||
it('should parse SSE event format correctly', () => {
|
||||
const sseMessage = 'event: progress\ndata: {"type":"status","message":"test"}\n\n';
|
||||
|
||||
|
||||
const eventMatch = sseMessage.match(/^event: (\w+)\ndata: (.+)$/s);
|
||||
|
||||
|
||||
expect(eventMatch).toBeTruthy();
|
||||
if (eventMatch) {
|
||||
const [, eventType, eventData] = eventMatch;
|
||||
expect(eventType).toBe('progress');
|
||||
|
||||
|
||||
const parsed = JSON.parse(eventData.replace(/\n\n$/, ''));
|
||||
expect(parsed.type).toBe('status');
|
||||
expect(parsed.message).toBe('test');
|
||||
@@ -112,7 +112,7 @@ describe('Frontend SSE Parser', () => {
|
||||
'embedded-json': '📦',
|
||||
'dom-selector': '🎯',
|
||||
'graphql-api': '🔌',
|
||||
'legacy': '📄'
|
||||
legacy: '📄'
|
||||
};
|
||||
return method ? icons[method] || '⚙️' : '⚙️';
|
||||
};
|
||||
@@ -128,7 +128,7 @@ describe('Frontend SSE Parser', () => {
|
||||
|
||||
/**
|
||||
* Manual E2E Testing Checklist:
|
||||
*
|
||||
*
|
||||
* □ Start dev server: npm run dev
|
||||
* □ Open /share?url=<instagram-url>
|
||||
* □ Click "Extract Recipe"
|
||||
|
||||
Reference in New Issue
Block a user