|
1 | 1 | """Using Axe-core, scan the Kitchen Sink pages for accessibility violations."""
|
2 | 2 |
|
3 |
| -import time |
4 |
| -from http.client import HTTPConnection |
5 |
| -from pathlib import Path |
6 |
| -from subprocess import PIPE, Popen |
7 | 3 | from urllib.parse import urljoin
|
8 | 4 |
|
9 | 5 | import pytest
|
|
25 | 21 | # people. It just means that page is free of common testable accessibility
|
26 | 22 | # pitfalls.
|
27 | 23 |
|
28 |
| -path_repo = Path(__file__).parent.parent |
29 |
| -path_docs_build = path_repo / "docs" / "_build" / "html" |
30 |
| - |
31 |
| - |
32 |
| -@pytest.fixture(scope="module") |
33 |
| -def url_base(): |
34 |
| - """Start local server on built docs and return the localhost URL as the base URL.""" |
35 |
| - # Use a port that is not commonly used during development or else you will |
36 |
| - # force the developer to stop running their dev server in order to run the |
37 |
| - # tests. |
38 |
| - port = "8213" |
39 |
| - host = "localhost" |
40 |
| - url = f"http://{host}:{port}" |
41 |
| - |
42 |
| - # Try starting the server |
43 |
| - process = Popen( |
44 |
| - ["python", "-m", "http.server", port, "--directory", path_docs_build], |
45 |
| - stdout=PIPE, |
46 |
| - ) |
47 |
| - |
48 |
| - # Try connecting to the server |
49 |
| - retries = 5 |
50 |
| - while retries > 0: |
51 |
| - conn = HTTPConnection(host, port) |
52 |
| - try: |
53 |
| - conn.request("HEAD", "/") |
54 |
| - response = conn.getresponse() |
55 |
| - if response is not None: |
56 |
| - yield url |
57 |
| - break |
58 |
| - except ConnectionRefusedError: |
59 |
| - time.sleep(1) |
60 |
| - retries -= 1 |
61 |
| - |
62 |
| - # If the code above never yields a URL, then we were never able to connect |
63 |
| - # to the server and retries == 0. |
64 |
| - if not retries: |
65 |
| - raise RuntimeError("Failed to start http server in 5 seconds") |
66 |
| - else: |
67 |
| - # Otherwise the server started and this fixture is done now and we clean |
68 |
| - # up by stopping the server. |
69 |
| - process.terminate() |
70 |
| - process.wait() |
71 |
| - |
72 | 24 |
|
73 | 25 | def filter_ignored_violations(violations, url_pathname):
|
74 | 26 | """Filter out ignored axe-core violations.
|
@@ -227,24 +179,6 @@ def test_axe_core(
|
227 | 179 | assert len(filtered_violations) == 0, format_violations(filtered_violations)
|
228 | 180 |
|
229 | 181 |
|
230 |
| -def test_version_switcher_highlighting(page: Page, url_base: str) -> None: |
231 |
| - """This isn't an a11y test, but needs a served site for Javascript to inject the version menu.""" |
232 |
| - page.goto(url=url_base) |
233 |
| - # no need to include_hidden here ↓↓↓, we just need to get the active version name |
234 |
| - button = page.get_by_role("button").filter(has_text="dev") |
235 |
| - active_version_name = button.get_attribute("data-active-version-name") |
236 |
| - # here we do include_hidden, so sidebar & topbar menus should each have a matching entry: |
237 |
| - entries = page.get_by_role("option", include_hidden=True).filter( |
238 |
| - has_text=active_version_name |
239 |
| - ) |
240 |
| - assert entries.count() == 2 |
241 |
| - # make sure they're highlighted |
242 |
| - for entry in entries.all(): |
243 |
| - light_mode = "rgb(10, 125, 145)" # pst-color-primary |
244 |
| - # dark_mode = "rgb(63, 177, 197)" |
245 |
| - expect(entry).to_have_css("color", light_mode) |
246 |
| - |
247 |
| - |
248 | 182 | @pytest.mark.a11y
|
249 | 183 | def test_code_block_tab_stop(page: Page, url_base: str) -> None:
|
250 | 184 | """Code blocks that have scrollable content should be tab stops."""
|
@@ -306,3 +240,14 @@ def test_notebook_ipywidget_output_tab_stop(page: Page, url_base: str) -> None:
|
306 | 240 | # ...and so our js code on the page should make it keyboard-focusable
|
307 | 241 | # (tabIndex = 0)
|
308 | 242 | assert ipywidget.evaluate("el => el.tabIndex") == 0
|
| 243 | + |
| 244 | + |
| 245 | +def test_breadcrumb_expansion(page: Page, url_base: str) -> None: |
| 246 | + """Foo.""" |
| 247 | + # page.goto(urljoin(url_base, "community/practices/merge.html")) |
| 248 | + # expect(page.get_by_label("Breadcrumb").get_by_role("list")).to_contain_text("Merge and review policy") |
| 249 | + page.set_viewport_size({"width": 1440, "height": 720}) |
| 250 | + page.goto(urljoin(url_base, "community/topics/config.html")) |
| 251 | + expect(page.get_by_label("Breadcrumb").get_by_role("list")).to_contain_text( |
| 252 | + "Update Sphinx configuration during the build" |
| 253 | + ) |
0 commit comments