A search agent is a persona, and every like or pass belongs to the one being viewed. The rail now opens on Viewing as: a full-width chooser, the name alone with one agent, a note with none, remembered in the URL and localStorage. The vote buttons, the reader's affinity control, the feed, the tag counts and the reader fetch all carry that agent; before, votes sent none and every one landed on the default agent. Best first and Newest first are back as the segmented control under Order, independent of the agent. The rail selects no longer clip descenders: Chrome ignores line-height on a select, so the fixed box is gone in favour of padding and a min-height. Settings render inside a sticky rail (Search agents; Sources with Job boards, Company boards, Runs, Messages; Account), a strip under the header on a phone, so Runs is one click away however long the company list gets. Sources shows one section at a time, chosen by the fragment, so the old redirects still land. Search agents are cards, newest first: name, an On/Off switch with its word, the intent in full, the weights, Edit in place, New agent on top, and a link to Roles as that agent. Switching one on rescores it. replace_scores writes nothing for an agent deleted while score was running, instead of failing the run on the foreign key. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
93 lines
3.6 KiB
Python
93 lines
3.6 KiB
Python
"""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.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 '<article id="reader" aria-label="Role" hidden>' in page
|
|
assert "data-reader" not in page.split("<header", 1)[0]
|
|
assert "<title>Roles — roledesk</title>" in page
|
|
assert "/static/roles.js" in page and "/static/judge.js" in page
|
|
|
|
|
|
def test_the_rail_opens_on_viewing_as_then_filters_then_order(client: TestClient) -> None:
|
|
rail = client.get("/").text.split('<aside id="rail"', 1)[1].split("</aside>", 1)[0]
|
|
for part in ('id="agent"', 'id="agent-one"', 'id="agent-none"', 'href="/settings/agents"'):
|
|
assert part in rail, part
|
|
headings = [rail.index(h) for h in ("Viewing as", "<h3>Filters</h3>", "<h3>Order</h3>",
|
|
"<h3>Tags")]
|
|
assert headings == sorted(headings)
|
|
# The agent is not an order any more: the segmented control is the order.
|
|
assert rail.index('id="sort"') > rail.index("<h3>Order</h3>")
|
|
assert rail.count('id="agent"') == 1
|
|
|
|
|
|
def test_a_role_address_is_the_same_page_with_its_reader_open(
|
|
client: TestClient, store: Store) -> None:
|
|
store.upsert_role(posting("1", company="Acme"))
|
|
uid = posting("1").uid
|
|
|
|
page = client.get(f"/roles/{uid}")
|
|
assert page.status_code == 200
|
|
assert 'id="roles-list"' in page.text and "/static/roles.js" in page.text
|
|
assert '<body data-reader="open">' in page.text
|
|
assert '<article id="reader" aria-label="Role">' in page.text
|
|
assert "<title>Senior Backend Engineer — roledesk</title>" in page.text
|
|
# Roles stays the lit tab, though the path is not its own.
|
|
assert 'href="/"\n class="active" aria-current="page">Roles' in page.text
|
|
|
|
missing = client.get("/roles/nope")
|
|
assert missing.status_code == 404 and "text/html" in missing.headers["content-type"]
|
|
|
|
|
|
def test_the_read_page_of_its_own_is_gone(client: TestClient) -> None:
|
|
assert client.get("/static/role.js").status_code == 404
|
|
other = client.get("/applications").text
|
|
assert 'id="rail-toggle"' not in other and 'id="search"' not in other
|
|
assert "<main>" in other
|