UNPKG

@nestjsvn/swagger-sse

Version:

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

67 lines (66 loc) 3.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const setup_1 = require("./setup"); const test_controllers_1 = require("./test-controllers"); describe('Click Method Diagnostic', () => { let context; beforeAll(async () => { context = await setup_1.E2ETestSetup.createContext('click-method-diagnostic', { controllers: [test_controllers_1.TestEventsController], }); }); afterAll(async () => { await setup_1.E2ETestSetup.cleanup('click-method-diagnostic'); }); it('should compare different click methods', async () => { await context.page.goto(`${context.baseUrl}/api-docs`); await context.page.waitForSelector('.swagger-ui', { timeout: 10000 }); console.log('=== Testing page.click() method ==='); // Method 1: Use page.click() like the working expansion diagnostic await context.page.click('.opblock .opblock-summary'); await context.page.waitForTimeout(2000); // Give more time const afterPageClick = await context.page.evaluate(() => { const pathElement = document.querySelector('[data-path="/test-events/basic"]'); const opblock = pathElement?.closest('.opblock'); return { isExpanded: opblock?.classList.contains('is-open'), hasExecuteWrapper: !!opblock?.querySelector('.execute-wrapper'), hasExecuteBtn: !!opblock?.querySelector('.btn.execute'), allButtons: Array.from(opblock?.querySelectorAll('button') ?? []).map(btn => ({ className: btn.className, textContent: btn.textContent?.trim() ?? '', })), }; }); console.log('After page.click():', JSON.stringify(afterPageClick, null, 2)); // Refresh page for second test await context.page.reload(); await context.page.waitForSelector('.swagger-ui', { timeout: 10000 }); console.log('=== Testing page.evaluate() method ==='); // Method 2: Use page.evaluate() like the failing test await context.page.evaluate(() => { const pathElement = document.querySelector('[data-path="/test-events/basic"]'); const opblockSummary = pathElement?.closest('.opblock')?.querySelector('.opblock-summary'); if (opblockSummary) { opblockSummary.click(); } }); await context.page.waitForTimeout(2000); // Give more time const afterEvaluateClick = await context.page.evaluate(() => { const pathElement = document.querySelector('[data-path="/test-events/basic"]'); const opblock = pathElement?.closest('.opblock'); return { isExpanded: opblock?.classList.contains('is-open'), hasExecuteWrapper: !!opblock?.querySelector('.execute-wrapper'), hasExecuteBtn: !!opblock?.querySelector('.btn.execute'), allButtons: Array.from(opblock?.querySelectorAll('button') ?? []).map(btn => ({ className: btn.className, textContent: btn.textContent?.trim() ?? '', })), }; }); console.log('After page.evaluate():', JSON.stringify(afterEvaluateClick, null, 2)); // This test always passes - it's just for diagnostics expect(true).toBe(true); }); });