# Verification Script - Data-TestID Attributes **Purpose**: Automated verification of data-testid attributes **Method**: Code-based verification (not DOM-based) **Usage**: Run these commands to verify implementation status --- ## 🔍 QUICK STATUS CHECK ```bash # Count total data-testid attributes grep -r "data-testid" cognitive-prism-assesment-ui/src/ | wc -l # List all existing attributes grep -rn "data-testid" cognitive-prism-assesment-ui/src/ ``` --- ## 📋 DETAILED VERIFICATION ### 1. Check Specific File ```bash # SignInPage grep -n "data-testid" cognitive-prism-assesment-ui/src/pages/designs/design-1/SignInPage.jsx # Design1Header grep -n "data-testid" cognitive-prism-assesment-ui/src/pages/designs/design-1/components/Design1Header.jsx # StudentProfileEditor grep -n "data-testid" cognitive-prism-assesment-ui/src/pages/StudentProfileEditor.jsx ``` ### 2. Verify Pattern Compliance ```bash # Find attributes that DON'T follow double underscore pattern grep -r "data-testid" cognitive-prism-assesment-ui/src/ | grep -v "__" | grep -v "//" # Find attributes with single underscore (wrong pattern) grep -r "data-testid=\"[^\"]*_[^\"]*\"" cognitive-prism-assesment-ui/src/ | grep -v "__" ``` ### 3. Check Missing Attributes by Scope ```bash # Check student_login scope grep -r "student_login__" cognitive-prism-assesment-ui/src/ | wc -l # Expected: 7 (currently 6) # Check student_nav scope grep -r "student_nav__" cognitive-prism-assesment-ui/src/ | wc -l # Expected: 7 (currently 5) # Check mandatory_reset scope grep -r "mandatory_reset__" cognitive-prism-assesment-ui/src/ | wc -l # Expected: 11 (currently 1) # Check profile_incomplete scope grep -r "profile_incomplete__" cognitive-prism-assesment-ui/src/ | wc -l # Expected: 3 (currently 0) # Check profile_editor scope grep -r "profile_editor__" cognitive-prism-assesment-ui/src/ | wc -l # Expected: 60+ (currently 0) # Check dashboard scope grep -r "dashboard__" cognitive-prism-assesment-ui/src/ | wc -l # Expected: 1 (currently 0) # Check assessment_card scope grep -r "assessment_card__" cognitive-prism-assesment-ui/src/ | wc -l # Expected: 2+ (currently 0) ``` --- ## 🐍 PYTHON VERIFICATION SCRIPT Create `verify_testids.py`: ```python #!/usr/bin/env python3 """ Verify data-testid attributes in codebase """ import re import subprocess from pathlib import Path # Expected attributes by scope EXPECTED = { 'student_login': 7, 'student_nav': 7, 'mandatory_reset': 11, 'profile_incomplete': 3, 'profile_editor': 60, # Minimum expected 'dashboard': 1, 'assessment_card': 2, # Minimum expected } def count_attributes(scope): """Count attributes for a scope""" result = subprocess.run( ['grep', '-r', f'{scope}__', 'cognitive-prism-assesment-ui/src/'], capture_output=True, text=True ) return len(result.stdout.strip().split('\n')) if result.stdout.strip() else 0 def verify_pattern(attribute): """Verify attribute follows pattern""" pattern = r'^[a-z][a-z0-9_]*__[a-z][a-z0-9_]*(__[a-z0-9_]+)*$' return bool(re.match(pattern, attribute)) def main(): print("=" * 60) print("Data-TestID Verification Report") print("=" * 60) print() total_found = 0 total_expected = sum(EXPECTED.values()) for scope, expected_count in EXPECTED.items(): found = count_attributes(scope) status = "✅" if found >= expected_count else "❌" percentage = (found / expected_count * 100) if expected_count > 0 else 0 print(f"{status} {scope:25} {found:3}/{expected_count:3} ({percentage:5.1f}%)") total_found += found print() print("=" * 60) print(f"Total: {total_found}/{total_expected} ({(total_found/total_expected*100):.1f}%)") print("=" * 60) if __name__ == '__main__': main() ``` **Usage:** ```bash python3 verify_testids.py ``` --- ## 🔄 CONTINUOUS VERIFICATION Add to CI/CD pipeline: ```yaml # .github/workflows/verify-testids.yml name: Verify Data-TestID Attributes on: [push, pull_request] jobs: verify: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Verify attributes run: | python3 verify_testids.py ``` --- ## 📊 EXPECTED RESULTS After full implementation: - `student_login`: 7/7 ✅ - `student_nav`: 7/7 ✅ - `mandatory_reset`: 11/11 ✅ - `profile_incomplete`: 3/3 ✅ - `profile_editor`: 60+/60+ ✅ - `dashboard`: 1/1 ✅ - `assessment_card`: 2+/2+ ✅ **Total**: 91+/91+ ✅ --- **Note**: This verification is code-based, not DOM-based. It checks source code, not rendered HTML.