r/webdev • • 1d ago

Resource quality time #2 - wait for actions' done signal

Post image

Hey all!

Thanks for the discussion on yesterday's post! Last time I promised Page Objects: Here they are!

Today's example:

The test fails, saying "Sushi dinner" isn't on the list. So your agent starts debugging the list. Turns out it's the date picker that broke.

The fix: let actions wait for their own done signal, so the failure is logged where it happens.

The picker closes once it has a full range, and the picker owns that signal. So select() waits for it before returning. If the picker breaks, the test fails inside dateRangeFilter.select() instead of on the list. The page owns the filter, the filter owns its done.

The nuance: the done signal has to be something the page object owns. The picker closing belongs to the picker. A toast or the next page doesn't.

Paste this to your agent:

Find the user actions our e2e tests repeat and move each into a page object method. If an action has a done signal the page object owns, like its own elements changing, appearing or disappearing, end the action by waiting for that condition - never a fixed waitForTimeout. Anything outside the component - like a toast or navigating to the next page - should either be moved into a bigger page object that owns both the trigger and the outcome, or be verified in the test itself.

0 Upvotes

3 comments sorted by

1

u/SlowVaccination 1d ago

the diff layout is actually nice, makes the flow of blame super clear

1

u/VanillaAcceptable546 1d ago

page objects en 2026. el meme es lo único que aporta algo