Merge branch 'worktree-agent-a8ed2a864305c4381'

# Conflicts:
#	app/web/api.py
This commit is contained in:
Wolf committed 2026-09-25 22:03:19 +02:00
commit fe83330c82
8 files changed
+418 -319

No files matched your search

+27 -3
View File
@@ -7,6 +7,7 @@ from __future__ import annotations
from collections.abc import Iterator
from datetime import UTC, datetime, timedelta
from pathlib import Path
from typing import Any
import pytest
from fastapi import FastAPI
@@ -55,6 +56,11 @@ def store(app: FastAPI) -> Store:
return app.state.store
@pytest.fixture
def queue(app: FastAPI) -> Any:
return app.state.queue
@pytest.fixture
def client(app: FastAPI) -> Iterator[TestClient]:
with TestClient(app) as c:
@@ -229,21 +235,26 @@ def test_companies_lists_board_and_open_role_count(
sub = store.add_subscription("ats", "greenhouse:acme", company="Acme", board="greenhouse")
store.add_company("Acme", key="acme")
store.upsert_role(posting("1", company="Acme"), sub)
store.add_company("Other", key="other") # known only from a search: no board
res = client.get("/api/companies")
assert res.status_code == 200
[row] = [c for c in res.json() if c["key"] == "acme"]
assert row == {"key": "acme", "name": "Acme", "board": "greenhouse",
"affinity": 0, "open_roles": 1}
"subscription_id": sub.id, "on": True, "affinity": 0, "open_roles": 1}
[other] = [c for c in res.json() if c["key"] == "other"]
assert (other["board"], other["subscription_id"], other["on"]) == ("", None, None)
def test_set_affinity_validates_and_updates(client: TestClient, store: Store) -> None:
def test_set_affinity_validates_updates_and_enqueues_a_score(
client: TestClient, store: Store, queue: Any) -> None:
store.add_company("Acme", key="acme")
res = client.post("/api/companies/acme/affinity", json={"affinity": 2})
assert res.status_code == 200
assert res.json()["affinity"] == 2
assert store.company("acme").affinity == 2 # type: ignore[union-attr]
assert queue.jobs.last("score", states=("queued", "running", "done")) is not None
assert client.post("/api/companies/acme/affinity", json={"affinity": 9}).status_code == 422
assert client.post("/api/companies/nope/affinity", json={"affinity": 1}).status_code == 404
@@ -396,8 +407,21 @@ def test_the_ranking_page_edits_one_ranking(client: TestClient) -> None:
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 'id="searches-list"' in page
assert 'value="1" selected>Region Hovedstaden' in page # from plugins.search
# Boards and the prune tool moved to Companies; a search has no board.
assert 'id="boards-list"' not in page and 'id="prune-form"' not in page
assert 'id="pull-now"' not in page # moved to Pulls
def test_the_companies_page_offers_the_follow_form_and_the_prune_tool(
client: TestClient) -> None:
page = client.get("/settings/companies").text
assert 'id="companies-list"' in page
assert 'id="b-host"' in page and 'id="b-slug"' in page and 'id="b-name"' in page
assert '<option value="greenhouse">' in page and '<option value="personio">' in page
assert 'id="prune-form"' in page and "Switch off boards with no roles in a region" in page
assert "hidden" in page.lower() and "mute" not in page.lower()
def test_the_modules_bring_their_own_elements(client: TestClient) -> None: