UNPKG

@nestjsvn/swagger-sse

Version:

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

57 lines (56 loc) 2.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const setup_1 = require("./setup"); const test_controllers_1 = require("./test-controllers"); describe('Static Assets Diagnostic', () => { let context; beforeAll(async () => { context = await setup_1.E2ETestSetup.createContext('static-assets-diagnostic', { controllers: [test_controllers_1.TestEventsController], }); }); afterAll(async () => { await setup_1.E2ETestSetup.cleanup('static-assets-diagnostic'); }); it('should check if SSE plugin assets are served correctly', async () => { console.log('=== Testing static asset serving ==='); // Test if the SSE plugin JavaScript file is accessible const jsResponse = await context.page.goto(`${context.baseUrl}/swagger-sse-assets/sse-plugin.js`); console.log('SSE Plugin JS Response Status:', jsResponse?.status()); if (jsResponse?.status() === 200) { const jsContent = await jsResponse.text(); console.log('SSE Plugin JS Content Length:', jsContent.length); console.log('Has isSseEndpoint function:', jsContent.includes('isSseEndpoint')); console.log('First 200 chars:', jsContent.substring(0, 200)); } else { console.log('SSE Plugin JS file not found or error'); } // Test if the CSS file is accessible const cssResponse = await context.page.goto(`${context.baseUrl}/swagger-sse-assets/sse-plugin.css`); console.log('SSE Plugin CSS Response Status:', cssResponse?.status()); // Test the main Swagger UI page await context.page.goto(`${context.baseUrl}/api-docs`); await context.page.waitForSelector('.swagger-ui', { timeout: 10000 }); // Check if the script tags are present in the HTML const scriptTags = await context.page.evaluate(() => { const scripts = Array.from(document.querySelectorAll('script')); return scripts.map(script => ({ src: script.src, hasSSEPlugin: script.src.includes('sse-plugin.js'), })); }); console.log('Script tags:', JSON.stringify(scriptTags, null, 2)); // Check if the SSE plugin script was loaded and executed const windowCheck = await context.page.evaluate(() => { return { hasIsSseEndpoint: typeof window.isSseEndpoint === 'function', hasSSEPatterns: !!window.ssePatterns, windowKeys: Object.keys(window).filter(key => key.toLowerCase().includes('sse')), }; }); console.log('Window check:', JSON.stringify(windowCheck, null, 2)); // This test always passes - it's just for diagnostics expect(true).toBe(true); }); });