Repository navigation
Move every browser test to the shared wait helpers #435
Copy link
Copy link
Open
Description
Context
Browser tests wait for the SPA by polling from the page with $page->script(...), because Pest assertions check only once and sleep() starves the server that serves the page. Until now the AGENTS.md rule told each file to copy that polling loop under a file-unique name. The result:
- 200 local
waitFor*functions in 96 files undertests/Browser, nearly all the same loop under another name (waitForWelcomeTestId,waitForSidebarTestId,waitForWebhookShowTestId, …); - 196 waits that write
document.querySelector('[data-testid=…]')inline.
#434 added shared helpers to tests/Pest.php, migrated ComposerUnsavedChangesTest.php and ComposerChannelSettingsTest.php, and changed the AGENTS.md rule: every wait goes through those helpers, and no new per-file waitFor* helper may be added.
Every helper takes a CSS selector where @name stands for [data-testid="name"] anywhere in it, as in $page->click('@name').
| Helper | Waits until |
|---|---|
waitFor($page, '@id') |
an element is mounted and laid out |
waitForGone($page, '@id') |
no element matches |
waitForState($page, '@id', "element…") |
an element exists and the expression about element is true |
waitForText($page, '[role="option"]', 'general') |
any matching element contains the text |
waitForGoneOrShown($page, gone: '@a', shown: '@b') |
either outcome, so the next assertion fails at once |
waitForPath($page, $path) |
the page is at that path |
waitForCondition($page, $js) |
only what is not about an element (location.search, a window.__ spy) |
To do
- Replace every local
waitFor*function with the shared helpers and delete the local copies. Helpers that only wrap one condition with a domain name (for examplewaitForChannelSettingsClosedMenu) may stay, built onwaitForCondition. - Rewrite every inline
document.querySelector(...)wait with the selector helpers above. SplitA && Bconditions into one wait each only when both end states persist. - Add a shared helper for a pattern that repeats and the helpers cannot express yet. Do not inline it.
- Drop "predate this rule" from the AGENTS.md Browser Tests section once no file has its own helper.
- Run the full browser suite in the three CI shards (
./vendor/bin/pest tests/Browser --compact --parallel --processes=3 --shard=N/3).
Pure test refactor: no app code changes. Split it into several PRs by area if that keeps review easy.
Files with their own waitFor* helpers
-
tests/Browser/ApiKeyCreateDialogTest.php -
tests/Browser/AuthLanguageSwitcherTest.php -
tests/Browser/AuthStandardFormTest.php -
tests/Browser/AuthTitlesTest.php -
tests/Browser/BillingPageTest.php -
tests/Browser/BillingProcessingTest.php -
tests/Browser/CalendarPageTest.php -
tests/Browser/ChangelogTest.php -
tests/Browser/ChannelGridTest.php -
tests/Browser/ChannelInsightsFiltersTest.php -
tests/Browser/ChannelInsightsTest.php -
tests/Browser/ChannelMediaIssueTest.php -
tests/Browser/ChannelMetricsCardTest.php -
tests/Browser/ChannelPostingGoalTest.php -
tests/Browser/ChannelReorderTest.php -
tests/Browser/ChannelSettingsPageTest.php -
tests/Browser/ChannelsSettingsTest.php -
tests/Browser/CommandPaletteTest.php -
tests/Browser/ComposerApprovalTest.php -
tests/Browser/ComposerAutosaveTest.php -
tests/Browser/ComposerCanvaMenuTest.php -
tests/Browser/ComposerChannelSettingsTest.php -
tests/Browser/ComposerEditInCanvaTest.php -
tests/Browser/ComposerGooglePhotosTest.php -
tests/Browser/ComposerMediaSourcesTest.php -
tests/Browser/ComposerMediaTrayTest.php -
tests/Browser/ComposerMobileTest.php -
tests/Browser/ComposerNetworkCardsTest.php -
tests/Browser/ComposerPreviewTest.php -
tests/Browser/ComposerQueueTest.php -
tests/Browser/ComposerSharedDataTest.php -
tests/Browser/ComposerSingleChannelTest.php -
tests/Browser/ComposerTemplatesTest.php -
tests/Browser/ComposerTimezoneTest.php -
tests/Browser/ConnectChannelDialogTest.php -
tests/Browser/ConnectConfirmationTest.php -
tests/Browser/ConnectSwitchAccountTest.php -
tests/Browser/CreateFeedsTest.php -
tests/Browser/CreateIdeaEditorTest.php -
tests/Browser/CreateIdeasBoardTest.php -
tests/Browser/CreateShellTest.php -
tests/Browser/CreateTemplatesTest.php -
tests/Browser/DarkModeSurfacesTest.php -
tests/Browser/DialogFooterTest.php -
tests/Browser/DialogFullScreenMobileTest.php -
tests/Browser/ImageCropperTest.php -
tests/Browser/ImportedPostCardTest.php -
tests/Browser/InsightsChannelFilterTest.php -
tests/Browser/InsightsParityTest.php -
tests/Browser/LabelFilterPopoverTest.php -
tests/Browser/LabelRowMenuTest.php -
tests/Browser/LinkCardPreviewTest.php -
tests/Browser/McpSettingsTest.php -
tests/Browser/MediaEditorTest.php -
tests/Browser/MediaLightboxTest.php -
tests/Browser/MemberAccessDialogTest.php -
tests/Browser/NotificationPreferencesTest.php -
tests/Browser/PostApprovalsTest.php -
tests/Browser/PostCardFooterTest.php -
tests/Browser/PostCardLabelsTest.php -
tests/Browser/PostComposerDialogTest.php -
tests/Browser/PostDetailsDialogTest.php -
tests/Browser/PostDetailsGroupTest.php -
tests/Browser/PostNotesTest.php -
tests/Browser/PostRecurrenceTest.php -
tests/Browser/PreferencesPageTest.php -
tests/Browser/ProfilePasswordRequirementsTest.php -
tests/Browser/ProfileTabsTest.php -
tests/Browser/PublishCardActionsTest.php -
tests/Browser/PublishListSkeletonTest.php -
tests/Browser/PublishPageTest.php -
tests/Browser/PublishQueueTest.php -
tests/Browser/ReferralSourceSurveyTest.php -
tests/Browser/RepurposeAccountHealthTest.php -
tests/Browser/RepurposeTest.php -
tests/Browser/SettingsListRowTest.php -
tests/Browser/SettingsSidebarTest.php -
tests/Browser/SidebarChannelReorderTest.php -
tests/Browser/SidebarChannelsTest.php -
tests/Browser/SidebarLanguageSwitchTest.php -
tests/Browser/SidebarMenuTest.php -
tests/Browser/SignaturesPageTest.php -
tests/Browser/SignupPreferencesTest.php -
tests/Browser/WebhookCreateDialogTest.php -
tests/Browser/WebhookDeleteTest.php -
tests/Browser/WebhookShowTest.php -
tests/Browser/WelcomeHeaderTest.php -
tests/Browser/WelcomeMcpTest.php -
tests/Browser/WelcomeMobileTest.php -
tests/Browser/WelcomePlanTest.php -
tests/Browser/WorkspaceCreateTest.php -
tests/Browser/WorkspaceInsightsTest.php -
tests/Browser/WritingAssistantTest.php -
tests/Browser/XLinkDefusingTest.php -
tests/Browser/XLongPostComposerTest.php -
tests/Browser/YouTubeDescriptionTest.php
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
Share the browser test wait helpers
Show a reel's track even when it was saved with only its id (#434)