@nestjsvn/swagger-sse
Version:
OpenAPI documentation and interactive Swagger UI for NestJS Server-Sent Events endpoints
85 lines (84 loc) • 4.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const setup_1 = require("./setup");
const test_controllers_1 = require("./test-controllers");
describe('Execute Button Diagnostic', () => {
let context;
beforeAll(async () => {
context = await setup_1.E2ETestSetup.createContext('execute-button-diagnostic', {
controllers: [test_controllers_1.TestEventsController],
});
});
afterAll(async () => {
await setup_1.E2ETestSetup.cleanup('execute-button-diagnostic');
});
it('should find the correct execute button selector', async () => {
await context.page.goto(`${context.baseUrl}/api-docs`);
await context.page.waitForSelector('.swagger-ui', { timeout: 10000 });
// Expand the endpoint using 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();
}
});
// Wait a moment for expansion
await context.page.waitForTimeout(1000);
// Check what execute-related elements exist
const executeElements = await context.page.evaluate(() => {
const pathElement = document.querySelector('[data-path="/test-events/basic"]');
const opblock = pathElement?.closest('.opblock');
// Find all elements containing "execute" in class or text
const allElements = Array.from(opblock?.querySelectorAll('*') || []);
const executeRelated = allElements.filter(el => {
const className = el.className?.toString?.() || '';
const textContent = el.textContent?.toLowerCase() || '';
return className.includes('execute') || textContent.includes('execute');
});
return {
hasExecuteWrapper: !!opblock?.querySelector('.execute-wrapper'),
hasExecuteBtn: !!opblock?.querySelector('.btn.execute'),
hasExecuteWrapperBtn: !!opblock?.querySelector('.execute-wrapper .btn.execute'),
executeRelatedElements: executeRelated.map(el => ({
tagName: el.tagName,
className: el.className?.toString?.() || '',
textContent: el.textContent?.trim() || '',
id: el.id || '',
})),
allButtons: Array.from(opblock?.querySelectorAll('button') || []).map(btn => ({
className: btn.className,
textContent: btn.textContent?.trim() || '',
id: btn.id || '',
})),
};
});
console.log('Execute elements analysis:', JSON.stringify(executeElements, null, 2));
// Try different selectors to see which ones work
const selectors = [
'.execute-wrapper .btn.execute',
'.btn.execute',
'button.execute',
'.execute-wrapper button',
'.opblock-body button',
'button[class*="execute"]',
'button:contains("Execute")',
];
for (const selector of selectors) {
try {
const element = await context.page.$(selector);
console.log(`Selector "${selector}": ${element ? 'FOUND' : 'NOT FOUND'}`);
if (element) {
const text = await element.textContent();
const className = await element.getAttribute('class');
console.log(` - Text: "${text}", Class: "${className}"`);
}
}
catch (error) {
console.log(`Selector "${selector}": ERROR - ${error.message}`);
}
}
// This test always passes - it's just for diagnostics
expect(true).toBe(true);
});
});