Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/render_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,18 @@ def key_line(page):
return page.locator(".lf-keyline").inner_text()


def key_line_route(page, command):
"""The keycaps one key-line binding draws, in the order they are pressed.

A chord's rows keep their complete route while the reader advances through it, so
the text alone no longer says how far a chord has come; `data-lf-key-state` does.
Read the keys through this locator and assert on both.
"""
return page.locator(
f'.lf-keyline .lf-key[data-lf-commands~="{command}"] > .lf-key-sequence > kbd'
)


def open_page(
browser,
url,
Expand Down
2 changes: 2 additions & 0 deletions tests/render_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@
held_stale,
hold_selection,
key_line,
key_line_route,
leaf_page,
margins_laid_out,
navigate,
Expand Down Expand Up @@ -603,6 +604,7 @@
"hold_selection",
"in_threads_scrollport",
"key_line",
"key_line_route",
"leaf_page",
"live_leaf",
"live_url",
Expand Down
26 changes: 14 additions & 12 deletions tests/test_render_margin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
SUGGESTION_PAGE,
_publish,
compare_with,
key_line_route,
leaf_page,
live_url,
margins_laid_out,
Expand Down Expand Up @@ -165,13 +166,14 @@ def activation_state():
expect(marker).not_to_be_focused()

page.keyboard.press("g")
expect(page.locator(".lf-keyline")).to_contain_text(
re.compile(r"m\s*page-map items")
)
# The row keeps the whole route from the first press to the last, so how far the
# chord has come is the list key's face rather than which keys the line is drawing.
map_route = key_line_route(page, "navigation.page-map-item")
expect(map_route).to_have_text(["g", "m", "1–9"])
expect(map_route.nth(1)).to_have_attribute("data-lf-key-state", "neutral")
page.keyboard.press("m")
expect(page.locator(".lf-keyline")).to_contain_text(
re.compile(r"1–9\s*page-map items")
)
expect(map_route).to_have_text(["g", "m", "1–9"])
expect(map_route.nth(1)).to_have_attribute("data-lf-key-state", "pressed")
page.keyboard.press(str(address["number"]))

preview = page.locator(".lf-margin-preview")
Expand Down Expand Up @@ -275,13 +277,13 @@ def test_one_margin_item_owns_a_targets_controls_information_and_more_actions(
}"""
)
page.keyboard.press("g")
expect(page.locator(".lf-keyline")).to_contain_text(
re.compile(r"m\s*page-map items")
)
map_route = key_line_route(page, "navigation.page-map-item")
map_steps = ["g", "m", f"1–{min(draft_address['count'], 9)}"]
expect(map_route).to_have_text(map_steps)
expect(map_route.nth(1)).to_have_attribute("data-lf-key-state", "neutral")
page.keyboard.press("m")
expect(page.locator(".lf-keyline")).to_contain_text(
re.compile(rf"1–{min(draft_address['count'], 9)}\s*page-map items")
)
expect(map_route).to_have_text(map_steps)
expect(map_route.nth(1)).to_have_attribute("data-lf-key-state", "pressed")
assert draft_address["number"] <= 9
page.keyboard.press(str(draft_address["number"]))
expect(draft_item.locator(".lf-draft-pencil")).to_be_focused()
Expand Down
Loading