Michael Rabinovich Cursor commited on
Commit ·
1004adf
1
Parent(s): 4a9408a
test: fix leaderboard smoke test for gallery-default tab + sr-only label
Browse filesGallery is now the default tab, so the Leaderboard content is hidden on
load; click the Leaderboard tab before asserting. Scope the label
locator to the visible <p> since the Leaderboard widget also renders a
screen-reader-only <caption> with the same text (strict-mode 2-element
violation otherwise).
Co-authored-by: Cursor <cursoragent@cursor.com>
- tests/test_smoke.py +15 -5
tests/test_smoke.py
CHANGED
|
@@ -34,24 +34,34 @@ def test_three_tabs_render(app_url):
|
|
| 34 |
|
| 35 |
|
| 36 |
def test_two_leaderboard_widgets_render(app_url):
|
| 37 |
-
"""Both Validated and Unvalidated leaderboards
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
("Validated Leaderboard" is not a substring of "Unvalidated
|
| 42 |
-
Leaderboard" with the uppercase V)
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
"""
|
| 45 |
with sync_playwright() as p:
|
| 46 |
browser = p.chromium.launch(headless=True)
|
| 47 |
try:
|
| 48 |
page = browser.new_page()
|
| 49 |
page.goto(app_url)
|
|
|
|
| 50 |
expect(
|
| 51 |
page.get_by_text("Validated Leaderboard", exact=True)
|
|
|
|
| 52 |
).to_be_visible(timeout=15_000)
|
| 53 |
expect(
|
| 54 |
page.get_by_text("Unvalidated Leaderboard", exact=True)
|
|
|
|
| 55 |
).to_be_visible(timeout=15_000)
|
| 56 |
finally:
|
| 57 |
browser.close()
|
|
|
|
| 34 |
|
| 35 |
|
| 36 |
def test_two_leaderboard_widgets_render(app_url):
|
| 37 |
+
"""Both Validated and Unvalidated leaderboards render on the Leaderboard tab.
|
| 38 |
|
| 39 |
+
Gallery is the default (first) tab, so the Leaderboard tab's content
|
| 40 |
+
is mounted-but-hidden until selected; click the tab first, then
|
| 41 |
+
assert. The two widgets are identified by their labels (set in
|
| 42 |
+
app.py). The labels are case-sensitive substrings that don't overlap
|
| 43 |
("Validated Leaderboard" is not a substring of "Unvalidated
|
| 44 |
+
Leaderboard" with the uppercase V).
|
| 45 |
+
|
| 46 |
+
The ``Leaderboard`` widget renders each label twice: the visible
|
| 47 |
+
``<p>`` label and a screen-reader-only ``<caption class="sr-only">``
|
| 48 |
+
inside the table. Both match the text, so the locator is scoped to
|
| 49 |
+
the ``<p>`` label to avoid a strict-mode "resolved to 2 elements"
|
| 50 |
+
violation.
|
| 51 |
"""
|
| 52 |
with sync_playwright() as p:
|
| 53 |
browser = p.chromium.launch(headless=True)
|
| 54 |
try:
|
| 55 |
page = browser.new_page()
|
| 56 |
page.goto(app_url)
|
| 57 |
+
page.get_by_role("tab", name="Leaderboard").click()
|
| 58 |
expect(
|
| 59 |
page.get_by_text("Validated Leaderboard", exact=True)
|
| 60 |
+
.and_(page.locator("p"))
|
| 61 |
).to_be_visible(timeout=15_000)
|
| 62 |
expect(
|
| 63 |
page.get_by_text("Unvalidated Leaderboard", exact=True)
|
| 64 |
+
.and_(page.locator("p"))
|
| 65 |
).to_be_visible(timeout=15_000)
|
| 66 |
finally:
|
| 67 |
browser.close()
|