fix(shot): mattermost hook v2 — interstitial appears on ANY first-visit route incl /login (proven byte-identical PNG); click 'View in Browser' best-effort then settle; unit test covers click + no-interstitial fallback; 207 pass, lint PASS
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
autonomic-bot
2026-06-11 06:45:43 +00:00
parent 5fc86991dd
commit 3c33129ebd
2 changed files with 31 additions and 8 deletions

View File

@ -138,14 +138,21 @@ def test_mattermost_screenshot_hook_lands_login():
status = 200
class _NavPage(_FakePage):
def __init__(self):
def __init__(self, click_raises=False):
super().__init__([])
self.urls = []
self.clicks = []
self._click_raises = click_raises
def goto(self, url, wait_until=None, timeout=None):
self.urls.append(url)
return _Resp()
def click(self, selector, timeout=None):
self.clicks.append(selector)
if self._click_raises:
raise TimeoutError("no interstitial")
tests_dir = os.path.join(os.path.dirname(__file__), "..")
meta = meta_mod.load("mattermost-lts", tests_dir=tests_dir)
hook = S._load_screenshot_hook(meta)
@ -153,7 +160,14 @@ def test_mattermost_screenshot_hook_lands_login():
page = _NavPage()
hook(page, meta_mod.hook_ctx("mm.example.org", meta))
assert page.urls == ["https://mm.example.org/login"]
assert page.idle_waits, "hook must settle before the harness snaps"
assert page.clicks == ["text=View in Browser"], "hook must click through the interstitial"
assert len(page.idle_waits) == 2, "hook must settle after nav AND after the click"
# no interstitial (already on the form): the click times out and the hook still succeeds
page2 = _NavPage(click_raises=True)
hook(page2, meta_mod.hook_ctx("mm.example.org", meta))
assert page2.clicks == ["text=View in Browser"]
assert len(page2.idle_waits) == 1, "failed click must skip the second settle, not raise"
def test_screenshot_reachable_through_real_load_path(tmp_path):