UNPKG

@nestjsvn/swagger-sse

Version:

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

66 lines (65 loc) 3.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const setup_1 = require("./setup"); const test_controllers_1 = require("./test-controllers"); describe('E2E Diagnostic Tests', () => { let context; beforeAll(async () => { context = await setup_1.E2ETestSetup.createContext('diagnostic', { controllers: [test_controllers_1.TestEventsController], }); }); afterAll(async () => { await setup_1.E2ETestSetup.cleanup('diagnostic'); }); it('should diagnose Swagger UI structure', async () => { await context.page.goto(`${context.baseUrl}/api-docs`); // Wait for Swagger UI to load await context.page.waitForSelector('.swagger-ui', { timeout: 10000 }); // Log the page title const title = await context.page.title(); console.log('Page title:', title); // Check if any endpoints are present const allEndpoints = await context.page.$$('.opblock'); console.log('Total endpoints found:', allEndpoints.length); // Check for test-events related elements const testEventsElements = await context.page.$$('[data-tag*="test"]'); console.log('Test-events elements found:', testEventsElements.length); // Check for any data-tag attributes const allTags = await context.page.evaluate(() => { const elements = Array.from(document.querySelectorAll('[data-tag]')); return elements.map(el => el.getAttribute('data-tag')); }); console.log('All data-tag values:', allTags); // Check for any data-path attributes const allPaths = await context.page.evaluate(() => { const elements = Array.from(document.querySelectorAll('[data-path]')); return elements.map(el => el.getAttribute('data-path')); }); console.log('All data-path values:', allPaths); // Check if SSE plugin elements exist const sseElements = await context.page.evaluate(() => { return { connectBtn: !!document.querySelector('[data-testid="sse-connect-btn"]'), status: !!document.querySelector('[data-testid="sse-status"]'), eventLog: !!document.querySelector('[data-testid="sse-event-log"]'), anySSE: document.querySelectorAll('[data-testid*="sse"]').length, }; }); console.log('SSE plugin elements:', sseElements); // Get the full HTML structure for analysis const swaggerContent = await context.page.$eval('.swagger-ui', el => el.innerHTML); console.log('Swagger UI content length:', swaggerContent.length); // Check for script tags that might load the SSE plugin const scripts = await context.page.evaluate(() => { const scriptTags = Array.from(document.querySelectorAll('script')); return scriptTags.map(script => ({ src: script.src, hasSSE: (script.textContent?.includes('sse') ?? false) || (script.src?.includes('sse') ?? false), })); }); console.log('Scripts with SSE:', scripts.filter(s => s.hasSSE)); // This test always passes - it's just for diagnostics expect(true).toBe(true); }); });