"""The Roles page's shell: the feed and a role's reader are one page, so `/roles/{uid}` renders what `/` renders with that role open. The script itself is exercised in a browser, not here; this holds what the server decides.""" from __future__ import annotations from collections.abc import Iterator from datetime import UTC, datetime from pathlib import Path import pytest from fastapi import FastAPI from fastapi.testclient import TestClient from app.config import Config, ServerConfig from app.main import create_app from app.models import HAND_REASONS from app.storage import Store from desk.models import Item def posting(source_id: str = "1", **raw: object) -> Item: item = Item(source_id=source_id, location=f"https://boards.example/acme/{source_id}", title="Senior Backend Engineer", body="Build things.", published_at=datetime(2026, 9, 20, tzinfo=UTC), raw=dict(raw)) item.source = "ats" return item @pytest.fixture def app(tmp_path: Path) -> FastAPI: return create_app(Config(server=ServerConfig(host="127.0.0.1", port=0), database=tmp_path / "roledesk.db")) @pytest.fixture def store(app: FastAPI) -> Store: return app.state.store @pytest.fixture def client(app: FastAPI) -> Iterator[TestClient]: with TestClient(app) as c: yield c def test_the_roles_page_is_the_rail_the_feed_and_a_shut_reader(client: TestClient) -> None: page = client.get("/").text for part in ('id="rail"', 'id="list"', 'id="roles-list"', 'id="reader"', 'id="rail-toggle"', 'id="search"', 'id="sort"', 'id="period"', 'id="tags"'): assert part in page, part assert '