You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(e2e): make product navigation resilient to sold-out inventory
navigateToFirstProduct was brittle — it clicked the first product link
on the page regardless of stock status. When a test store's first
product happened to be sold out, addToCart() would fail with a
misleading timeout looking for a nonexistent "Add to cart" button.
Introduce navigateToInStockProduct which tries product links
sequentially, checking for an "Add to cart" button before settling.
Sold-out products are skipped. Tests only fail when every product on
the page is unavailable.
Addresses reviewer feedback from Gray, Kara, and John:
- Renamed method to match its actual behavior (navigateToInStockProduct)
- Extracted shared "Add to cart" button locator (getAddToCartButton)
to eliminate duplication with addToCart()
- Switched from has-text CSS selector to getByRole for consistency
with project E2E guidelines
- Replaced goBack() with goto(originalUrl) for reliable navigation
- Replaced networkidle waits with visible-element assertions
- Added max-attempts cap (10) to bound failure time
- Named the timeout constant with explanatory context
A deprecated navigateToFirstProduct alias is kept to avoid breaking
any external callers, but all internal call sites are updated.
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments