refactor: remove obsolete test file for lessons behind the curriculum
Browse files
mathly2/tests/test_behind_home_browser.py
DELETED
|
@@ -1,63 +0,0 @@
|
|
| 1 |
-
"""The card of lessons behind the curriculum on the home (add-behind-lessons-to-home 2.1), in a real browser."""
|
| 2 |
-
from datetime import datetime, timedelta, timezone
|
| 3 |
-
|
| 4 |
-
import pytest
|
| 5 |
-
|
| 6 |
-
playwright = pytest.importorskip("playwright.sync_api")
|
| 7 |
-
|
| 8 |
-
from mathly2 import clock
|
| 9 |
-
from mathly2.tests.serve import running
|
| 10 |
-
from mathly2.tests.test_home_browser import KID_ID, PHONE, bank, browser, no_sideways_scroll, sign_in, to_home, world # noqa: F401
|
| 11 |
-
|
| 12 |
-
STAMP = "2026-10-05T10:00:00+00:00"
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
def seed(app, store, bank, lessons):
|
| 16 |
-
today = clock.school_day()
|
| 17 |
-
store.set_lesson_dates({lessons[0]: today - timedelta(days=2), lessons[1]: today - timedelta(days=9)})
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
def test_practice_tests_below_87_are_inside_the_nearest_test_card_with_the_grade_in_the_button(browser, bank):
|
| 21 |
-
app, store, klass, lessons = world(bank)
|
| 22 |
-
test = store.create_test(klass["id"], clock.school_day() + timedelta(days=10), lessons[:1], "t@school.test", created_at=clock.now() - timedelta(days=20))
|
| 23 |
-
for skill in [x["id"] for x in bank.skills if x["unit"] == lessons[0]][:2]: # started skills, so a practice test can begin
|
| 24 |
-
store.save_progress(KID_ID, skill, started_at=STAMP)
|
| 25 |
-
for number, grade in ((1, 25), (2, 87)):
|
| 26 |
-
row = store.create_attempt(KID_ID, "exercise_test", f"{test['id']}:{number}", clock.now() - timedelta(hours=2), clock.now() - timedelta(hours=1), [])
|
| 27 |
-
store.save_attempt(row["id"], submitted_at=clock.now() - timedelta(hours=1), grade=grade)
|
| 28 |
-
with running(app) as url:
|
| 29 |
-
page = sign_in(browser, url)
|
| 30 |
-
to_home(page)
|
| 31 |
-
page.wait_for_selector("#nearest-test #weak-tests")
|
| 32 |
-
assert page.locator("#weak-tests").count() == 1 and page.locator("section#weak-tests").count() == 0 # inside the test's card, not a card of its own
|
| 33 |
-
top, weak = page.locator("#nearest-test").bounding_box(), page.locator("#weak-tests").bounding_box()
|
| 34 |
-
assert top["y"] <= weak["y"] and weak["y"] + weak["height"] <= top["y"] + top["height"]
|
| 35 |
-
assert page.locator("#nearest-test .today").bounding_box()["y"] < weak["y"] # under today's task
|
| 36 |
-
rows = page.locator("#weak-tests li")
|
| 37 |
-
assert rows.count() == 1 and rows.first.get_attribute("data-number") == "1" # 87 is good enough
|
| 38 |
-
link = rows.first.locator("[data-way=retake]")
|
| 39 |
-
assert link.get_attribute("href") == f"#/exam/{test['id']}/1" and link.locator(".grade-chip").inner_text() == "25"
|
| 40 |
-
assert "87" not in page.inner_text("#weak-tests") and "13" not in page.inner_text("#weak-tests")
|
| 41 |
-
no_sideways_scroll(page)
|
| 42 |
-
page.click("#weak-tests [data-way=retake]")
|
| 43 |
-
page.wait_for_selector("#qz-q")
|
| 44 |
-
assert not page.errors
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
def test_no_card_when_no_lesson_is_behind_or_when_it_was_passed(browser, bank):
|
| 48 |
-
app, store, klass, lessons = world(bank)
|
| 49 |
-
store.set_lesson_dates({lessons[0]: clock.school_day() + timedelta(days=5)})
|
| 50 |
-
with running(app) as url:
|
| 51 |
-
page = sign_in(browser, url)
|
| 52 |
-
to_home(page)
|
| 53 |
-
page.wait_for_selector("#continue-path")
|
| 54 |
-
assert page.locator("#behind-card").count() == 0
|
| 55 |
-
app, store, klass, lessons = world(bank)
|
| 56 |
-
store.set_lesson_dates({lessons[0]: clock.school_day() - timedelta(days=1)})
|
| 57 |
-
q = store.create_attempt(KID_ID, "quiz", lessons[0], clock.now() - timedelta(hours=2), clock.now() - timedelta(hours=1), [])
|
| 58 |
-
store.save_attempt(q["id"], submitted_at=clock.now() - timedelta(hours=1), grade=87) # 13 of 15: passed
|
| 59 |
-
with running(app) as url:
|
| 60 |
-
page = sign_in(browser, url)
|
| 61 |
-
to_home(page)
|
| 62 |
-
page.wait_for_selector("#continue-path")
|
| 63 |
-
assert page.locator("#behind-card").count() == 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|