test: fix flaky combobox test#625
Conversation
📝 WalkthroughWalkthroughThe classification section test now cleans up after each test and uses an explicit 5000ms timeout when locating the selected keyword button. ChangesClassification selection test
Estimated code review effort: 1 (Trivial) | ~2 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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)
src/domain/event/formSections/classificationSection/__tests__/ClassificationSection.test.tsx (1)
266-277: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPrefer
findByRolewith timeout overwaitFor+getByRole.
findByRolealready polls internally and accepts{ timeout: 5000 }as a third argument. The currentwaitFor(() => expect(getByRole(...)).toBeInTheDocument())pattern is functionally equivalent but less idiomatic and produces less helpful failure messages. The simpler form also matches the existing usage offindByRolein thefindElementhelper at line 121.♻️ Proposed refactor
- await waitFor( - () => - expect( - screen.getByRole('button', { - name: new RegExp( - `1 valittu vaihtoehto.*${getValue(keyword?.name?.fi, '')}`, - 'i' - ), - }) - ).toBeInTheDocument(), - { timeout: 5000 } - ); + await screen.findByRole( + 'button', + { + name: new RegExp( + `1 valittu vaihtoehto.*${getValue(keyword?.name?.fi, '')}`, + 'i' + ), + }, + { timeout: 5000 } + );🤖 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 `@src/domain/event/formSections/classificationSection/__tests__/ClassificationSection.test.tsx` around lines 266 - 277, Replace the waitFor/getByRole assertion in the ClassificationSection test with screen.findByRole, passing the existing button name matcher and { timeout: 5000 } options, and assert the awaited result is in the document. Follow the existing findElement helper’s findByRole usage.
🤖 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
`@src/domain/event/formSections/classificationSection/__tests__/ClassificationSection.test.tsx`:
- Around line 266-277: Replace the waitFor/getByRole assertion in the
ClassificationSection test with screen.findByRole, passing the existing button
name matcher and { timeout: 5000 } options, and assert the awaited result is in
the document. Follow the existing findElement helper’s findByRole usage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 68600cf4-bf6e-42f5-b3c3-65607d47fb98
📒 Files selected for processing (1)
src/domain/event/formSections/classificationSection/__tests__/ClassificationSection.test.tsx
0903fe1 to
889a400
Compare
|
LINKEDCOMPONENTS-UI branch is deployed to platta: https://linkedcomponents-ui-pr625.dev.hel.ninja 🚀🚀🚀 |
e2e tests result is success for https://linkedcomponents-ui-pr625.dev.hel.ninja 😆🎉🎉🎉 |
Refs: LINK-2581
889a400 to
a906df9
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/domain/event/formSections/classificationSection/__tests__/ClassificationSection.test.tsx (1)
268-277: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winTimeout increase is appropriate, but note other
findByRolecalls lack explicit timeouts.The explicit
{ timeout: 5000 }on this assertion is a reasonable mitigation for CI flakiness where the selected keyword button may take longer to render. However, thefindElementhelper (lines 123, 127, 131) also usesfindByRole/findByRolewith the default 1000ms timeout for option and checkbox lookups. If the CI slowness is systemic, those calls could become future flakiness sources. Consider applying a consistent timeout to all async queries if flakiness recurs.As per library context,
@testing-library/react16.2.0 defaultsfindBy*queries to 1000ms.🤖 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 `@src/domain/event/formSections/classificationSection/__tests__/ClassificationSection.test.tsx` around lines 268 - 277, Use a consistent extended timeout for the async role lookups in the findElement helper, including its option and checkbox findByRole calls, matching the 5000ms timeout used by the selected keyword assertion. Keep the timeout centralized or reusable where practical so future CI slowness does not leave these queries at the default 1000ms.
🤖 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
`@src/domain/event/formSections/classificationSection/__tests__/ClassificationSection.test.tsx`:
- Around line 268-277: Use a consistent extended timeout for the async role
lookups in the findElement helper, including its option and checkbox findByRole
calls, matching the 5000ms timeout used by the selected keyword assertion. Keep
the timeout centralized or reusable where practical so future CI slowness does
not leave these queries at the default 1000ms.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e52adab3-ebea-4069-90ad-4de81d74215a
📒 Files selected for processing (1)
src/domain/event/formSections/classificationSection/__tests__/ClassificationSection.test.tsx
|
LINKEDCOMPONENTS-UI branch is deployed to platta: https://linkedcomponents-ui-pr625.dev.hel.ninja 🚀🚀🚀 |
e2e tests result is success for https://linkedcomponents-ui-pr625.dev.hel.ninja 😆🎉🎉🎉 |
|



Refs: LINK-2581
Description ✨
Hopefully now fixes the combobox test which failed often in CI.
Issues 🐛
Closes 🙅♀️
LINK-2581:
Summary by CodeRabbit