"""Multi-axis verifier for task-manager /projects/:id Kanban board. Spans: (a) UI structure — h1 "Apollo", 4 stat tiles, 3 column titles with counts, 4 task titles in correct columns, ≥4 status-selects + ≥4 Delete buttons, ≥4 filter selects, member chip "Alice". (b) Data shape — column counts read 2/1/1; stats read 4/25%/1; priority badges with text "high"/"medium"/"low" present. (c) Behavior — status-select change PUTs /api/tasks/; column counts flip to 1/1/2 after the move; clicking Delete on a task DELETEs /api/tasks/ (auto-accept confirm dialog). Drives via in-app pushState into /projects/. Tests are ordered: data-shape + UI first, behavior tests (which mutate state) last. """ import re from pathlib import Path import pytest import requests from playwright.sync_api import sync_playwright BASE = "http://127.0.0.1:5101" APP = "http://127.0.0.1:5273" ARTIFACTS = Path("/logs/artifacts") @pytest.fixture(scope="module") def page(): ARTIFACTS.mkdir(parents=True, exist_ok=True) page_errors: list[str] = [] projects = requests.get(f"{BASE}/api/projects", timeout=10).json() target = next((p for p in projects if p["name"] == "Apollo"), None) assert target, f"seeded project 'Apollo' not in {[p['name'] for p in projects]}" pid = target["id"] (ARTIFACTS / "pid.txt").write_text(str(pid)) with sync_playwright() as p: browser = p.chromium.launch(headless=True) ctx = browser.new_context(viewport={"width": 1280, "height": 900}) page = ctx.new_page() page.on("pageerror", lambda e: page_errors.append(str(e))) page.on("dialog", lambda d: d.accept()) page.goto(APP, wait_until="networkidle", timeout=30_000) page.evaluate( f"() => {{ history.pushState({{}}, '', '/projects/{pid}'); window.dispatchEvent(new PopStateEvent('popstate')); }}" ) try: page.wait_for_selector("h1", timeout=10_000) except Exception: pass page.wait_for_timeout(1500) page.screenshot(path=str(ARTIFACTS / "agent-app.png"), full_page=True) (ARTIFACTS / "pageerrors.log").write_text("\n".join(page_errors)) yield page browser.close() def _pid(): return int((ARTIFACTS / "pid.txt").read_text().strip()) # ---------- (a) UI structure ---------- def test_no_page_errors(): errs = (ARTIFACTS / "pageerrors.log").read_text() if (ARTIFACTS / "pageerrors.log").exists() else "" assert not errs.strip(), f"Page errors:\n{errs}" def test_h1_project_name(page): h = page.locator("h1").first assert h.is_visible(), "no

on page" assert "Apollo" in h.inner_text(), f"h1 text={h.inner_text()!r}" def test_three_kanban_columns(page): """Column titles 'To Do', 'In Progress', 'Done' all visible.""" body = page.locator("body").inner_text() for col in ("To Do", "In Progress", "Done"): assert col in body, f"column title {col!r} missing. Body excerpt: {body[:600]!r}" def test_member_chip(page): body = page.locator("body").inner_text() assert "Alice" in body, "member 'Alice' missing" def test_filter_bar(page): """Should have ≥4 filter selects (status / priority / member / tag).""" selects = page.locator('select').count() assert selects >= 4, f"expected ≥4 selects (4 filters minimum); got {selects}" def test_task_titles_in_correct_columns(page): """All 4 task titles render and bucketed correctly.""" body = page.locator("body").inner_text() for title in ("Wire credentials", "Draft retro doc", "Refactor adapter", "Ship migration"): assert title in body, f"task {title!r} missing. Body excerpt: {body[:800]!r}" def test_per_task_actions(page): """Each of the 4 tasks should have its own status-select and Delete button.""" # Task status selects use the .status-select class in golden, but agent # may use a different class. Conservatively count elements; the first 4 are usually filters. Pick a status # select beyond the first 4. We change its value to "done" via select_option. selects = page.locator('select').all() assert len(selects) >= 5, f"need ≥5 selects to find a task status-select" # Try selects[4] onward for a select that has a "done" option AND is not # the priority/status/member/tag filter. target_select = None for s in selects[4:]: try: opts = [o.get_attribute("value") for o in s.locator("option").all()] if "done" in opts and "" not in opts: target_select = s break except Exception: continue assert target_select is not None, "no task status-select found among selects beyond filters" target_select.select_option(value="done", timeout=5_000) page.wait_for_timeout(2000) assert captured, f"no PUT /api/tasks/ observed after status change" def test_delete_task_sends_delete(page): """Click a Delete button — confirm dialog auto-accepts — observe a DELETE to /api/tasks/.""" captured = [] def on_request(req): if req.method == "DELETE" and re.search(r"/api/tasks/\d+", req.url): captured.append(req.url) page.on("request", on_request) deletes = [b for b in page.get_by_role("button").all() if (b.inner_text() or "").strip().lower() == "delete"] assert deletes, "no Delete buttons found on tasks" deletes[0].click(timeout=5_000, force=True) page.wait_for_timeout(2000) assert captured, "no DELETE /api/tasks/ observed after Delete click"