|
| 1 | +import { chromium } from 'playwright'; |
| 2 | +import { mkdirSync } from 'fs'; |
| 3 | + |
| 4 | +try { |
| 5 | + mkdirSync('/tmp/playwright-logs', { recursive: true }); |
| 6 | +} catch (e) {} |
| 7 | + |
| 8 | +async function comprehensiveTextVisibilityTest() { |
| 9 | + console.log('Starting comprehensive sidebar text visibility test...'); |
| 10 | + const browser = await chromium.launch({ headless: true }); |
| 11 | + const page = await browser.newPage({ |
| 12 | + viewport: { width: 1920, height: 1080 } |
| 13 | + }); |
| 14 | + |
| 15 | + try { |
| 16 | + await page.goto('http://localhost:5173/console/', { waitUntil: 'networkidle', timeout: 30000 }); |
| 17 | + await page.waitForTimeout(3000); |
| 18 | + |
| 19 | + console.log('\n=== EXPANDED STATE (DEFAULT) ==='); |
| 20 | + await page.screenshot({ path: '/tmp/playwright-logs/comprehensive-expanded.png', fullPage: true }); |
| 21 | + |
| 22 | + const expandedAnalysis = await page.evaluate(() => { |
| 23 | + const sidebar = document.querySelector('[data-sidebar="sidebar"]'); |
| 24 | + const parent = sidebar?.parentElement?.parentElement; |
| 25 | + |
| 26 | + // Get all text elements in sidebar |
| 27 | + const allText = Array.from(sidebar?.querySelectorAll('*') || []) |
| 28 | + .filter(el => { |
| 29 | + const text = el.textContent?.trim(); |
| 30 | + return text && text.length > 0 && text.length < 100; |
| 31 | + }) |
| 32 | + .map(el => { |
| 33 | + const style = window.getComputedStyle(el); |
| 34 | + const rect = el.getBoundingClientRect(); |
| 35 | + return { |
| 36 | + tag: el.tagName.toLowerCase(), |
| 37 | + text: el.textContent?.trim().substring(0, 50), |
| 38 | + classes: el.className, |
| 39 | + dataAttr: el.getAttribute('data-sidebar'), |
| 40 | + display: style.display, |
| 41 | + opacity: style.opacity, |
| 42 | + visibility: style.visibility, |
| 43 | + width: style.width, |
| 44 | + height: style.height, |
| 45 | + overflow: style.overflow, |
| 46 | + position: style.position, |
| 47 | + isVisible: rect.width > 0 && rect.height > 0 && style.display !== 'none' && parseFloat(style.opacity) > 0 |
| 48 | + }; |
| 49 | + }); |
| 50 | + |
| 51 | + // Group by visibility |
| 52 | + const visible = allText.filter(t => t.isVisible); |
| 53 | + const invisible = allText.filter(t => !t.isVisible); |
| 54 | + |
| 55 | + // Get specific elements |
| 56 | + const menuButtons = Array.from(document.querySelectorAll('[data-sidebar="menu-button"]')); |
| 57 | + const groupLabels = Array.from(document.querySelectorAll('[data-sidebar="group-label"]')); |
| 58 | + |
| 59 | + return { |
| 60 | + dataState: parent?.getAttribute('data-state'), |
| 61 | + dataCollapsible: parent?.getAttribute('data-collapsible'), |
| 62 | + sidebarWidth: sidebar?.parentElement ? window.getComputedStyle(sidebar.parentElement).width : null, |
| 63 | + totalTextElements: allText.length, |
| 64 | + visibleCount: visible.length, |
| 65 | + invisibleCount: invisible.length, |
| 66 | + invisibleElements: invisible.slice(0, 10), |
| 67 | + menuButtonsAnalysis: menuButtons.slice(0, 3).map(btn => { |
| 68 | + const style = window.getComputedStyle(btn); |
| 69 | + const spans = Array.from(btn.querySelectorAll('span')); |
| 70 | + return { |
| 71 | + text: btn.textContent?.trim().substring(0, 30), |
| 72 | + classes: btn.className.substring(0, 200), |
| 73 | + width: style.width, |
| 74 | + height: style.height, |
| 75 | + display: style.display, |
| 76 | + overflow: style.overflow, |
| 77 | + spans: spans.map(s => ({ |
| 78 | + text: s.textContent?.trim(), |
| 79 | + display: window.getComputedStyle(s).display, |
| 80 | + opacity: window.getComputedStyle(s).opacity, |
| 81 | + overflow: window.getComputedStyle(s).overflow, |
| 82 | + width: window.getComputedStyle(s).width |
| 83 | + })) |
| 84 | + }; |
| 85 | + }), |
| 86 | + groupLabelsAnalysis: groupLabels.map(label => ({ |
| 87 | + text: label.textContent?.trim(), |
| 88 | + display: window.getComputedStyle(label).display, |
| 89 | + opacity: window.getComputedStyle(label).opacity, |
| 90 | + marginTop: window.getComputedStyle(label).marginTop |
| 91 | + })) |
| 92 | + }; |
| 93 | + }); |
| 94 | + |
| 95 | + console.log('\nExpanded State Analysis:'); |
| 96 | + console.log('Data State:', expandedAnalysis.dataState); |
| 97 | + console.log('Sidebar Width:', expandedAnalysis.sidebarWidth); |
| 98 | + console.log('Total Text Elements:', expandedAnalysis.totalTextElements); |
| 99 | + console.log('Visible Elements:', expandedAnalysis.visibleCount); |
| 100 | + console.log('Invisible Elements:', expandedAnalysis.invisibleCount); |
| 101 | + |
| 102 | + if (expandedAnalysis.invisibleCount > 0) { |
| 103 | + console.log('\n⚠️ INVISIBLE TEXT ELEMENTS IN EXPANDED STATE:'); |
| 104 | + expandedAnalysis.invisibleElements.forEach((el, i) => { |
| 105 | + console.log(`${i + 1}. "${el.text}"`); |
| 106 | + console.log(` Tag: ${el.tag}, Data: ${el.dataAttr}`); |
| 107 | + console.log(` Display: ${el.display}, Opacity: ${el.opacity}, Overflow: ${el.overflow}`); |
| 108 | + console.log(` Width: ${el.width}, Height: ${el.height}`); |
| 109 | + console.log(` Classes: ${el.classes.substring(0, 100)}...`); |
| 110 | + }); |
| 111 | + } |
| 112 | + |
| 113 | + console.log('\nMenu Buttons Analysis:'); |
| 114 | + expandedAnalysis.menuButtonsAnalysis.forEach((btn, i) => { |
| 115 | + console.log(`\nButton ${i + 1}: "${btn.text}"`); |
| 116 | + console.log(` Width: ${btn.width}, Height: ${btn.height}`); |
| 117 | + console.log(` Overflow: ${btn.overflow}`); |
| 118 | + console.log(` Spans (${btn.spans.length}):`); |
| 119 | + btn.spans.forEach((span, j) => { |
| 120 | + console.log(` Span ${j + 1}: "${span.text}"`); |
| 121 | + console.log(` Display: ${span.display}, Opacity: ${span.opacity}, Width: ${span.width}, Overflow: ${span.overflow}`); |
| 122 | + }); |
| 123 | + }); |
| 124 | + |
| 125 | + if (expandedAnalysis.groupLabelsAnalysis.length > 0) { |
| 126 | + console.log('\nGroup Labels Analysis:'); |
| 127 | + expandedAnalysis.groupLabelsAnalysis.forEach((label, i) => { |
| 128 | + console.log(` ${i + 1}. "${label.text}": display=${label.display}, opacity=${label.opacity}, marginTop=${label.marginTop}`); |
| 129 | + }); |
| 130 | + } |
| 131 | + |
| 132 | + // Now test collapsed state |
| 133 | + console.log('\n\n=== COLLAPSING SIDEBAR ==='); |
| 134 | + await page.evaluate(() => { |
| 135 | + document.querySelector('[data-sidebar="trigger"]')?.click(); |
| 136 | + }); |
| 137 | + await page.waitForTimeout(500); |
| 138 | + await page.screenshot({ path: '/tmp/playwright-logs/comprehensive-collapsed.png', fullPage: true }); |
| 139 | + |
| 140 | + const collapsedAnalysis = await page.evaluate(() => { |
| 141 | + const sidebar = document.querySelector('[data-sidebar="sidebar"]'); |
| 142 | + const parent = sidebar?.parentElement?.parentElement; |
| 143 | + return { |
| 144 | + dataState: parent?.getAttribute('data-state'), |
| 145 | + sidebarWidth: sidebar?.parentElement ? window.getComputedStyle(sidebar.parentElement).width : null |
| 146 | + }; |
| 147 | + }); |
| 148 | + |
| 149 | + console.log('\nCollapsed State:'); |
| 150 | + console.log('Data State:', collapsedAnalysis.dataState); |
| 151 | + console.log('Sidebar Width:', collapsedAnalysis.sidebarWidth); |
| 152 | + |
| 153 | + // Test re-expand |
| 154 | + console.log('\n\n=== RE-EXPANDING SIDEBAR ==='); |
| 155 | + await page.evaluate(() => { |
| 156 | + document.querySelector('[data-sidebar="trigger"]')?.click(); |
| 157 | + }); |
| 158 | + await page.waitForTimeout(500); |
| 159 | + await page.screenshot({ path: '/tmp/playwright-logs/comprehensive-reexpanded.png', fullPage: true }); |
| 160 | + |
| 161 | + console.log('\n=== SUMMARY ==='); |
| 162 | + console.log(`✅ Sidebar state changes work: ${expandedAnalysis.dataState === 'expanded' && collapsedAnalysis.dataState === 'collapsed'}`); |
| 163 | + console.log(`✅ Sidebar width changes work: ${expandedAnalysis.sidebarWidth === '256px' && collapsedAnalysis.sidebarWidth === '48px'}`); |
| 164 | + console.log(`⚠️ Text visibility issues: ${expandedAnalysis.invisibleCount} invisible elements in expanded state`); |
| 165 | + |
| 166 | + if (expandedAnalysis.invisibleCount > 0) { |
| 167 | + console.log('\n🔴 PROBLEM DETECTED: Text elements are still invisible when expanded!'); |
| 168 | + process.exit(1); |
| 169 | + } |
| 170 | + |
| 171 | + } catch (error) { |
| 172 | + console.error('Error during test:', error); |
| 173 | + throw error; |
| 174 | + } finally { |
| 175 | + await browser.close(); |
| 176 | + } |
| 177 | +} |
| 178 | + |
| 179 | +comprehensiveTextVisibilityTest().catch(err => { |
| 180 | + console.error('Test failed:', err); |
| 181 | + process.exit(1); |
| 182 | +}); |
0 commit comments