UNPKG

@nestjsvn/swagger-sse

Version:

OpenAPI documentation and interactive Swagger UI for NestJS Server-Sent Events endpoints

110 lines (109 loc) 6.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const setup_1 = require("./setup"); const test_controllers_1 = require("./test-controllers"); describe('Execute Flow Diagnostic E2E Test', () => { let context; beforeAll(async () => { context = await setup_1.E2ETestSetup.createContext('execute-flow-diagnostic', { controllers: [test_controllers_1.TestEventsController, test_controllers_1.MobileTestController], }); }); afterAll(async () => { await setup_1.E2ETestSetup.cleanup('execute-flow-diagnostic'); }); it('should diagnose the complete execute flow', async () => { console.log('=== EXECUTE FLOW DIAGNOSTIC START ==='); // Navigate to Swagger UI await context.page.goto(`${context.baseUrl}/api-docs`); await context.page.waitForSelector('.swagger-ui', { timeout: 10000 }); console.log('1. Swagger UI loaded'); // Click on the basic endpoint console.log('2. Clicking on basic endpoint...'); await context.page.click('[data-path="/test-events/basic"]'); await context.page.waitForTimeout(1000); console.log('3. Basic endpoint clicked'); // Take screenshot after endpoint click await context.page.screenshot({ path: 'after-endpoint-click.png', fullPage: true }); console.log('4. Screenshot taken: after-endpoint-click.png'); // Check for Try it out button const tryItOutBtn = await context.page.$('.btn.try-out__btn'); console.log('5. Try it out button found:', !!tryItOutBtn); if (tryItOutBtn) { const isVisible = await tryItOutBtn.isVisible(); console.log('6. Try it out button visible:', isVisible); if (isVisible) { console.log('7. Clicking Try it out button...'); await context.page.click('.btn.try-out__btn'); await context.page.waitForTimeout(1000); console.log('8. Try it out button clicked'); // Take screenshot after try it out click await context.page.screenshot({ path: 'after-try-it-out.png', fullPage: true }); console.log('9. Screenshot taken: after-try-it-out.png'); // Check for Execute button const executeBtn = await context.page.$('.execute-wrapper .btn.execute'); console.log('10. Execute button found:', !!executeBtn); if (executeBtn) { const isVisible = await executeBtn.isVisible(); console.log('11. Execute button visible:', isVisible); if (isVisible) { console.log('12. Clicking Execute button...'); await context.page.click('.execute-wrapper .btn.execute'); console.log('13. Execute button clicked'); // Wait longer and take screenshot await context.page.waitForTimeout(3000); await context.page.screenshot({ path: 'after-execute-click.png', fullPage: true }); console.log('14. Screenshot taken: after-execute-click.png'); // Check what happened in the response area const responseArea = await context.page.$('.responses-wrapper'); console.log('15. Response area found:', !!responseArea); if (responseArea) { const responseHTML = await responseArea.innerHTML(); console.log('16. Response area HTML (first 500 chars):'); console.log(responseHTML.substring(0, 500)); } // Check for any SSE-related elements const sseElements = await context.page.$$('[data-testid*="sse"]'); console.log('17. SSE elements found:', sseElements.length); // Check for any elements with "sse" in their class or id const sseRelatedElements = await context.page.$$eval('*', elements => elements.filter(el => (typeof el.className === 'string' && el.className.toLowerCase().includes('sse')) || (typeof el.id === 'string' && el.id.toLowerCase().includes('sse')) || (el.textContent && el.textContent.toLowerCase().includes('sse'))).map(el => ({ tagName: el.tagName, className: typeof el.className === 'string' ? el.className : '', id: typeof el.id === 'string' ? el.id : '', textContent: el.textContent?.substring(0, 50) }))); console.log('18. SSE-related elements:'); console.log(JSON.stringify(sseRelatedElements, null, 2)); // Check console logs for any errors const consoleLogs = await context.page.evaluate(() => { return window.testConsoleLogs || []; }); console.log('19. Console logs:', consoleLogs); // Check if the SSE plugin script is loaded const ssePluginLoaded = await context.page.evaluate(() => { return typeof window.ssePlugin !== 'undefined' || document.querySelector('script[src*="sse-plugin"]') !== null; }); console.log('20. SSE plugin loaded:', ssePluginLoaded); // Check if the endpoint is recognized as SSE const endpointInfo = await context.page.evaluate(() => { const pathElement = document.querySelector('[data-path="/test-events/basic"]'); return { exists: !!pathElement, innerHTML: pathElement?.innerHTML, parentElement: pathElement?.parentElement?.tagName, parentClass: pathElement?.parentElement?.className }; }); console.log('21. Endpoint info:'); console.log(JSON.stringify(endpointInfo, null, 2)); } } } } console.log('=== EXECUTE FLOW DIAGNOSTIC END ==='); expect(true).toBe(true); }, 60000); });