Spaces:
Running
Running
| """Test that UI displays in English.""" | |
| import re | |
| from pathlib import Path | |
| # Japanese character regex pattern (Hiragana, Katakana, Kanji) | |
| JAPANESE_PATTERN = re.compile(r'[\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FFF]') | |
| class TestUILanguage: | |
| """Tests to verify UI is in English.""" | |
| def test_html_lang_attribute_is_english(self): | |
| """HTML lang attribute should be 'en' for English.""" | |
| html_path = Path(__file__).parent.parent / 'rock_paper_scissors' / 'static' / 'index.html' | |
| content = html_path.read_text(encoding='utf-8') | |
| assert 'lang="en"' in content, "HTML lang attribute should be 'en'" | |
| def test_html_has_no_japanese_text(self): | |
| """HTML should not contain Japanese characters.""" | |
| html_path = Path(__file__).parent.parent / 'rock_paper_scissors' / 'static' / 'index.html' | |
| content = html_path.read_text(encoding='utf-8') | |
| japanese_chars = JAPANESE_PATTERN.findall(content) | |
| assert not japanese_chars, f"HTML contains Japanese characters: {''.join(japanese_chars[:20])}" | |
| def test_js_has_no_japanese_text(self): | |
| """JavaScript should not contain Japanese characters.""" | |
| js_path = Path(__file__).parent.parent / 'rock_paper_scissors' / 'static' / 'main.js' | |
| content = js_path.read_text(encoding='utf-8') | |
| japanese_chars = JAPANESE_PATTERN.findall(content) | |
| assert not japanese_chars, f"JS contains Japanese characters: {''.join(japanese_chars[:20])}" | |
| def test_html_has_english_title(self): | |
| """Page title should be in English.""" | |
| html_path = Path(__file__).parent.parent / 'rock_paper_scissors' / 'static' / 'index.html' | |
| content = html_path.read_text(encoding='utf-8') | |
| assert 'Rock Paper Scissors' in content, "Title should contain 'Rock Paper Scissors'" | |
| def test_html_has_english_labels(self): | |
| """UI labels should be in English.""" | |
| html_path = Path(__file__).parent.parent / 'rock_paper_scissors' / 'static' / 'index.html' | |
| content = html_path.read_text(encoding='utf-8') | |
| # Check for expected English labels | |
| expected_labels = [ | |
| 'State:', | |
| 'Camera', | |
| 'You', | |
| 'Hand Detection Status', | |
| ] | |
| for label in expected_labels: | |
| assert label in content, f"Expected English label '{label}' not found" | |
| def test_js_has_english_result_text(self): | |
| """Result text in JS should be in English.""" | |
| js_path = Path(__file__).parent.parent / 'rock_paper_scissors' / 'static' / 'main.js' | |
| content = js_path.read_text(encoding='utf-8') | |
| # Check for English result messages | |
| assert 'Reachy wins' in content or 'Reachy Wins' in content, "Should have English win message" | |
| assert 'You win' in content or 'You Win' in content, "Should have English lose message" | |
| assert 'Draw' in content or 'draw' in content, "Should have English draw message" | |
| def test_js_has_english_status_text(self): | |
| """Status text in JS should be in English.""" | |
| js_path = Path(__file__).parent.parent / 'rock_paper_scissors' / 'static' / 'main.js' | |
| content = js_path.read_text(encoding='utf-8') | |
| # Check status messages are in English | |
| expected_messages = [ | |
| 'No frame', | |
| 'Available', | |
| 'Unavailable', | |
| 'Detected', | |
| 'Not detected', | |
| ] | |
| found_count = sum(1 for msg in expected_messages if msg in content) | |
| assert found_count >= 3, f"Expected more English status messages, found {found_count}" | |