37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
import pathlib
|
|
import re
|
|
import unittest
|
|
|
|
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
|
INDEX_HTML = (ROOT / 'index.html').read_text(encoding='utf-8')
|
|
TUTORIAL_JS = (ROOT / 'js' / 'tutorial.js').read_text(encoding='utf-8')
|
|
MAIN_JS = (ROOT / 'js' / 'main.js').read_text(encoding='utf-8')
|
|
|
|
|
|
class TestIssue57Polish(unittest.TestCase):
|
|
def test_help_overlay_lists_mute_and_contrast_shortcuts(self):
|
|
self.assertIn('Mute Sound', INDEX_HTML)
|
|
self.assertRegex(INDEX_HTML, r'>M<')
|
|
self.assertIn('High Contrast', INDEX_HTML)
|
|
self.assertRegex(INDEX_HTML, r'>C<')
|
|
|
|
def test_help_overlay_has_replay_tutorial_button(self):
|
|
self.assertRegex(
|
|
INDEX_HTML,
|
|
r'id="replay-tutorial-btn"[^>]*onclick="resetTutorial\(\)"',
|
|
'Expected help overlay to expose a replay tutorial button.',
|
|
)
|
|
|
|
def test_reset_tutorial_clears_flag_and_restarts_walkthrough(self):
|
|
self.assertRegex(TUTORIAL_JS, r'function\s+resetTutorial\s*\(')
|
|
self.assertIn("localStorage.removeItem(TUTORIAL_KEY)", TUTORIAL_JS)
|
|
self.assertIn('startTutorial()', TUTORIAL_JS)
|
|
|
|
def test_restore_mute_and_contrast_labels_match_saved_state(self):
|
|
self.assertIn("btn.setAttribute('aria-label', 'Sound muted, click to unmute')", MAIN_JS)
|
|
self.assertIn("btn.setAttribute('aria-label', 'High contrast on, click to disable')", MAIN_JS)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|