// Integration Test Script for NestedTabs Implementation
// This script tests all major features to ensure they work correctly
const puppeteer = require('puppeteer');
async function runIntegrationTests() {
console.log('π§ͺ Starting integration tests for NestedTabs implementation...\n');
const browser = await puppeteer.launch({
headless: false, // Set to true for CI/CD
devtools: true
});
const page = await browser.newPage();
try {
// Navigate to the app
await page.goto('http://localhost:9999');
await page.waitForSelector('.app', { timeout: 5000 });
console.log('β
App loaded successfully');
// Test 1: URL Synchronization
console.log('\nπ Testing URL synchronization...');
// Check initial URL
let url = page.url();
console.log('Initial URL:', url);
// Click on Release Notes tab
await page.click('[class*="tab"]:has-text("Release Notes")');
await page.waitForTimeout(500);
url = page.url();
console.log('After clicking Release Notes:', url);
if (url.includes('tab=release-notes')) {
console.log('β
URL updated correctly for Release Notes tab');
} else {
console.log('β URL not updated for Release Notes tab');
}
// Click on Templates tab
await page.click('[class*="tab"]:has-text("Templates")');
await page.waitForTimeout(500);
url = page.url();
console.log('After clicking Templates:', url);
if (url.includes('tab=templates')) {
console.log('β
URL updated correctly for Templates tab');
} else {
console.log('β URL not updated for Templates tab');
}
// Test 2: Browser Navigation
console.log('\nπ Testing browser back/forward navigation...');
await page.goBack();
await page.waitForTimeout(500);
url = page.url();
if (url.includes('tab=release-notes')) {
console.log('β
Browser back navigation works');
} else {
console.log('β Browser back navigation failed');
}
await page.goForward();
await page.waitForTimeout(500);
url = page.url();
if (url.includes('tab=templates')) {
console.log('β
Browser forward navigation works');
} else {
console.log('β Browser forward navigation failed');
}
// Test 3: Projects Tab and Profile Selection
console.log('\nπ₯ Testing Projects tab and profile functionality...');
await page.click('[class*="tab"]:has-text("Projects")');
await page.waitForTimeout(500);
// Check if Add Tab button exists
const addTabButton = await page.$('button:has-text("Add Project")');
if (addTabButton) {
console.log('β
Add Project button found');
} else {
console.log('β Add Project button not found');
}
// Test 4: Search/Filter Functionality
console.log('\nπ Testing search functionality...');
// First, we need to add a profile to test with
// Click Add Project button
if (addTabButton) {
await addTabButton.click();
await page.waitForSelector('.modal-overlay', { timeout: 2000 });
console.log('β
Add Profile modal opened');
// Close modal with ESC or click outside
await page.keyboard.press('Escape');
await page.waitForTimeout(500);
const modalClosed = await page.$('.modal-overlay') === null;
if (modalClosed) {
console.log('β
Modal closed successfully');
} else {
console.log('β Modal did not close');
}
}
// Test 5: Tab Transitions
console.log('\nπ Testing all tab transitions...');
const tabs = ['Projects', 'Release Notes', 'Readme', 'Templates'];
for (let i = 0; i < tabs.length; i++) {
await page.click(`[class*="tab"]:has-text("${tabs[i]}")`);
await page.waitForTimeout(300);
// Check if the correct content is displayed
const activeTab = await page.$eval('.tab.active', el => el.textContent);
if (activeTab.includes(tabs[i])) {
console.log(`β
${tabs[i]} tab activated correctly`);
} else {
console.log(`β ${tabs[i]} tab activation failed`);
}
}
// Test 6: Component Rendering
console.log('\nπ¨ Testing component rendering...');
// Check Release Notes
await page.click('[class*="tab"]:has-text("Release Notes")');
await page.waitForTimeout(500);
const releaseNotesContent = await page.$('.release-notes-container');
if (releaseNotesContent) {
console.log('β
Release Notes component rendered');
} else {
console.log('β Release Notes component not found');
}
// Check Readme/Help
await page.click('[class*="tab"]:has-text("Readme")');
await page.waitForTimeout(500);
const readmeContent = await page.$('.help-container');
if (readmeContent) {
console.log('β
Readme/Help component rendered');
} else {
console.log('β Readme/Help component not found');
}
// Check Templates
await page.click('[class*="tab"]:has-text("Templates")');
await page.waitForTimeout(500);
const templatesContent = await page.$('[name="templates-content-area"]');
if (templatesContent) {
console.log('β
Templates component rendered');
} else {
console.log('β Templates component not found');
}
// Test 7: Nested Tab Structure
console.log('\nποΈ Testing nested tab structure...');
const outerTabs = await page.$$('.outer-tabs .tab');
console.log(`Found ${outerTabs.length} outer tabs`);
// Test 8: Language Selector
console.log('\nπ Testing language selector presence...');
const langSelector = await page.$('.language-selector');
if (langSelector) {
console.log('β
Language selector present');
} else {
console.log('β Language selector not found');
}
console.log('\n⨠Integration tests completed!');
} catch (error) {
console.error('β Test failed with error:', error);
} finally {
await browser.close();
}
}
// Run the tests
runIntegrationTests().catch(console.error);