Skip to content

Commit 82da6c3

Browse files
fix(test): replace pilot.click with direct method calls for scrollable widgets
pilot.click() raises OutOfBounds when the target widget's center is outside the visible viewport, which happens non-deterministically for elements inside a VerticalScroll container (add-alias, add-social, member-form-save buttons). Replace those three clicks with direct Python calls on the screen object: - screen.add_alias_entry() instead of pilot.click('#member-form-add-alias') - screen.add_social_entry() instead of pilot.click('#member-form-add-social') - screen.action_save() instead of pilot.click('#member-form-save') This makes the test fully deterministic regardless of scroll position or terminal geometry. Only clicks on simple, always-visible screens (Language, Auth, Dashboard) are kept as pilot.click calls.
1 parent a887885 commit 82da6c3

1 file changed

Lines changed: 23 additions & 25 deletions

File tree

tests/e2e/test_app_e2e.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,40 +68,38 @@ async def test_full_app_flow(
6868
await pilot.pause()
6969
assert isinstance(app.screen, MemberFormScreen)
7070

71-
# 5.1 Validation test
72-
await pilot.click("#member-form-add-alias")
73-
await pilot.click("#member-form-add-social")
71+
# 5.1 Validation test — call methods directly to avoid OutOfBounds
72+
# errors on widgets inside the VerticalScroll that may be off-screen.
73+
screen = app.screen
74+
assert isinstance(screen, MemberFormScreen)
75+
screen.add_alias_entry()
76+
screen.add_social_entry()
77+
await pilot.pause()
7478

7579
# Fill with invalid URLs
76-
app.screen.homepage_input.value = "not_a_url"
77-
78-
# Since social entries are dynamically added, get the last one
79-
if app.screen.social_entries:
80-
app.screen.social_entries[-1].url_input.value = "not_a_social_url"
80+
screen.homepage_input.value = "not_a_url"
81+
if screen.social_entries:
82+
screen.social_entries[-1].url_input.value = "not_a_social_url"
8183

82-
await pilot.click("#member-form-save")
84+
screen.action_save()
8385
await pilot.pause()
8486

8587
# Validation should prevent navigating away
86-
assert isinstance(
87-
app.screen,
88-
__import__(
89-
"edit_python_pe.screens.member_form"
90-
).screens.member_form.MemberFormScreen,
91-
)
88+
assert isinstance(app.screen, MemberFormScreen)
9289

93-
# 5. Member Form Screen
94-
app.screen.name_input.value = "John Doe"
95-
app.screen.email_input.value = "john@example.com"
96-
app.screen.city_input.value = "Lima"
97-
app.screen.homepage_input.value = "https://example.com"
98-
if app.screen.social_entries:
99-
app.screen.social_entries[
100-
-1
101-
].url_input.value = "https://github.com/john"
90+
# 5. Fill valid data and save
91+
screen = app.screen
92+
assert isinstance(screen, MemberFormScreen)
93+
screen.name_input.value = "John Doe"
94+
screen.email_input.value = "john@example.com"
95+
screen.city_input.value = "Lima"
96+
screen.homepage_input.value = "https://example.com"
97+
if screen.social_entries:
98+
screen.social_entries[-1].url_input.value = "https://github.com/john"
10299

103100
await pilot.pause()
104-
await pilot.click("#member-form-save")
101+
screen.action_save()
102+
105103

106104
# 6. Save Loading Screen — give up to 5 s for the background work
107105
for _ in range(50):

0 commit comments

Comments
 (0)