"""Where the Portfolio page's buttons land, measured in a real browser. Test users reported two things no markup test can see: with ten years of financial-year tabs the header's buttons dropped under the title instead of staying beside it, and the holdings table's Manage holdings and Edit columns sat on the left rather than over the table, on the right. """ from __future__ import annotations import json import re import subprocess import sys from pathlib import Path import pytest import factories as fac from test_routes import bind_to_only_portfolio, make_login ROOT = Path(__file__).resolve().parent.parent sys.path.insert(0, str(ROOT)) from tools.browser import find_chrome # noqa: E402 pytestmark = pytest.mark.visual CHROME = find_chrome() if CHROME is None: pytest.skip("no headless Chrome on this machine", allow_module_level=True) HTML = {"accept": "text/html"} STATIC = ROOT / "app" / "static" MEASURE = """ """ # The page goes in an iframe of the wanted width: headless Chrome will not # make a window narrower than 500px. Same approach as test_visual.py. WRAPPER = """
""" def _standalone(page: str) -> str: def script(match: re.Match) -> str: path = STATIC / match.group(1) if match.group(1) == "idle.js" or not path.is_file(): return "" return "" page = re.sub(r'', script, page) page = re.sub(r']*>', lambda _m: "", page) return page.replace("