-
Notifications
You must be signed in to change notification settings - Fork 8.3k
test: Fix flaky If-Else component reset regression test #10380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…LABS_API_KEY using import.meta.env to improve compatibility with ES modules
…ccurately reflect the test scenario 💡 (general-bugs-reset-flow-run.spec.ts): add explicit wait times to ensure proper test execution and avoid flakiness
WalkthroughA regression test for If-Else flow execution is refactored. The test focus shifts from image sending in the playground to validating multiple runs with different branches. Deliberate 500ms waits are added throughout to improve test stability. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (5 passed)
✨ Finishing touches
🧪 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (39.42%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #10380 +/- ##
==========================================
- Coverage 29.99% 29.99% -0.01%
==========================================
Files 1316 1316
Lines 59657 59661 +4
Branches 8921 8922 +1
==========================================
+ Hits 17896 17897 +1
- Misses 40944 40947 +3
Partials 817 817
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/frontend/tests/extended/regression/general-bugs-reset-flow-run.spec.ts (2)
145-153: Consider replacing hardcoded timeouts with condition-based waits.While these
waitForTimeoutcalls may reduce flakiness, they represent an anti-pattern in E2E testing. The inconsistent timeout pattern (this section has 3 waits while others have 1-2) suggests the root cause of the flakiness may not be fully understood.For more robust and maintainable tests, consider:
Recommended approach:
Replace hardcoded delays with condition-based waits that verify the UI is in the expected state:
- await page.waitForTimeout(500); - await page.getByTestId("popover-anchor-input-input_text").fill("1"); - await page.waitForTimeout(500); - + // Wait for input to be ready and value to be set + await expect(page.getByTestId("popover-anchor-input-input_text")).toHaveValue("1"); + await page.getByTestId("button_run_text output").click(); - - await page.waitForTimeout(500);If timing is critical due to debouncing or animations, use
page.waitForLoadState('networkidle')or wait for specific state changes rather than arbitrary timeouts.Note: This suggestion applies to all
waitForTimeoutcalls throughout the test (lines 78, 100, 121, 126, 145, 148, 152, 171).
106-189: Consider extracting repeated assertion logic into a helper function.The assertion pattern is duplicated four times throughout the test, differing only in the component names. This reduces maintainability and readability.
Consider refactoring to a helper function:
async function assertBranchExecution( page: Page, activeComponent: string, inactiveComponent: string ) { const successfulCount = await page .getByTestId(`node_duration_${activeComponent}`) .count(); const inactiveCount = await page .getByTestId(`node_status_icon_${inactiveComponent}_inactive`) .count(); expect(successfulCount).toBe(1); expect(inactiveCount).toBe(1); }Then replace the duplicated blocks with:
// First run - true branch await assertBranchExecution(page, "text output", "textoutputfalse"); // Second run - false branch await assertBranchExecution(page, "textoutputfalse", "text output"); // Third run - true branch retest await assertBranchExecution(page, "text output", "textoutputfalse"); // Fourth run - false branch retest await assertBranchExecution(page, "textoutputfalse", "text output");This would make the test more maintainable and highlight the test's core logic.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/frontend/tests/extended/regression/general-bugs-reset-flow-run.spec.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/frontend/**/*.@(test|spec).{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)
src/frontend/**/*.@(test|spec).{ts,tsx,js,jsx}: Frontend test files should be located in 'src/frontend/' and use '.test.{ts,tsx,js,jsx}' or '.spec.{ts,tsx,js,jsx}' extensions.
Test both sync and async code paths in frontend test files.
Mock external dependencies appropriately in frontend test files to isolate unit tests from external services.
Test error handling and edge cases in frontend test files.
Validate input/output behavior and test component initialization and configuration in frontend test files.
Each frontend test should have a clear description or comment explaining its purpose, especially for complex setups or mocks.
Files:
src/frontend/tests/extended/regression/general-bugs-reset-flow-run.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (43)
- GitHub Check: Run Frontend Unit Tests / Frontend Jest Unit Tests
- GitHub Check: Run Frontend Tests / Determine Test Suites and Shard Distribution
- GitHub Check: Test Starter Templates
- GitHub Check: Playwright Tests - Shard 40/40
- GitHub Check: Playwright Tests - Shard 39/40
- GitHub Check: Playwright Tests - Shard 38/40
- GitHub Check: Playwright Tests - Shard 33/40
- GitHub Check: Playwright Tests - Shard 37/40
- GitHub Check: Playwright Tests - Shard 35/40
- GitHub Check: Playwright Tests - Shard 36/40
- GitHub Check: Playwright Tests - Shard 29/40
- GitHub Check: Playwright Tests - Shard 32/40
- GitHub Check: Playwright Tests - Shard 31/40
- GitHub Check: Playwright Tests - Shard 34/40
- GitHub Check: Playwright Tests - Shard 30/40
- GitHub Check: Playwright Tests - Shard 28/40
- GitHub Check: Playwright Tests - Shard 26/40
- GitHub Check: Playwright Tests - Shard 23/40
- GitHub Check: Playwright Tests - Shard 24/40
- GitHub Check: Playwright Tests - Shard 21/40
- GitHub Check: Playwright Tests - Shard 25/40
- GitHub Check: Playwright Tests - Shard 27/40
- GitHub Check: Playwright Tests - Shard 11/40
- GitHub Check: Playwright Tests - Shard 22/40
- GitHub Check: Playwright Tests - Shard 19/40
- GitHub Check: Playwright Tests - Shard 17/40
- GitHub Check: Playwright Tests - Shard 16/40
- GitHub Check: Playwright Tests - Shard 12/40
- GitHub Check: Playwright Tests - Shard 7/40
- GitHub Check: Playwright Tests - Shard 18/40
- GitHub Check: Playwright Tests - Shard 15/40
- GitHub Check: Playwright Tests - Shard 20/40
- GitHub Check: Playwright Tests - Shard 9/40
- GitHub Check: Playwright Tests - Shard 6/40
- GitHub Check: Playwright Tests - Shard 5/40
- GitHub Check: Playwright Tests - Shard 10/40
- GitHub Check: Playwright Tests - Shard 13/40
- GitHub Check: Playwright Tests - Shard 8/40
- GitHub Check: Playwright Tests - Shard 3/40
- GitHub Check: Playwright Tests - Shard 14/40
- GitHub Check: Playwright Tests - Shard 2/40
- GitHub Check: Playwright Tests - Shard 1/40
- GitHub Check: Playwright Tests - Shard 4/40
🔇 Additional comments (1)
src/frontend/tests/extended/regression/general-bugs-reset-flow-run.spec.ts (1)
11-11: Improved test description clarity.The updated test name accurately describes the test's purpose: validating that the If-Else component can be executed multiple times across different branches. This is clearer than the previous description.
This pull request updates the regression test for the flow run reset functionality, focusing on the If-Else component. The changes improve test reliability and better reflect the intended user flow when running the component multiple times with different branches.
Test scenario update:
Test stability improvements:
waitForTimeoutcalls to ensure UI elements and state are ready before performing actions, reducing flakiness in the test.Summary by CodeRabbit