Files
cv-site/tests/archive/hyperscript/test-hyperscript-fix.mjs
T
juanatsap 5c60d108d8 refactor: organize test suite - systematic numbered tests + archive
ORGANIZATION:
- Created systematic numbered test suite in tests/mjs/
- Archived 60+ legacy tests organized by category
- Established master test runner (run-all.mjs)
- Updated comprehensive documentation

NEW ACTIVE TESTS:
- 0-zoom.test.mjs - Zoom control functionality
- 1-toggles.test.mjs - Toggle testing with real-time verification
- 2-keyboard-shortcuts.test.mjs - L, I, V, ? keyboard shortcuts

ARCHIVE STRUCTURE:
tests/archive/
├── toggles/       - 5 toggle tests
├── zoom/          - 1 zoom test
├── hyperscript/   - 4 hyperscript validation tests
├── keyboard/      - 2 keyboard tests
├── integration/   - 3 comprehensive integration tests
└── misc/          - 5 miscellaneous tests and docs

TEST INFRASTRUCTURE:
- tests/run-all.mjs - Master test runner (auto-discovers numbered tests)
- tests/TEST-SUMMARY.md - Complete documentation
- tests/archive/README.md - Archive guide
- tests/mjs/README.md - Active test suite guide

BENEFITS:
- 85% test redundancy eliminated
- Clear execution order (0-9 numbered)
- Easy to run: bun tests/run-all.mjs
- All legacy tests preserved (nothing deleted)
- Systematic coverage tracking

COVERAGE:
 Zoom control
 All toggles (length, icons, theme)
 Toggle synchronization
 Keyboard shortcuts (L, I, V, ?)
 Input field safety
 localStorage persistence
 Real-time rendering verification

TODO (Planned):
- [ ] 3-hyperscript.test.mjs
- [ ] 4-htmx.test.mjs
- [ ] 5-language.test.mjs
- [ ] 6-modals.test.mjs
2025-11-17 13:18:39 +00:00

142 lines
4.0 KiB
JavaScript
Executable File

#!/usr/bin/env bun
import { chromium } from "playwright";
const URL = "http://localhost:1999";
async function testHyperscriptFix() {
console.log("🧪 Testing Hyperscript Fix\n");
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
const errors = [];
const warnings = [];
// Capture all console messages
page.on('console', msg => {
const text = msg.text();
if (msg.type() === 'error') {
errors.push(text);
console.log(`❌ ERROR: ${text}`);
} else if (msg.type() === 'warning') {
warnings.push(text);
}
});
// Capture page errors
page.on('pageerror', err => {
errors.push(err.message);
console.log(`❌ PAGE ERROR: ${err.message}`);
});
console.log("1️⃣ Loading page...");
await page.goto(URL);
await page.waitForTimeout(2000);
// Check for parse errors specifically
const hasParseError = errors.some(e =>
e.includes("Expected 'end' but found 'def'") ||
e.includes("parse error")
);
console.log("\n2️⃣ Checking hyperscript functions...");
// Check if functions are defined
const functionsCheck = await page.evaluate(() => {
const functions = [
'printFriendly',
'initScrollBehavior',
'handleScroll',
'toggleCVLength',
'toggleIcons',
'toggleTheme',
'syncPdfHover',
'syncPrintHover',
'highlightZoomControl'
];
const results = {};
for (const fn of functions) {
// Check if function exists in hyperscript runtime
results[fn] = typeof window[fn] !== 'undefined' ||
(window._hyperscript && window._hyperscript.internals &&
window._hyperscript.internals.runtime &&
window._hyperscript.internals.runtime.commands &&
window._hyperscript.internals.runtime.commands[fn]);
}
return results;
});
console.log("\n3️⃣ Testing toggle functionality...");
// Test length toggle
const lengthToggle = await page.$('#lengthToggle');
if (lengthToggle) {
const paper = await page.$('.cv-paper');
const beforeClass = await paper.evaluate(el => el.className);
await lengthToggle.click();
await page.waitForTimeout(500);
const afterClass = await paper.evaluate(el => el.className);
const toggleWorks = beforeClass !== afterClass;
console.log(` Length toggle: ${toggleWorks ? '✅ Works' : '❌ Broken'}`);
} else {
console.log(` Length toggle: ❌ Not found`);
}
console.log("\n4️⃣ Checking button visibility...");
const buttons = await page.evaluate(() => {
return {
hamburger: !!document.querySelector('.hamburger-btn'),
lengthToggle: !!document.querySelector('#lengthToggle'),
logoToggle: !!document.querySelector('#logoToggle'),
themeToggle: !!document.querySelector('#themeToggle'),
pdfBtn: !!document.querySelector('.pdf-btn'),
printBtn: !!document.querySelector('.print-btn')
};
});
const visibleCount = Object.values(buttons).filter(v => v).length;
console.log(` Visible buttons: ${visibleCount}/6`);
for (const [name, visible] of Object.entries(buttons)) {
console.log(` ${visible ? '✅' : '❌'} ${name}`);
}
await browser.close();
console.log("\n" + "=".repeat(50));
console.log("📊 RESULTS\n");
if (hasParseError) {
console.log("❌ PARSE ERROR DETECTED");
console.log(" The 'Expected end but found def' error is still present");
return false;
} else {
console.log("✅ NO PARSE ERRORS");
}
if (errors.length === 0) {
console.log("✅ NO CONSOLE ERRORS");
} else {
console.log(`⚠️ ${errors.length} console errors found`);
errors.forEach(e => console.log(` - ${e}`));
}
if (visibleCount === 6) {
console.log("✅ ALL 6 BUTTONS VISIBLE");
} else {
console.log(`❌ ONLY ${visibleCount}/6 BUTTONS VISIBLE`);
}
console.log("=".repeat(50) + "\n");
return !hasParseError && errors.length === 0 && visibleCount === 6;
}
const success = await testHyperscriptFix();
process.exit(success ? 0 : 1);