"""The Imports & exports page's arrangement. Two sections of equal halves — Imports (broker file · dividend statement) and Exports (download · what's in each) — and moved the Import templates section into a **Manage templates** dialog. The dialog is not just tidying: the section it replaces could install and remove a template but never hand one back, so a correction made here could not leave the machine. Download is the verb that closes the loop the contribution flow opens. """ from __future__ import annotations import re import pytest from test_routes import make_login HTML = {"accept": "text/html"} GOOD = b""" name: Example Registry match: any: - Example Registry Services fields: payment_date: after: ["payment date"] type: date net_amount: after: ["net amount"] type: money """ @pytest.fixture def admin(client, session_factory, tmp_path, monkeypatch, app_module): """Signed in as an admin, with the drop-in directory pointed at tmp_path — the real default is `/data/formats`, which a test must never write to.""" monkeypatch.setattr(app_module.settings.imports, "templates_dir", str(tmp_path)) make_login(client, session_factory) return tmp_path def _page(client, session_factory) -> str: make_login(client, session_factory) response = client.get("/imports-exports", headers=HTML) assert response.status_code == 200 return response.text def test_the_page_has_an_imports_and_an_exports_section(client, session_factory): page = _page(client, session_factory) assert '

Imports

' in page assert '

Exports

' in page def test_the_import_templates_section_is_gone_from_the_page(client, session_factory): """It became a button. Templates are something you manage occasionally, not a third of a page you read every time you import a file.""" page = _page(client, session_factory) body = page[:page.index("', page, re.S) assert found, "no Manage templates dialog" dialog = found.group(0) assert 'action="/imports-exports/formats"' in dialog, "cannot install" # Download and remove are per-template rows, so they need one installed — # see the download tests below. With none, the dialog says so rather than # rendering an empty list. assert "No custom templates installed" in dialog def test_the_two_import_panels_are_equal_halves(client, session_factory): """`.columns` is 1fr 2fr, which pushed the pair off centre for no reason.""" page = _page(client, session_factory) assert '
' in page assert '
' not in page def test_the_dialog_is_reachable_without_script(client, session_factory): """A `` with no `open` is display:none, so the button being the only way in would hide template management entirely.""" page = _page(client, session_factory) assert "