Skip to content

Commit c2a4e70

Browse files
shrimblyclaude
andcommitted
deflake title shimmer completion test
The test slept for the nominal animation duration plus a fixed grace period, which slow Windows CI runners exceed. Completion is now observed through the recorded frame callbacks with a polling deadline. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 158af78 commit c2a4e70

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

‎tests/ui/test_integration.py‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,29 @@ def test_title_shimmer_changes_only_color_across_the_full_title():
158158
async def test_title_shimmer_finishes_on_the_original_title(monkeypatch):
159159
monkeypatch.setattr(AsciiTitleShimmer, "INITIAL_DELAY_SECONDS", 0.001)
160160
monkeypatch.setattr(AsciiTitleShimmer, "FRAME_INTERVAL_SECONDS", 0.005)
161+
162+
# The final frame renders the same spans as the initial one, so completion
163+
# must be observed through the frame callbacks rather than the render
164+
# output. Timers fire late on slow CI runners; poll with a deadline
165+
# instead of sleeping for the nominal animation duration.
166+
shown_frames = []
167+
original_show_frame = AsciiTitleShimmer._show_frame
168+
169+
def recording_show_frame(self, frame_index):
170+
shown_frames.append(frame_index)
171+
original_show_frame(self, frame_index)
172+
173+
monkeypatch.setattr(AsciiTitleShimmer, "_show_frame", recording_show_frame)
161174
form = ConfigurationForm()
162175

163176
async with ScreenHarness(form).run_test() as pilot:
164177
title = form.query_one("#ascii-title", AsciiTitleShimmer)
165-
animation_duration = (
166-
title.INITIAL_DELAY_SECONDS
167-
+ (len(title.frames) - 2) * title.FRAME_INTERVAL_SECONDS
168-
)
169-
await pilot.pause(animation_duration + 0.05)
178+
last_frame_index = len(title.frames) - 1
179+
for _ in range(200):
180+
if shown_frames and shown_frames[-1] == last_frame_index:
181+
break
182+
await pilot.pause(0.05)
183+
assert shown_frames and shown_frames[-1] == last_frame_index
170184

171185
rendered = title.render()
172186
assert rendered.plain == title.frames[-1].plain

0 commit comments

Comments
 (0)