UNPKG

@nestjsvn/swagger-sse

Version:

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

92 lines (91 loc) 5.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const setup_1 = require("./setup"); const test_controllers_1 = require("./test-controllers"); describe('Click Diagnostic E2E Test', () => { let context; beforeAll(async () => { context = await setup_1.E2ETestSetup.createContext('click-diagnostic', { controllers: [test_controllers_1.TestEventsController, test_controllers_1.MobileTestController], }); }); afterAll(async () => { await setup_1.E2ETestSetup.cleanup('click-diagnostic'); }); it('should diagnose click issues step by step', async () => { console.log('=== DIAGNOSTIC TEST START ==='); // Navigate to Swagger UI await context.page.goto(`${context.baseUrl}/api-docs`); console.log('1. Navigated to Swagger UI'); // Wait for Swagger UI to load await context.page.waitForSelector('.swagger-ui', { timeout: 10000 }); console.log('2. Swagger UI loaded'); // Take a screenshot to see the current state await context.page.screenshot({ path: 'swagger-ui-loaded.png', fullPage: true }); console.log('3. Screenshot taken: swagger-ui-loaded.png'); // Check what endpoints are available const allEndpoints = await context.page.$$eval('[data-path]', elements => elements.map(el => el.getAttribute('data-path'))); console.log('4. Available endpoints:', allEndpoints); // Check if our specific endpoint exists const basicEndpoint = await context.page.$('[data-path="/test-events/basic"]'); console.log('5. Basic endpoint found:', !!basicEndpoint); if (basicEndpoint) { // Check if it's visible and clickable const isVisible = await basicEndpoint.isVisible(); const boundingBox = await basicEndpoint.boundingBox(); console.log('6. Basic endpoint visible:', isVisible); console.log('7. Basic endpoint bounding box:', boundingBox); // Try to click on the endpoint console.log('8. Attempting to click on basic endpoint...'); await context.page.click('[data-path="/test-events/basic"] .opblock-summary'); console.log('9. Clicked on basic endpoint'); // Wait a moment and take another screenshot await context.page.waitForTimeout(2000); await context.page.screenshot({ path: 'after-endpoint-click.png', fullPage: true }); console.log('10. Screenshot taken: after-endpoint-click.png'); // Check if "Try it out" button appeared const tryItOutBtn = await context.page.$('.btn.try-out__btn'); console.log('11. Try it out button found:', !!tryItOutBtn); if (tryItOutBtn) { const isVisible = await tryItOutBtn.isVisible(); console.log('12. Try it out button visible:', isVisible); if (isVisible) { console.log('13. Attempting to click Try it out button...'); await context.page.click('.btn.try-out__btn'); console.log('14. Clicked Try it out button'); // Wait and take screenshot await context.page.waitForTimeout(2000); await context.page.screenshot({ path: 'after-try-it-out-click.png', fullPage: true }); console.log('15. Screenshot taken: after-try-it-out-click.png'); // Check for Execute button const executeBtn = await context.page.$('.execute-wrapper .btn.execute'); console.log('16. Execute button found:', !!executeBtn); if (executeBtn) { const isVisible = await executeBtn.isVisible(); console.log('17. Execute button visible:', isVisible); if (isVisible) { console.log('18. Attempting to click Execute button...'); await context.page.click('.execute-wrapper .btn.execute'); console.log('19. Clicked Execute button'); // Wait and take final screenshot await context.page.waitForTimeout(5000); await context.page.screenshot({ path: 'after-execute-click.png', fullPage: true }); console.log('20. Screenshot taken: after-execute-click.png'); // Check for SSE UI elements const sseConnectBtn = await context.page.$('[data-testid="sse-connect-btn"]'); console.log('21. SSE Connect button found:', !!sseConnectBtn); // Check for any console errors const logs = await context.page.evaluate(() => { return window.consoleErrors || []; }); console.log('22. Console errors:', logs); } } } } } console.log('=== DIAGNOSTIC TEST END ==='); // Always pass this test - it's just for diagnostics expect(true).toBe(true); }, 60000); // 60 second timeout });