fix(e2e): intercept API request to fix race condition in loading message test#4245
Conversation
…age test Agent-Logs-Url: https://github.com/Parsely/wp-parsely/sessions/67915978-cf03-4015-942f-0d373a8b09ff Co-authored-by: acicovic <23142906+acicovic@users.noreply.github.com>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThe PR introduces a test timing fix by intercepting the Related Posts API request and artificially delaying its completion. This keeps the loading UI visible long enough for the test assertion to verify the ChangesRelated Posts Loading State Test Timing
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/e2e/specs/content-helper/related-posts-panel-filters.spec.ts (1)
45-48: ⚡ Quick winConvert multi-line comment to block comment style.
Multi-line comments should use block comment syntax (
/* */or/** */) instead of multiple single-line comments, per WordPress JavaScript coding standards.📝 Proposed fix to use block comment style
- // Intercept the Related Posts API request to ensure the loading message - // stays visible long enough for the assertion. Without this, the fetch - // may complete before the check runs, causing a timeout on the transient - // loading state. + /* + * Intercept the Related Posts API request to ensure the loading message + * stays visible long enough for the assertion. Without this, the fetch + * may complete before the check runs, causing a timeout on the transient + * loading state. + */As per coding guidelines, WordPress coding standards require block comment style for multi-line comments.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/e2e/specs/content-helper/related-posts-panel-filters.spec.ts` around lines 45 - 48, Replace the consecutive single-line comments describing the Related Posts API interception with a single block comment (/* ... */) so the multi-line explanation uses block comment style per WP JS coding standards; locate the comment that begins "Intercept the Related Posts API request to ensure the loading message" (above the interception/assertion in related-posts-panel-filters.spec.ts) and wrap the full multi-line text inside a single /* ... */ block.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/e2e/specs/content-helper/related-posts-panel-filters.spec.ts`:
- Around line 45-48: Replace the consecutive single-line comments describing the
Related Posts API interception with a single block comment (/* ... */) so the
multi-line explanation uses block comment style per WP JS coding standards;
locate the comment that begins "Intercept the Related Posts API request to
ensure the loading message" (above the interception/assertion in
related-posts-panel-filters.spec.ts) and wrap the full multi-line text inside a
single /* ... */ block.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e4f82da6-34a7-4c68-bb3c-3cdd2df94148
📒 Files selected for processing (1)
tests/e2e/specs/content-helper/related-posts-panel-filters.spec.ts
…errors fix(e2e): intercept API request to fix race condition in loading message test" (17035a0)
Description
Intercept the
/wp-parsely/v2/stats/postsAPI route in therelated-posts-panel-filtersE2E spec and introduce a short 2-second delay before letting the request continue. This keeps the.related-posts-loading-messageelement visible long enough for Playwright to assert on it.Motivation and context
The
related-posts-panel-filtersE2E test was flaking (and consistently failing in CI) because the API response arrived before Playwright could observe the transient loading state. The test waited for.related-posts-loading-messageto be visible, but the fetch had already completed and the element was gone, causing aTimeoutErroron all 3 retries.Cross-referencing CI failure logs across all open PRs revealed 10 out of 16 failing E2E runs shared this exact error — always the same test, same selector, all retries exhausted. The route intercept is the standard Playwright approach for testing transient loading states without weakening assertions.
How has this been tested?
TimeoutErrorwaiting for.related-posts-loading-messageto be visible.Screenshots (if appropriate)
N/A
Summary by CodeRabbit