diff --git a/static/app.js b/static/app.js index 0e9767c..7e2d87f 100644 --- a/static/app.js +++ b/static/app.js @@ -111,7 +111,7 @@ function showHome() { head.append(el("h2", null, "Recently played")); if (history.length >= 5) { const va = el("a", null, "view all \u2192"); - va.href = BASE + "history"; + va.href = BASE + "?history"; head.append(va); } main.append(head); diff --git a/tests/test_browser.py b/tests/test_browser.py index a507646..1b4be8b 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -115,10 +115,9 @@ async def _history_page_and_delete(): op.open(urllib.request.Request(BASE + "/login", data=json.dumps({"username": "erin", "password": "erinpw12345"}).encode(), headers={"Content-Type": "application/json"}, method="POST")) - for e in ({"title": "Hist A", "slug_id": "hist-a", "season_id": 1, "ep_id": 7, - "lang": "eng", "ep": 7, "pos": 5}, - {"title": "Hist B", "slug_id": "hist-b", "season_id": 2, "ep_id": 9, - "lang": "jpn", "ep": 9, "pos": 30, "dur": 600}): + for n in range(1, 6): # 5 entries: makes the home "view all" link render + e = {"title": f"Hist {n}", "slug_id": f"hist-{n}", "season_id": n, "ep_id": n, + "lang": "eng", "ep": n, "pos": 5, "dur": 600} op.open(urllib.request.Request(BASE + "/api/history", data=json.dumps(e).encode(), headers={"Content-Type": "application/json"}, method="POST")) @@ -130,13 +129,17 @@ async def _history_page_and_delete(): page.on("pageerror", lambda e: errors.append(str(e))) await _login(page, "erin", "erinpw12345") - await page.goto(BASE + "/?history") + # regression: "view all" must go to the ?history query, not the /history path + await page.goto(BASE + "/") + await page.wait_for_selector("a:has-text('view all')", timeout=15000) + assert (await page.get_attribute("a:has-text('view all')", "href")).endswith("/?history") + await page.click("a:has-text('view all')", force=True) await page.wait_for_selector(".card.hist", timeout=15000) await page.wait_for_function( - "document.querySelectorAll('.card.hist').length == 2", timeout=15000, polling=POLL) + "document.querySelectorAll('.card.hist').length == 5", timeout=15000, polling=POLL) await page.click(".card.hist .del", force=True) await page.wait_for_function( - "document.querySelectorAll('.card.hist').length == 1", timeout=15000, polling=POLL) + "document.querySelectorAll('.card.hist').length == 4", timeout=15000, polling=POLL) await page.wait_for_selector(".toast", timeout=5000) assert not errors, errors await browser.close()