Files
cc-ci/tests/unit/test_screenshot.py
autonomic-bot daa7edd3a7 feat(3 U1-scaffold): app screenshot capture module (offline; not yet wired)
harness/screenshot.py: best-effort Playwright capture of the live app (reuses harness browser).
Default = landing page (credential-free, secret-safe R7); recipes needing post-login opt into a
recipe-meta SCREENSHOT hook responsible for avoiding secret pages. Every failure swallowed -> None
(cosmetics never block, R7). Pure helpers unit-tested. Orchestrator wiring + live demo come after U0
PASSes (avoid deploy contention with the Adversary's cold U0 re-runs).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 06:05:39 +00:00

32 lines
985 B
Python

"""Unit tests for the pure helpers in harness.screenshot (Phase 3 U1).
The Playwright capture itself needs a live app (exercised in the U1 live demo); here we cover the
pure bits: the artifact path and the SCREENSHOT-hook resolution. Run cold:
cc-ci-run -m pytest tests/unit/test_screenshot.py -q
"""
from __future__ import annotations
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "runner"))
from harness import screenshot as S # noqa: E402
def test_screenshot_path():
assert S.screenshot_path("/var/lib/cc-ci-runs/42") == "/var/lib/cc-ci-runs/42/screenshot.png"
def test_hook_none_when_absent():
assert S._load_screenshot_hook(None) is None
assert S._load_screenshot_hook({}) is None
assert S._load_screenshot_hook({"SCREENSHOT": "not-callable"}) is None
def test_hook_returned_when_callable():
def hook(page, domain, meta):
pass
assert S._load_screenshot_hook({"SCREENSHOT": hook}) is hook