ALL testing and debugging MUST follow our Systematic Research Methodology.
- Use the Research Template for investigation
- Research systematically - Understand the system before testing
- Never assume test failures - Investigate root causes thoroughly
- Document findings - Capture insights for future reference
- Phase 1: Problem Decomposition - What exactly is failing and why?
- Phase 2: Systematic Code Research - Investigate implementation and test logic
- Phase 3: Evidence-Based Analysis - Compare expected vs actual behavior
- Phase 4: Targeted Resolution - Fix root causes, not symptoms
See Headless Test Research Findings for a real example of this methodology successfully identifying complex testing issues.
This app includes a comprehensive test suite that can be run at any time during development to ensure code quality and catch regressions.
Purpose: Validates learning path progression and b-level behavior compliance.
Key Features:
- Level Progression Tracking: Monitors transitions through multiple levels
- B-Level Compliance Validation: Ensures b-levels ask ONLY triads questions
- Question Type Analysis: Validates each level's allowed question types
- Key Usage Verification: Confirms appropriate keys for each level
- Comprehensive Reporting: Detailed behavior analysis with pass/fail status
Usage:
# Start development server first
npm run dev
# Run enhanced headless test
npm run test:headlessExpected Test Flow:
- Level 1 (Introduction): Mixed content validation
- Level 1a (Sharps): Mixed content with accidentals
- Level 1b (Sharps b-level): TRIADS ONLY - critical UX validation
- Comprehensive reporting with B-Level Compliance analysis
Success Criteria:
- ✅ All question/answer validations pass
- ✅ Level progression occurs correctly
- ✅ B-levels show "TRIADS ONLY" compliance
- ✅ No mixed content violations in b-levels
- ✅ 100% success rate with comprehensive behavior validation
Sample Success Output:
🎯 B-Level Validation Summary:
B-Levels Tested: 1b
All B-Levels Valid: ✅ YES
🎉 B-levels successfully use triads-only behavior!
🏆 Final Verdict:
🎉 ALL TESTS PASSED! Learning path and b-level behavior working correctly.
This test validates the core UX improvement where b-levels provide focused triad practice instead of confusing mixed content.
CRITICAL: Before fixing any test failures, follow this systematic approach
Developers and assistants often make mistakes when they:
- Assume they understand the test failure immediately
- Apply the first fix that comes to mind
- Don't investigate the root cause
- Make changes without understanding the full context
DO NOT start coding immediately. Instead:
-
Read the test failure carefully
- What exactly is failing?
- What was the expected vs actual result?
- Which test case is failing?
-
Examine the test code
- Understand what the test is trying to verify
- Check if the test logic is correct
- Verify the expected values make sense
-
Check the implementation
- Look at the function being tested
- Understand how it should work
- Identify potential issues
DO NOT assume the problem is where you first look:
-
Check recent changes
git log --oneline -10 # Recent commits git show <commit> --name-only # What files changed
-
Look for related issues
- Are there similar test failures?
- Is this part of a larger problem?
- Are there other functions with similar logic?
-
Consider the broader impact
- Will fixing this break other functionality?
- Are there edge cases to consider?
- Is this a symptom of a larger issue?
DO NOT proceed without a clear understanding:
-
Document your theory
- Write down what you think is wrong
- Explain why you think this is the issue
- List your assumptions
-
Gather evidence
- Look for supporting evidence
- Check for contradictory evidence
- Test your hypothesis with additional debugging
-
Consider alternatives
- What else could be causing this?
- Are there other explanations?
- What would disprove your theory?
DO NOT make changes until you're certain:
-
Make minimal changes
- Fix only what's necessary
- Preserve working functionality
- Document your changes
-
Test thoroughly
- Run the specific failing test
- Run all related tests
- Run the full test suite
-
Verify the fix
- Confirm the test now passes
- Ensure no new failures
- Test edge cases
Test Failure: Seventh chord spelling validation was failing with key mismatches.
Systematic Investigation:
- Understood the failure: Keys shown in questions didn't match keys used in validation
- Investigated context: Found the issue was in
startAdvancedPractice(), not the main validation logic - Formed hypothesis: Multiple random key selections were causing inconsistency
- Implemented fix: Selected key once and reused it throughout the function
Result: Complete resolution with no regressions.
- Always investigate before coding
- Consider multiple possible causes
- Look for patterns and related issues
- Make minimal, targeted fixes
- Test thoroughly after changes
- Document your process
This systematic approach prevents the most common debugging mistakes.
- Press:
Ctrl+Shift+Q(Windows/Linux) orCmd+Shift+Q(Mac) - What happens:
- Clears console
- Runs all tests
- Shows results in new tab (or overlay if popup blocked)
- Logs detailed results to console
Open the browser console and run:
MusicTheoryTests.runAllTests()// Run specific test categories
MusicTheoryTests.runChordNormalizationTests()
MusicTheoryTests.runAccidentalNormalizationTests()
MusicTheoryTests.runFunctionExistenceTests()
MusicTheoryTests.runAppStateTests()