Files
cv-site/tests/mjs/32-all-tooltips-final-test.mjs
T
juanatsap e5c824970c fix: Override .has-tooltip position for theme switcher button
The theme switcher button was hidden above the viewport on desktop because
.has-tooltip's position: relative was overriding the button's position: fixed
due to CSS cascade order (_tooltips.css loaded after _themes.css).

Fixed by adding !important to .color-theme-switcher position: fixed rule.

Changes:
- static/css/01-foundation/_themes.css: Add !important to position: fixed
  to override .has-tooltip position: relative cascade

Testing:
- Added comprehensive tooltip tests for all buttons (desktop & mobile)
- Verified theme switcher visible on desktop at correct position
- Verified all tooltips working on hover (desktop only, hidden on mobile touch)
- Verified button positioning in mobile bottom dock

All buttons now display correctly:
 Desktop: All 6 buttons with working tooltips
 Mobile: All 5 buttons in bottom dock
2025-11-20 18:51:38 +00:00

136 lines
4.9 KiB
JavaScript
Executable File

#!/usr/bin/env bun
import { chromium } from 'playwright';
(async () => {
const browser = await chromium.launch({ headless: false });
console.log('========================================');
console.log(' COMPREHENSIVE TOOLTIP TEST');
console.log(' Testing ALL buttons on desktop & mobile');
console.log('========================================\n');
// ========== DESKTOP TEST ==========
console.log('📱 DESKTOP TEST (1920x1080)');
console.log('─────────────────────────────\n');
const desktopPage = await browser.newPage({ viewport: { width: 1920, height: 1080 } });
await desktopPage.goto('http://localhost:1999/');
await desktopPage.waitForLoadState('networkidle');
await desktopPage.waitForTimeout(1000);
const desktopButtons = [
{ id: 'download-button', name: 'Download PDF', expectedPosition: 'right' },
{ id: 'print-friendly-button', name: 'Print Friendly', expectedPosition: 'right' },
{ id: 'zoom-toggle-button', name: 'Zoom Toggle', expectedPosition: 'right' },
{ id: 'shortcuts-button', name: 'Keyboard Shortcuts', expectedPosition: 'right' },
{ id: 'color-theme-switcher', name: 'Theme Switcher', expectedPosition: 'right' },
{ id: 'info-button', name: 'Info Button', expectedPosition: 'right' },
{ id: 'back-to-top', name: 'Back to Top', expectedPosition: 'left' }
];
for (const btn of desktopButtons) {
const button = desktopPage.locator(`#${btn.id}`);
const exists = await button.count() > 0;
if (!exists) {
console.log(`${btn.name}: NOT FOUND in DOM`);
continue;
}
const isVisible = await button.isVisible();
console.log(`${isVisible ? '✅' : '❌'} ${btn.name}: ${isVisible ? 'Visible' : 'Not visible'}`);
if (isVisible) {
// Test tooltip
await button.hover();
await desktopPage.waitForTimeout(300);
const tooltip = await desktopPage.evaluate((id) => {
const btn = document.getElementById(id);
if (!btn) return null;
const computed = window.getComputedStyle(btn, '::before');
return {
opacity: computed.opacity,
visibility: computed.visibility,
content: computed.content,
position: computed.position
};
}, btn.id);
if (tooltip && parseFloat(tooltip.opacity) > 0.5) {
console.log(` 💬 Tooltip: VISIBLE (opacity: ${tooltip.opacity})`);
} else {
console.log(` ⚠️ Tooltip: NOT visible or low opacity`);
}
}
}
await desktopPage.screenshot({
path: '/Users/txeo/Git/yo/cv/tests/mjs/screenshots/all-tooltips-desktop.png',
fullPage: false
});
console.log('\n📸 Desktop screenshot saved\n');
await desktopPage.close();
// ========== MOBILE TEST ==========
console.log('📱 MOBILE TEST (375x667 - iPhone SE)');
console.log('─────────────────────────────\n');
const mobilePage = await browser.newPage({ viewport: { width: 375, height: 667 } });
await mobilePage.goto('http://localhost:1999/');
await mobilePage.waitForLoadState('networkidle');
await mobilePage.waitForTimeout(1000);
const mobileButtons = [
{ id: 'download-button', name: 'Download PDF' },
{ id: 'print-friendly-button', name: 'Print Friendly' },
{ id: 'shortcuts-button', name: 'Keyboard Shortcuts' },
{ id: 'color-theme-switcher', name: 'Theme Switcher' },
{ id: 'info-button', name: 'Info Button' }
];
console.log('Checking button visibility and positions on mobile...\n');
for (const btn of mobileButtons) {
const button = mobilePage.locator(`#${btn.id}`);
const exists = await button.count() > 0;
if (!exists) {
console.log(`${btn.name}: NOT FOUND`);
continue;
}
const isVisible = await button.isVisible();
const box = isVisible ? await button.boundingBox() : null;
if (isVisible && box) {
// Check if button is in bottom dock (y > 500 for iPhone SE height 667)
const inBottomDock = box.y > 500;
console.log(`${isVisible ? '✅' : '❌'} ${btn.name}: Visible at y=${Math.round(box.y)} ${inBottomDock ? '(bottom dock)' : ''}`);
// Tooltips are hidden on mobile touch devices, so we don't test them
} else {
console.log(`${btn.name}: Not visible or no bounding box`);
}
}
await mobilePage.screenshot({
path: '/Users/txeo/Git/yo/cv/tests/mjs/screenshots/all-tooltips-mobile.png',
fullPage: true
});
console.log('\n📸 Mobile screenshot saved\n');
await mobilePage.close();
// ========== SUMMARY ==========
console.log('========================================');
console.log(' TEST COMPLETE');
console.log('========================================');
console.log('\n✅ All tests completed successfully!');
console.log('📸 Screenshots saved to tests/mjs/screenshots/\n');
await browser.close();
})();