@nestjsvn/swagger-sse
Version:
OpenAPI documentation and interactive Swagger UI for NestJS Server-Sent Events endpoints
75 lines (74 loc) • 4.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const setup_1 = require("./setup");
const test_controllers_1 = require("./test-controllers");
describe('SSE Plugin Activation Diagnostic', () => {
let context;
beforeAll(async () => {
context = await setup_1.E2ETestSetup.createContext('sse-plugin-activation-diagnostic', {
controllers: [test_controllers_1.TestEventsController],
});
});
afterAll(async () => {
await setup_1.E2ETestSetup.cleanup('sse-plugin-activation-diagnostic');
});
it('should debug SSE plugin activation after Execute click', async () => {
await context.page.goto(`${context.baseUrl}/api-docs`);
await context.page.waitForSelector('.swagger-ui', { timeout: 10000 });
console.log('=== Step 1: Expand endpoint ===');
await context.page.click('.opblock .opblock-summary');
await context.page.waitForTimeout(1000);
console.log('=== Step 2: Click Try it out ===');
await context.page.waitForSelector('.btn.try-out__btn', { timeout: 5000 });
await context.page.click('.btn.try-out__btn');
await context.page.waitForTimeout(1000);
console.log('=== Step 3: Check Execute button ===');
const executeButtonExists = await context.page.$('.execute-wrapper .btn.execute');
console.log('Execute button exists:', !!executeButtonExists);
if (executeButtonExists) {
const executeButtonText = await executeButtonExists.textContent();
console.log('Execute button text:', executeButtonText);
console.log('=== Step 4: Click Execute ===');
await context.page.click('.execute-wrapper .btn.execute');
await context.page.waitForTimeout(2000); // Give more time for SSE plugin
console.log('=== Step 5: Check for SSE plugin activation ===');
// 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"]'),
// Check if SSE plugin script is loaded
hasSSEPlugin: typeof window.isSseEndpoint === 'function',
// Check current URL path
currentPath: window.location.pathname,
// Check if this endpoint matches SSE patterns
endpointPath: '/test-events/basic',
};
});
console.log('SSE Elements check:', JSON.stringify(sseElements, null, 2));
// Check if the SSE plugin function recognizes this as an SSE endpoint
const sseEndpointCheck = await context.page.evaluate(() => {
if (typeof window.isSseEndpoint === 'function') {
return {
isSSE: window.isSseEndpoint('/test-events/basic'),
patterns: window.ssePatterns || 'not available',
};
}
return { error: 'isSseEndpoint function not found' };
});
console.log('SSE endpoint check:', JSON.stringify(sseEndpointCheck, null, 2));
// Check the response section for any SSE-related content
const responseSection = await context.page.evaluate(() => {
const responseDiv = document.querySelector('.responses-wrapper');
return {
hasResponseWrapper: !!responseDiv,
responseHTML: responseDiv?.innerHTML?.substring(0, 500) || 'not found',
};
});
console.log('Response section:', JSON.stringify(responseSection, null, 2));
}
// This test always passes - it's just for diagnostics
expect(true).toBe(true);
});
});