Merge the seniority range filter: From, To and Track in the rail (wp-sen-b-range)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 13:14:45 +02:00
commit d529f6c0ce
6 files changed
+207 -71

No files matched your search

+4 -5
View File
@@ -573,7 +573,7 @@ kbd {
two halves split the width, so the choice is one target each rather than
two words pushed against the edge. */
.seg { display: flex; }
#sort { padding: 0 .3rem; }
#sort, #f-track { padding: 0 .3rem; }
#rail .seg button {
flex: 1; text-align: center;
font-size: .8rem; padding: .18rem .55rem;
@@ -644,13 +644,12 @@ kbd {
.rail-fields { display: flex; flex-direction: column; gap: .45rem; padding-top: .6rem; }
.rail-fields input[type="text"], .rail-fields select { width: auto; }
.rail-fields .check { padding: 0 .3rem; white-space: normal; }
/* A filter and what widens it: Seniority's heading, its levels and "no
level"; Pay's select and "no pay". Closer together than the fields. */
/* A filter and what widens it: Seniority's heading, its From and To, the
track and "no level"; Pay's select and "no pay". Closer together than the
fields. */
.rail-facet { display: flex; flex-direction: column; gap: .3rem; }
.rail-fields .rail-field { margin: .25rem .3rem 0; }
.rail-facet .check { font-size: .84rem; }
/* The levels are the tags' chips, and wrap as they do. */
#f-seniority:not(:empty) { display: flex; flex-wrap: wrap; gap: .25rem; padding: 0 .3rem; }
/* `?company=` and `?place=` from another page's link: a plain chip under
its field, which takes it off. */
.rail-legacy { padding: 0 .3rem; }
+86 -39
View File
@@ -37,7 +37,7 @@
*
* The filters are in the query string, so a reload or a link keeps them, and
* each one set is a history entry, so back takes it off again: a tag, the
* period, Show read, a select, a checkbox, a seniority level, a company or
* period, Show read, a select, a checkbox, a seniority bound or track, a company or
* place chip picked or removed, Clear, and a company's name. Text is the
* exception: the search box replaces the entry, or back would step through a
* search a letter at a time. Who is viewing and the
@@ -70,8 +70,11 @@
* `region:skane`), several joined by OR. `?company=` and `?place=`, the
* substrings of the links from other pages, still filter and show as a chip
* of their own to take off; nothing in the rail types a new one. Seniority
* (a From and a To rung and a Track, `level_from`, `level_to` and `track`)
* and Pay carry the counts of `/api/roles/facets`, asked after each reload
* with the feed's own parameters, so each says what a click would add.
* with the feed's own parameters, so each says what a click would add. The
* rungs and which level is on which come from the page (`ROLEDESK_LADDER`),
* an old `?seniority=` is ignored.
*
* The list is paged: 60 rows, then 60 more each time the end of the list comes
* within 600px of the screen, with the offset the rows already shown. Back to
@@ -101,6 +104,17 @@
const VIEWING = "roledesk.agent";
const number = new Intl.NumberFormat("en");
// The seniority ladder from the page: `rungs` in order and, for each level
// word, its rung (an index into them) and track (`app.models.LADDER`).
const LADDER = window.ROLEDESK_LADDER;
// What each rung is called on each side of the ladder, [individual, people].
// The rungs below Staff have no side and are named as they are.
const RUNG_SIDES = {
staff: ["Staff", "Manager"], principal: ["Principal", "Senior Manager"],
distinguished: ["Distinguished", "Director"],
};
const TRACKS = { "": "Both", ic: "Individual", people: "People" };
// What the list is in the order of. Best first is the viewing agent's
// score, moved by its votes; Newest first is first seen.
const SORTS = { score: "Best first", time: "Newest first" };
@@ -120,26 +134,27 @@
// Everything `clearFilters` has to put back, in one place, so a new filter
// added here cannot be forgotten there. `company` and `place` are the
// substrings of links from other pages; `companyKeys` and `places` are the
// rail's chips. `seniorityUnknown` and `payUnknown` are the "and roles
// with no level / no pay" boxes, asked only while a level or a pay option
// is picked.
// rail's chips. `levelFrom`, `levelTo` and `track` are the seniority range;
// `seniorityUnknown` and `payUnknown` are the "and roles with no level / no
// pay" boxes, asked only while a range, a track or a pay option is picked.
function blankFilter() {
return {
sort: "score", agent: null, period: "all", tags: new Set(), showRead: true,
company: "", place: "", function: "", remote: "", judged: "", pay: "",
showMuted: false, gated: false, companyKeys: [], places: [],
seniority: [], seniorityUnknown: true, payUnknown: false,
levelFrom: "", levelTo: "", track: "", seniorityUnknown: true, payUnknown: false,
};
}
/** How many filters are on, for the burger; `more` counts only the ones
under "More filters", for its summary. A chip or a level is one each,
as a tag is; the "no level" and "no pay" boxes widen a filter already
under "More filters", for its summary. A chip, a bound or the track is
one each, as a tag is; the "no level" and "no pay" boxes widen a filter already
counted. */
function filtersOn(f = state.filter, { more = false } = {}) {
const folded = [f.company.trim(), f.place.trim(), f.function, f.remote, f.pay, f.judged,
f.showMuted, sortShown() === "score" && f.gated].filter(Boolean).length
+ f.companyKeys.length + f.places.length + f.seniority.length;
+ f.companyKeys.length + f.places.length
+ [f.levelFrom, f.levelTo, f.track].filter(Boolean).length;
if (more) return folded;
return folded + [!f.showRead, f.period !== "all"].filter(Boolean).length + f.tags.size;
}
@@ -189,6 +204,9 @@
const sortShown = () =>
(state.filter.sort === "score" && state.filter.agent !== null ? "score" : "time");
/** Whether a bound or a track is set, which is what "no level" asks about. */
const seniorityOn = (f = state.filter) => Boolean(f.levelFrom || f.levelTo || f.track);
/** The feed's query for a filter, the one on screen unless told. */
function feedParams(f = state.filter, q = state.q) {
const p = new URLSearchParams();
@@ -202,9 +220,11 @@
f.tags.forEach((t) => p.append("tags", t));
f.companyKeys.forEach((key) => p.append("company_keys", key));
f.places.forEach((token) => p.append("places", token));
f.seniority.forEach((level) => p.append("seniority", level));
for (const [param, key] of [["level_from", "levelFrom"], ["level_to", "levelTo"], ["track", "track"]]) {
if (f[key]) p.set(param, f[key]);
}
// Each box is sent only off its default, and only while its filter is on.
if (f.seniority.length && !f.seniorityUnknown) p.set("seniority_unknown", "false");
if (seniorityOn(f) && !f.seniorityUnknown) p.set("seniority_unknown", "false");
if (f.pay && f.payUnknown) p.set("pay_unknown", "true");
if (f.agent !== null) {
p.set("agent", String(f.agent));
@@ -236,7 +256,10 @@
f.tags = new Set(q.getAll("tags"));
f.companyKeys = [...new Set(q.getAll("company_keys").filter(Boolean))];
f.places = [...new Set(q.getAll("places").filter(Boolean))];
f.seniority = [...new Set(q.getAll("seniority").filter(Boolean))];
// A name the ladder does not know is dropped, rather than sent for a 422.
f.levelFrom = LADDER.rungs.includes(q.get("level_from")) ? q.get("level_from") : "";
f.levelTo = LADDER.rungs.includes(q.get("level_to")) ? q.get("level_to") : "";
f.track = q.get("track") in TRACKS ? q.get("track") : "";
f.seniorityUnknown = q.get("seniority_unknown") !== "false";
f.payUnknown = q.get("pay_unknown") === "true";
if (!view) return;
@@ -688,8 +711,6 @@
el.querySelector("button").onclick = () => setFilter({ [key]: "" });
}
const levelLabel = (level) => level.charAt(0).toUpperCase() + level.slice(1);
/* Which of the facet's pay states each Pay option keeps (`Store.PAY`),
so the option's count is theirs added up: 'stated' in the facet is a
line with no figure, the option "stated_only". */
@@ -698,33 +719,50 @@
normalised: ["normalised"], stated_only: ["stated"],
};
/* Seniority and Pay with their counts. The levels are the facet's, in the
server's order; until it answers, the ones pressed, so a level read from
the address can be taken off at once. Built again only when a level,
a count or a press changed, so a pressed button keeps its focus. */
/* A rung's name on the track chosen: with both, the two sides together. */
function rungLabel(rung, track) {
const sides = RUNG_SIDES[rung];
if (!sides) return rung.charAt(0).toUpperCase() + rung.slice(1);
return track === "ic" ? sides[0] : track === "people" ? sides[1] : sides.join(" / ");
}
/* How many roles a rung holds on the track chosen, the facet's per-level
counts added up: a level with no track counts on either. Undefined
until the facet answers. */
function rungCount(facets, rung, track) {
if (!facets) return undefined;
const at = LADDER.rungs.indexOf(rung);
return facets.seniority.reduce((sum, x) => {
const place = LADDER.levels[x.value];
return place && place[0] === at && (!track || !place[1] || place[1] === track)
? sum + x.count : sum;
}, 0);
}
/* Seniority and Pay with their counts. The rungs of both selects are the
ladder's, worded for the track; the option is set only when its text
changed, since the rail is drawn again on every filter and rewriting an
open select shuts it. */
function renderFacets() {
const f = state.filter;
const facets = state.facets;
const countOf = (list, value) => list?.find((x) => x.value === value)?.count;
const shown = (n) => (n === undefined ? "" : number.format(n));
const levels = facets ? facets.seniority.map((x) => x.value).filter(Boolean) : [];
for (const level of f.seniority) if (!levels.includes(level)) levels.push(level);
const row = $("#f-seniority");
const counts = levels.map((level) => countOf(facets?.seniority, level));
const sig = JSON.stringify([levels, counts, f.seniority]);
if (row.dataset.key !== sig) {
row.dataset.key = sig;
row.innerHTML = levels.map((level, i) => `
<button type="button" class="tag" data-level="${esc(level)}"
aria-pressed="${f.seniority.includes(level)}"
>${esc(levelLabel(level))}${counts[i] === undefined ? ""
: `<span class="count">${shown(counts[i])}</span>`}</button>`).join("");
row.querySelectorAll("[data-level]").forEach((b) => {
b.onclick = () => toggleLevel(b.dataset.level);
for (const [id, key] of [["f-level-from", "levelFrom"], ["f-level-to", "levelTo"]]) {
const select = document.getElementById(id);
LADDER.rungs.forEach((rung, i) => {
const n = rungCount(facets, rung, f.track);
const text = rungLabel(rung, f.track) + (n === undefined ? "" : ` · ${shown(n)}`);
const option = select.options[i + 1];
if (option.textContent !== text) option.textContent = text;
});
setValue(id, f[key]);
}
$("#f-seniority-unknown-row").hidden = !f.seniority.length;
$("#f-track").querySelectorAll("[data-track]").forEach((b) => {
b.setAttribute("aria-pressed", String(f.track === b.dataset.track));
});
$("#f-seniority-unknown-row").hidden = !seniorityOn(f);
setValue("f-seniority-unknown", f.seniorityUnknown);
$("#f-seniority-unknown-count").textContent = shown(countOf(facets?.seniority, ""));
@@ -740,13 +778,11 @@
$("#f-pay-unknown-count").textContent = shown(countOf(facets?.pay, ""));
}
/* A level pressed or let go, pushed as a filter. The last one let go
/* A bound or the track set, pushed as a filter. The last one taken off
ticks "no level" again, which is how the box starts for the next. */
function toggleLevel(level) {
const f = state.filter;
const next = f.seniority.includes(level)
? f.seniority.filter((l) => l !== level) : [...f.seniority, level];
setFilter({ seniority: next, seniorityUnknown: next.length ? f.seniorityUnknown : true });
function setSeniority(patch) {
const next = { ...state.filter, ...patch };
setFilter({ ...patch, seniorityUnknown: seniorityOn(next) ? next.seniorityUnknown : true });
}
/* Viewing as: a select of the enabled agents, also when there is one, and
@@ -1636,6 +1672,17 @@
}));
$("#f-pay-unknown").addEventListener("change",
(e) => setFilter({ payUnknown: e.target.checked }));
// From and To hold "" and the rungs; the options are the ladder's.
for (const [id, key] of [["f-level-from", "levelFrom"], ["f-level-to", "levelTo"]]) {
$(`#${id}`).innerHTML = `<option value="">Any level</option>` + LADDER.rungs.map((rung) =>
`<option value="${esc(rung)}"></option>`).join("");
$(`#${id}`).addEventListener("change", (e) => setSeniority({ [key]: e.target.value }));
}
$("#f-track").innerHTML = Object.entries(TRACKS).map(([key, label]) =>
`<button type="button" data-track="${key}">${label}</button>`).join("");
$("#f-track").querySelectorAll("[data-track]").forEach((b) => {
b.onclick = () => { if (b.dataset.track !== state.filter.track) setSeniority({ track: b.dataset.track }); };
});
$("#f-seniority-unknown").addEventListener("change",
(e) => setFilter({ seniorityUnknown: e.target.checked }));
$("#f-show-muted").addEventListener("change",
+16 -4
View File
@@ -78,12 +78,18 @@
<div id="f-company-text" class="rail-legacy" hidden></div>
<div id="f-place"></div>
<div id="f-place-text" class="rail-legacy" hidden></div>
{# The levels come with their counts from /api/roles/facets, so the
server's list is the one shown. "No level" is a question only
once a level is pressed. #}
{# From and to are the rungs of `app.models.RUNGS`, drawn by roles.js
from `ROLEDESK_LADDER` with counts from
/api/roles/facets; the track says which side of the ladder
counts. "No level" is a question only once a bound or a track is
set. #}
<div class="rail-facet" role="group" aria-labelledby="f-seniority-label">
<span class="rail-field" id="f-seniority-label">Seniority</span>
<div id="f-seniority" class="rail-chips"></div>
<label class="rail-field" for="f-level-from">From</label>
<select id="f-level-from"></select>
<label class="rail-field" for="f-level-to">To</label>
<select id="f-level-to"></select>
<div class="seg" id="f-track" role="group" aria-label="Track"></div>
<label class="check" id="f-seniority-unknown-row" hidden>
<input type="checkbox" id="f-seniority-unknown"> <span>and roles with no level<span
class="count" id="f-seniority-unknown-count"></span></span>
@@ -150,6 +156,12 @@
{% endblock %}
{% block scripts %}
<script>
// The seniority ladder, `RUNGS` and `LADDER` of app/models.py, so the
// rail's From, To and Track never hold a copy of the words; see
// app/web/pages.py.
window.ROLEDESK_LADDER = {{ ladder | tojson }};
</script>
{# base.html has no block in its head; a stylesheet linked from the body
applies all the same, and chips.css only adds to app.css. #}
<link rel="stylesheet" href="{{ asset('chips.css') }}">
+24 -14
View File
@@ -16,8 +16,8 @@ from pydantic import BaseModel, Field
from app import jobs, places
from app.models import (
AFFINITY, LEVELS, Agent, Application, Company, FetchTerms, Gate, Limits, Prompts, Role, RoleRow,
HandReason, ScoredRole, Status, Subscription, Weights, company_key,
AFFINITY, RUNGS, TRACKS, Agent, Application, Company, FetchTerms, Gate, Limits, Prompts, Role, RoleRow,
HandReason, ScoredRole, Status, Subscription, Weights, company_key, levels_between,
)
from app.storage import Store
from app.web.deps import ConfigDep, StoreDep
@@ -78,20 +78,27 @@ def _feed_filters(
pay: Literal["", "stated", "normalised", "stated_only"] = "",
company_keys: list[str] = Query(default=[]),
tokens: list[str] = Query(default=[], alias="places"),
seniority: list[str] = Query(default=[]),
level_from: str = "",
level_to: str = "",
track: str = "",
seniority_unknown: bool = True,
pay_unknown: bool = False,
) -> dict[str, Any]:
"""The feed's filters, as `Store.roles_page`, `count_roles` and
`role_facets` take them, read from the query of `GET /api/roles` and
`GET /api/roles/facets` alike. A place token that names nothing and a
level outside `LEVELS` are a 422 sentence, not an empty feed."""
`GET /api/roles/facets` alike. A place token that names nothing, a rung
outside `RUNGS` and a track outside `TRACKS` are a 422 sentence, not an
empty feed. The three seniority parameters become the levels between
them (`levels_between`), which is what the store filters on."""
for token in tokens:
if not places.known(token):
raise HTTPException(422, f"No place is known as {token!r}.")
for level in seniority:
if level not in LEVELS:
raise HTTPException(422, f"Seniority is one of {', '.join(LEVELS)}, not {level!r}.")
for name, rung in (("level_from", level_from), ("level_to", level_to)):
if rung and rung not in RUNGS:
raise HTTPException(422, f"{name} is one of {', '.join(RUNGS)}, not {rung!r}.")
if track and track not in TRACKS:
raise HTTPException(422, f"track is one of {', '.join(TRACKS)}, not {track!r}.")
levels = levels_between(level_from, level_to, track) if level_from or level_to or track else []
return {
"q": q or None, "company": company or None, "place": place or None,
"function": function or None, "remote": remote or None, "days": days,
@@ -99,7 +106,7 @@ def _feed_filters(
"tag_mode": tag_mode, "agent": _agent_id(store, agent),
"by_score": agent is not None and order == "score", "gated": gated,
"judged": judged or None, "pay": pay or None, "company_keys": company_keys,
"places": tokens, "seniority": seniority, "seniority_unknown": seniority_unknown,
"places": tokens, "seniority": list(levels), "seniority_unknown": seniority_unknown,
"pay_unknown": pay_unknown}
@@ -223,12 +230,15 @@ def list_roles(
as well.
`company` and `place` are substrings, kept for links from other pages.
The rail's fields are `company_keys` (repeated, exact keys),
The rail's fields are `company_keys` (repeated, exact keys) and
`places` (repeated place tokens, `app.places`: `country:DK`,
`region:skane`, `place:malmo`, matched on whole folded words) and
`seniority` (repeated levels), each several values joined by OR. A role
with no level passes the seniority filter unless `seniority_unknown` is
false. The parameters are read by `_feed_filters`.
`region:skane`, `place:malmo`, matched on whole folded words), several
values joined by OR, and the seniority range: `level_from` and
`level_to` (rungs of `RUNGS`, either or both) and `track` (`ic` or
`people`), which keep the levels between the two rungs on that track
(`levels_between`). A role with no level passes the seniority filter
unless `seniority_unknown` is false. The parameters are read by
`_feed_filters`.
A copy of another role (`Store.rebuild_dupes`) is never a row; its kept
role's `copies` says how many it stands for."""
+8 -3
View File
@@ -41,7 +41,7 @@ from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import HTMLResponse, RedirectResponse
from fastapi.templating import Jinja2Templates
from app.models import REMOTE, STATUSES
from app.models import LADDER, REMOTE, RUNGS, STATUSES
from app.web.deps import StoreDep
_ROOT = Path(__file__).resolve().parents[2]
@@ -104,6 +104,10 @@ COUNTRY_OPTIONS = [(c, c.upper()) for c in sorted(ADZUNA_COUNTRIES)]
REGION_OPTIONS = sorted(PLATSBANKEN_REGIONS.items(), key=lambda kv: kv[1])
#: The ATS hosts `plugins.ats` reads, for the Follow and Set board selects.
HOST_OPTIONS = list(HOSTS.items())
#: The seniority ladder as `roles.js` reads it: the rungs in order, and each
#: level's rung (an index into them) and track, so the words are `app.models`'
#: alone. The page carries it as JSON.
LADDER_JSON = {"rungs": list(RUNGS), "levels": {k: list(v) for k, v in LADDER.items()}}
def asset(path: str) -> str:
@@ -134,7 +138,8 @@ def page(request: Request, name: str, **context: object) -> HTMLResponse:
@router.get("/", response_class=HTMLResponse)
def roles(request: Request) -> HTMLResponse:
return page(request, "roles.html", functions=FUNCTION_OPTIONS,
remote_options=REMOTE_OPTIONS, pay_options=PAY_OPTIONS, role=None)
remote_options=REMOTE_OPTIONS, pay_options=PAY_OPTIONS,
ladder=LADDER_JSON, role=None)
@router.get("/roles/{uid}", response_class=HTMLResponse)
@@ -149,7 +154,7 @@ def role(request: Request, uid: str, store: StoreDep) -> HTMLResponse:
raise HTTPException(404, f"no such role: {uid}")
return page(request, "roles.html", functions=FUNCTION_OPTIONS,
remote_options=REMOTE_OPTIONS, pay_options=PAY_OPTIONS,
role=found, active_path="/")
ladder=LADDER_JSON, role=found, active_path="/")
@router.get("/applications", response_class=HTMLResponse)
+69 -6
View File
@@ -16,6 +16,7 @@ from fastapi.testclient import TestClient
from app.config import Config, ServerConfig
from app.main import create_app
from app.models import LADDER, RUNGS
from app.models import excerpt as models_excerpt
from app.storage import Store
from app.web import SETTINGS, TABS
@@ -116,15 +117,57 @@ def test_list_roles_filters_by_company_keys_places_and_seniority(
assert shown(places=["country:DK", "region:skane"]) == {"kbh", "billund", "malmo"}
assert shown(places=["place:kobenhavn"]) == {"kbh"}
assert shown(places=["Lund"]) == set() # not Billund
assert shown(seniority=["senior"]) == {"kbh", "berlin", "malmo"}
assert shown(seniority=["senior"], seniority_unknown="false") == {"kbh", "berlin"}
assert shown(seniority=["senior", "junior"], seniority_unknown="false",
assert shown(level_from="senior", level_to="senior") == {"kbh", "berlin", "malmo"}
assert shown(level_from="senior", level_to="senior",
seniority_unknown="false") == {"kbh", "berlin"}
assert shown(level_from="junior", level_to="senior", seniority_unknown="false",
company_keys=["other"]) == {"billund", "berlin"}
res = client.get("/api/roles", params={"places": ["region:atlantis"]})
assert res.status_code == 422 and "region:atlantis" in res.json()["detail"]
res = client.get("/api/roles", params={"seniority": ["boss"]})
res = client.get("/api/roles", params={"level_from": "boss"})
assert res.status_code == 422 and "boss" in res.json()["detail"]
res = client.get("/api/roles", params={"level_to": "boss"})
assert res.status_code == 422 and "level_to" in res.json()["detail"]
res = client.get("/api/roles", params={"track": "both"})
assert res.status_code == 422 and "both" in res.json()["detail"]
# The repeated `seniority` of the chip row is not a parameter any more.
assert shown(seniority=["junior"]) == set(uid)
def test_list_roles_filters_by_a_range_of_rungs_and_a_track(
client: TestClient, store: Store) -> None:
for sid, title in (("junior", "Junior Engineer"), ("senior", "Senior Engineer"),
("staff", "Staff Engineer"), ("manager", "Engineering Manager"),
("director", "Director of Engineering"), ("none", "Engineer")):
item = posting(sid)
item.title = title
upsert(store, item)
uid = {r.source_id: r.uid for r in store.roles()}
def shown(**params: Any) -> set[str]:
res = client.get("/api/roles", params=params)
assert res.status_code == 200, res.text
found = {r["uid"] for r in res.json()["items"]}
return {sid for sid, u in uid.items() if u in found}
everyone = set(uid)
assert shown() == everyone
# A range: a bound alone is open on the other side; no level passes.
assert shown(level_from="staff") == {"staff", "manager", "director", "none"}
assert shown(level_to="senior") == {"junior", "senior", "none"}
assert shown(level_from="senior", level_to="staff",
seniority_unknown="false") == {"senior", "staff", "manager"}
# A track keeps its own side and the rungs under Staff, which have none.
assert shown(track="ic", seniority_unknown="false") == {"junior", "senior", "staff"}
assert shown(track="people", seniority_unknown="false") == {
"junior", "senior", "manager", "director"}
# Both together.
assert shown(level_from="staff", track="people",
seniority_unknown="false") == {"manager", "director"}
assert shown(level_from="staff", track="ic", seniority_unknown="false") == {"staff"}
# `seniority_unknown` alone changes nothing: no bound, no track, no filter.
assert shown(seniority_unknown="false") == everyone
def test_role_facets_count_each_facet_under_the_other_filters(
@@ -137,8 +180,8 @@ def test_role_facets_count_each_facet_under_the_other_filters(
upsert(store, item)
res = client.get("/api/roles/facets",
params={"seniority": ["senior"], "seniority_unknown": "false",
"pay": "stated"})
params={"level_from": "senior", "level_to": "senior",
"seniority_unknown": "false", "pay": "stated"})
assert res.status_code == 200
body = res.json()
levels = {f["value"]: f["count"] for f in body["seniority"]}
@@ -146,6 +189,12 @@ def test_role_facets_count_each_facet_under_the_other_filters(
assert body["pay"] == [{"value": "normalised", "count": 1}, # a and b are senior
{"value": "stated", "count": 0}, {"value": "", "count": 1}]
assert client.get("/api/roles/facets", params={"places": ["country:ZZ"]}).status_code == 422
assert client.get("/api/roles/facets", params={"track": "boss"}).status_code == 422
# A track counts the same levels; the facet leaves its own filter out.
res = client.get("/api/roles/facets", params={"track": "people"})
assert res.status_code == 200
assert {f["value"]: f["count"] for f in res.json()["seniority"]}["senior"] == 2
def test_suggest_companies_folds_the_name_and_leaves_out_the_hidden(
@@ -519,6 +568,20 @@ def test_the_roles_page_offers_the_judged_filter_and_hidden_companies(
assert "Show muted" not in page
def test_the_roles_page_carries_the_ladder_as_json(client: TestClient, store: Store) -> None:
upsert(store, posting("1"))
uid = posting("1").uid
for page in (client.get("/").text, client.get(f"/roles/{uid}").text):
marker = "window.ROLEDESK_LADDER = "
start = page.index(marker) + len(marker)
ladder = json.loads(page[start:page.index(";\n", start)])
assert ladder["rungs"] == list(RUNGS)
assert ladder["levels"] == {level: list(place) for level, place in LADDER.items()}
for name in ("f-level-from", "f-level-to", "f-track"):
assert f'id="{name}"' in page
assert 'id="f-seniority"' not in page
# --------------------------------------------------------------- companies
def test_companies_lists_board_and_open_role_count(