-
Notifications
You must be signed in to change notification settings - Fork 8k
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
[ResponseOps][Rules] Fix rules list item enabled state updates causing test flakyness #183805
[ResponseOps][Rules] Fix rules list item enabled state updates causing test flakyness #183805
Conversation
1af9586
to
4fbed12
Compare
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#6038[✅] x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/config.ts: 50/50 tests passed. |
4fbed12
to
925ed14
Compare
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#6039[✅] x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/config.ts: 50/50 tests passed. |
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#6040[✅] x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/config.ts: 100/100 tests passed. |
Flaky Test Runner Stats🟠 Some tests failed. - kibana-flaky-test-suite-runner#6041[❌] x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/config.ts: 174/200 tests passed. |
925ed14
to
a9adc01
Compare
/ci |
Flaky Test Runner Stats🎉 All tests passed! - kibana-flaky-test-suite-runner#6046[✅] x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/config.ts: 50/50 tests passed. |
Pinging @elastic/response-ops (Team:ResponseOps) |
@@ -60,7 +60,6 @@ export const RuleStatusDropdown: React.FunctionComponent<ComponentOpts> = ({ | |||
hideSnoozeOption = false, | |||
direction = 'column', | |||
}: ComponentOpts) => { | |||
const [isEnabled, setIsEnabled] = useState<boolean>(rule.enabled); | |||
const [isSnoozed, setIsSnoozed] = useState<boolean>(!hideSnoozeOption && isRuleSnoozed(rule)); |
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.
nit:
Could isSnoozed
be also removed from useEffect and handled same way as isEnabled
?
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.
I agree with Janki! We can derive the state from the props when the component is rendered.
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.
Yep, I quickly went through the setIsSnoozed
usages and concluded it wasn't necessary since the data flow is unidirectional from rule
, but a useMemo
would be much better at handling this, commit coming in a few minutes 🙂
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.
Not even a useMemo
🙂. const isSnoozed = !hideSnoozeOption && isRuleSnoozed(rule)
is more than enough!
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.
Nice catch! LGTM 👍
594383d
to
15ee943
Compare
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
Summary
Removes optimistic updates from rules list item when enabling/disabling rules to avoid out-of-sync states (the likely cause of this flaky test).
Fixes #157623