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

@ -21,11 +21,17 @@ EXTRA_ENV = {"TIMEOUT": "600"}
def SCREENSHOT(page, ctx):
"""Land the real sign-in form for the CI card (phase-shot). The default landing capture gets
mattermost's "view in desktop app or browser?" interstitial at `/` — a real page but not
representative of the app. `/login` renders the standard login form directly. Credential-free
(empty fields, R7 secret-safety: never a page showing generated secrets); the harness snaps
the PNG after this returns."""
"""Land the real sign-in form for the CI card (phase-shot). Mattermost serves a
"view in desktop app or browser?" interstitial on a browser's FIRST visit to ANY route
(including /login — proven by shot-proof2-mattermost-lts: byte-identical interstitial PNG with
and without a plain /login hook); a real user clicks "View in Browser" to reach the login
form, so the hook does exactly that. Click + second settle are best-effort (if the
interstitial is absent we are already on the form). Credential-free (empty fields, R7
secret-safety); the harness snaps the PNG after this returns. Waits are kept short (8s/3s/8s)
so the realistic hook path stays well inside the ~60s step budget — the 45s nav deadline is
only burned when the app never serves, and then the hook raises before any settle."""
import contextlib
from harness import browser as harness_browser
from harness import screenshot as screenshot_mod
@ -36,4 +42,7 @@ def SCREENSHOT(page, ctx):
deadline_seconds=screenshot_mod.NAV_DEADLINE_S,
wait_until="domcontentloaded",
)
screenshot_mod.settle(page)
screenshot_mod.settle(page, 8_000)
with contextlib.suppress(Exception):
page.click("text=View in Browser", timeout=3_000)
screenshot_mod.settle(page, 8_000)

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):