From 7a7dcedcb77064ee23217d87d2b93e58128864e5 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 14 Apr 2026 07:51:16 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Add=20test=20for=20year-by-year?= =?UTF-8?q?=20impact=20log=20toggle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: singhaditya21 <53948039+singhaditya21@users.noreply.github.com> --- tests/test_script.py | 81 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 tests/test_script.py diff --git a/tests/test_script.py b/tests/test_script.py new file mode 100644 index 0000000..0cd8bf1 --- /dev/null +++ b/tests/test_script.py @@ -0,0 +1,81 @@ +import unittest +import os +from playwright.sync_api import sync_playwright + +class TestYearCardToggle(unittest.TestCase): + def setUp(self): + # We need absolute path for the script.js since we might run from another dir + base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + self.script_path = os.path.join(base_dir, 'script.js') + + def test_toggle_expanded_class(self): + """ + Tests that the 'expanded' class is correctly toggled on '.year-card' + elements when their '.year-card-header' is clicked. + Also verifies the first '.year-card' is expanded by default. + """ + with sync_playwright() as p: + browser = p.chromium.launch(headless=True) + page = browser.new_page() + + with open(self.script_path, "r") as f: + js_content = f.read() + + # Mocked DOM + html_content = f""" + + +
+ +