Companies and Searches: follow, hide not mute, prune moved, one row style
Companies gets a Follow-a-company form, a combined affinity/on-off filter, and one .srow-style row per company (name, board or "from searches", open roles, on/off switch, affinity). The prune-by-region tool moves here from Searches, folded under the list in a <details>. The lede states the difference between switching a board off (stops reading it, closes its roles) and hiding a company (keeps reading it, keeps its roles out of the list and unscored). affinityControl becomes three icon toggles (favourite, like, hidden) instead of four letter buttons with a neutral one; pressing the pressed icon clears back to neutral. "Hidden" is the word everywhere the UI names affinity -1; the code keeps mute/hide_muted. CompanyOut carries each company's board subscription id and on-state, so the Companies page needs only /api/companies, not a second fetch of /api/sources. Setting a company's affinity now enqueues a score job, deduped by the queue to one run. Searches keeps only the search form and list, in the same row style; company boards and the prune tool left with it, and "Pull now" left for Pulls (package B3). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
7d31cca394
commit
55248555e9
8 files changed
+419
-318
No files matched your search
+27
-3
@@ -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:
|
||||
@@ -127,21 +133,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
|
||||
@@ -271,8 +282,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:
|
||||
|
||||
Reference in new issue
Block a user