Two tabs and a cog: settings shell, one ranking, a script per page, the phone frame
The top bar is Roles and Applications plus health's cog. Behind the cog,
/settings/{ranking,searches,companies,pulls,messages,account} share one row
of sub-tabs, an underlined row on a desktop and pills on a phone. The old
paths answer 301 with their query string.
Ranking edits the first enabled agent, or creates one, with the intent,
the weights and the gates under Advanced. The order menu on Roles reads
Newest and Best match with one enabled agent, and names them with several.
config.yaml keeps the Copenhagen starter; the other two are commented
examples in config.example.yaml.
roles.js is split into roles.js, applications.js, ranking.js and
companies.js; count, cell, debounce, the company list and the affinity
control live once in app.js. app.css gets the phone frame after health and
newsdesk: one-row bar, edge-to-edge panels, 44px targets and 16px fields on
a coarse pointer, hover only where there is one, safe areas. The app is
installable from a manifest and roledesk-coloured icons. Every lede touched
is written for the person using the app.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
8c4bc3112a
commit
7d31cca394
34 files changed
+848
-565
No files matched your search
+72
-22
@@ -15,7 +15,7 @@ from fastapi.testclient import TestClient
|
||||
from app.config import Config, ServerConfig
|
||||
from app.main import create_app
|
||||
from app.storage import Store
|
||||
from app.web import TABS
|
||||
from app.web import MOVED, SETTINGS, TABS
|
||||
from auth import AuthConfig
|
||||
from desk.models import Item
|
||||
|
||||
@@ -200,43 +200,93 @@ def test_set_status_validates_and_writes_an_event(
|
||||
|
||||
# -------------------------------------------------------------------- tabs
|
||||
|
||||
def test_every_tab_renders_with_the_whole_nav(client: TestClient) -> None:
|
||||
assert [t.label for t in TABS] == ["Roles", "Applications", "Agents", "Companies",
|
||||
"Sources", "Jobs", "Schedules", "Messages", "Account"]
|
||||
for tab in TABS:
|
||||
def test_every_page_renders_with_the_whole_nav(client: TestClient) -> None:
|
||||
assert [t.label for t in TABS] == ["Roles", "Applications"]
|
||||
assert [t.label for t in SETTINGS] == ["Ranking", "Searches", "Companies", "Pulls",
|
||||
"Messages", "Account"]
|
||||
assert all(t.path.startswith("/settings/") for t in SETTINGS)
|
||||
for tab in (*TABS, *SETTINGS):
|
||||
res = client.get(tab.path)
|
||||
assert res.status_code == 200, f"{tab.path} answered {res.status_code}"
|
||||
assert "roledesk</title>" in res.text
|
||||
for other in TABS:
|
||||
assert f">{other.label}</a>" in res.text
|
||||
assert 'href="/settings" class="icon' in res.text
|
||||
assert '<link rel="manifest" href="/static/manifest.json">' in res.text
|
||||
|
||||
|
||||
def test_each_roledesk_tab_is_a_shell_for_roles_js(client: TestClient) -> None:
|
||||
for path, container in [("/", 'id="roles-list"'),
|
||||
("/applications", 'id="applications-list"'),
|
||||
("/agents", 'id="agents-list"'),
|
||||
("/companies", 'id="companies-list"')]:
|
||||
def test_the_cog_and_one_sub_tab_are_current_on_a_settings_page(client: TestClient) -> None:
|
||||
page = client.get("/settings/pulls").text
|
||||
assert 'class="icon active"' in page
|
||||
for tab in SETTINGS:
|
||||
assert f">{tab.label}</a>" in page
|
||||
assert page.count('aria-current="page"') == 1
|
||||
current = page.index('aria-current="page"')
|
||||
assert page.rindex('href="', 0, current) == page.index('href="/settings/pulls"')
|
||||
assert 'class="icon active"' not in client.get("/").text
|
||||
|
||||
|
||||
def test_settings_is_ranking(client: TestClient) -> None:
|
||||
res = client.get("/settings", follow_redirects=False)
|
||||
assert res.status_code == 302 and res.headers["location"] == "/settings/ranking"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("old", "new"), sorted(MOVED.items()))
|
||||
def test_an_old_tab_moves_permanently_and_keeps_its_query(
|
||||
client: TestClient, old: str, new: str) -> None:
|
||||
res = client.get(old, follow_redirects=False)
|
||||
assert res.status_code == 301 and res.headers["location"] == new
|
||||
res = client.get(f"{old}?agent=3&q=a+b", follow_redirects=False)
|
||||
assert res.status_code == 301 and res.headers["location"] == f"{new}?agent=3&q=a+b"
|
||||
assert client.get(old).status_code == 200
|
||||
|
||||
|
||||
def test_each_page_loads_only_its_own_script(client: TestClient) -> None:
|
||||
scripts = {"roles.js", "applications.js", "ranking.js", "companies.js", "sources.js",
|
||||
"jobs.js", "messages.js"}
|
||||
for path, container, script in [
|
||||
("/", 'id="roles-list"', "roles.js"),
|
||||
("/applications", 'id="applications-list"', "applications.js"),
|
||||
("/settings/ranking", 'id="ranking-form"', "ranking.js"),
|
||||
("/settings/searches", 'id="searches-list"', "sources.js"),
|
||||
("/settings/companies", 'id="companies-list"', "companies.js"),
|
||||
("/settings/pulls", 'id="kinds"', "jobs.js"),
|
||||
("/settings/messages", 'id="notices"', "messages.js")]:
|
||||
page = client.get(path).text
|
||||
assert container in page and "/static/roles.js" in page
|
||||
assert container in page, path
|
||||
assert [s for s in scripts if f"/static/{s}" in page] == [script], path
|
||||
# toasts.js before app.js before the page's own script: `api()` needs
|
||||
# `window.toast`, and roles.js needs `api()`.
|
||||
assert page.index("toasts.js") < page.index("app.js") < page.index("roles.js")
|
||||
# `window.toast`, and every page script needs `api()` and the helpers.
|
||||
assert page.index("toasts.js") < page.index("app.js") < page.index(f"/static/{script}")
|
||||
assert client.get(f"/static/{script}").status_code == 200
|
||||
assert "ROLEDESK_STATUSES" in client.get("/applications").text
|
||||
assert client.get("/static/roles.js").status_code == 200
|
||||
|
||||
|
||||
def test_the_sources_tab_is_a_shell_for_sources_js(client: TestClient) -> None:
|
||||
page = client.get("/sources").text
|
||||
def test_the_ranking_page_edits_one_ranking(client: TestClient) -> None:
|
||||
page = client.get("/settings/ranking").text
|
||||
assert 'id="a-intent"' in page and "<details" in page and 'id="a-gates"' in page
|
||||
assert 'id="a-delete"' not in page and 'id="a-new"' not in page
|
||||
assert 'id="agents-list"' not in page
|
||||
|
||||
|
||||
def test_the_searches_page_offers_the_jobindex_areas(client: TestClient) -> None:
|
||||
page = client.get("/settings/searches").text
|
||||
assert 'id="searches-list"' in page and 'id="boards-list"' in page
|
||||
assert page.index("app.js") < page.index("sources.js")
|
||||
assert 'value="1" selected>Region Hovedstaden' in page # from plugins.search
|
||||
assert client.get("/static/sources.js").status_code == 200
|
||||
|
||||
|
||||
def test_the_modules_bring_their_own_elements(client: TestClient) -> None:
|
||||
assert "<desk-jobs>" in client.get("/jobs").text
|
||||
assert "<desk-schedules>" in client.get("/schedules").text
|
||||
assert "<auth-account>" in client.get("/account").text
|
||||
pulls = client.get("/settings/pulls").text
|
||||
assert pulls.index("<desk-jobs>") < pulls.index("<desk-schedules>")
|
||||
assert "<auth-account>" in client.get("/settings/account").text
|
||||
|
||||
|
||||
def test_the_install_files_are_served(client: TestClient) -> None:
|
||||
manifest = client.get("/static/manifest.json").json()
|
||||
assert manifest["name"] == "roledesk" and manifest["display"] == "standalone"
|
||||
for icon in manifest["icons"]:
|
||||
assert client.get(icon["src"]).status_code == 200
|
||||
assert client.get("/static/apple-touch-icon.png").status_code == 200
|
||||
|
||||
|
||||
def test_pull_is_declared_every_six_hours(client: TestClient) -> None:
|
||||
@@ -275,7 +325,7 @@ def test_a_locked_app_shuts_every_tab_and_the_api(
|
||||
config = Config(server=ServerConfig(host="127.0.0.1", port=0),
|
||||
database=tmp_path / "locked.db", auth=AuthConfig(enabled="always"))
|
||||
with TestClient(create_app(config), follow_redirects=False) as locked:
|
||||
for tab in TABS:
|
||||
for tab in (*TABS, *SETTINGS):
|
||||
assert locked.get(tab.path).status_code == 303
|
||||
assert locked.get("/api/roles").status_code == 401
|
||||
assert locked.get("/health").status_code == 200
|
||||
|
||||
Reference in new issue
Block a user