| index 4f24f8c..83564bc 100755 | | index 4f24f8c..83564bc 100755 |
| --- a/tests/e2e.py | | --- a/tests/e2e.py |
| +++ b/tests/e2e.py | | +++ b/tests/e2e.py |
| @@ -17,8 +17,9 @@ provider at tests/mockapi.py, opens the page with Playwright at 1440 / 1024 / | | @@ -17,8 +17,9 @@ provider at tests/mockapi.py, opens the page with Playwright at 1440 / 1024 / |
| 17 | Skips cleanly (exit 0) when Playwright is missing, so the offline suite stays | 17 | Skips cleanly (exit 0) when Playwright is missing, so the offline suite stays |
| 18 | dependency-free. | 18 | dependency-free. |
| 19 | | 19 | |
| 20 | - python3 tests/e2e.py # run if Playwright is available | 20 | + python3 tests/e2e.py # run if Playwright is available |
| 21 | - python3 tests/e2e.py --strict # exit 2 when Playwright is missing | 21 | + python3 tests/e2e.py --strict # exit 2 when Playwright is missing |
| | 22 | + python3 tests/e2e.py --shots /tmp # write the PNGs somewhere other than docs/ |
| 22 | """ | 23 | """ |
| 23 | | 24 | |
| 24 | import argparse | 25 | import argparse |
| @@ -121,6 +122,8 @@ class Handler(http.server.BaseHTTPRequestHandler): | | @@ -121,6 +122,8 @@ class Handler(http.server.BaseHTTPRequestHandler): |
| 121 | def main(): | 122 | def main(): |
| 122 | ap = argparse.ArgumentParser() | 123 | ap = argparse.ArgumentParser() |
| 123 | ap.add_argument("--strict", action="store_true") | 124 | ap.add_argument("--strict", action="store_true") |
| | 125 | + ap.add_argument("--shots", default=DOCS, |
| | 126 | + help="where the PNGs go (default docs/, the committed README set)") |
| 124 | args = ap.parse_args() | 127 | args = ap.parse_args() |
| 125 | | 128 | |
| 126 | try: | 129 | try: |
| @@ -133,7 +136,8 @@ def main(): | | @@ -133,7 +136,8 @@ def main(): |
| 133 | bad("plugin_websearch binary is missing (run make first)") | 136 | bad("plugin_websearch binary is missing (run make first)") |
| 134 | return 1 | 137 | return 1 |
| 135 | | 138 | |
| 136 | - os.makedirs(DOCS, exist_ok=True) | 139 | + shots = args.shots |
| | 140 | + os.makedirs(shots, exist_ok=True) |
| 137 | mock, mock_base, log = start_mock() | 141 | mock, mock_base, log = start_mock() |
| 138 | os.environ["WEBSEARCH_MOCK_BASE"] = mock_base | 142 | os.environ["WEBSEARCH_MOCK_BASE"] = mock_base |
| 139 | os.environ["WEBSEARCH_SEARXNG_BASE"] = mock_base + "/searxng" | 143 | os.environ["WEBSEARCH_SEARXNG_BASE"] = mock_base + "/searxng" |
| @@ -229,8 +233,17 @@ def main(): | | @@ -229,8 +233,17 @@ def main(): |
| 229 | "document.getElementById('runMeta').textContent.indexOf('tavily') >= 0", | 233 | "document.getElementById('runMeta').textContent.indexOf('tavily') >= 0", |
| 230 | timeout=20000) | 234 | timeout=20000) |
| 231 | ok("switching the backend changes the next request") | 235 | ok("switching the backend changes the next request") |
| | 236 | + # The meta line carries the real elapsed time, which is |
| | 237 | + # 2-7 ms and therefore different on every run. The |
| | 238 | + # assertion above already proved it says "<n> ms"; the |
| | 239 | + # PNG pins the wording, not this run's stopwatch. |
| | 240 | + page.evaluate( |
| | 241 | + "var m=document.getElementById('runMeta');" |
| | 242 | + "if(m)m.textContent=m.textContent.replace(/\\d+ ms/,'N ms');" |
| | 243 | + "var e=document.getElementById('searxng');" |
| | 244 | + "if(e)e.value='';") |
| 232 | page.screenshot( | 245 | page.screenshot( |
| 233 | - path=os.path.join(DOCS, "ui-search-dark.png"), | 246 | + path=os.path.join(shots, "ui-search-dark.png"), |
| 234 | full_page=True) | 247 | full_page=True) |
| 235 | | 248 | |
| 236 | # Exa has no key: the provider's own message must appear. | 249 | # Exa has no key: the provider's own message must appear. |
| @@ -287,7 +300,15 @@ def main(): | | @@ -287,7 +300,15 @@ def main(): |
| 287 | page.reload(wait_until="networkidle") | 300 | page.reload(wait_until="networkidle") |
| 288 | page.wait_for_selector(".prov", timeout=15000) | 301 | page.wait_for_selector(".prov", timeout=15000) |
| 289 | | 302 | |
| 290 | - page.screenshot(path=os.path.join(DOCS, "ui-%s.png" % tag), | 303 | + # The mock server listens on a fresh port on every run, and |
| | 304 | + # that port lands in the SearXNG base field - so the PNG |
| | 305 | + # differed byte-for-byte between two green runs and any |
| | 306 | + # `git status` after `make e2e` showed seven modified |
| | 307 | + # screenshots. Blank the harness address so the picture is |
| | 308 | + # of the page's default state, not of this run's loopback. |
| | 309 | + page.evaluate("var e=document.getElementById('searxng');" |
| | 310 | + "if(e)e.value='';") |
| | 311 | + page.screenshot(path=os.path.join(shots, "ui-%s.png" % tag), |
| 291 | full_page=True) | 312 | full_page=True) |
| 292 | page.close() | 313 | page.close() |
| 293 | browser.close() | 314 | browser.close() |
| 294 | | 315 | |