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
Bug 1906896: show empty message for no alerts #7523
Bug 1906896: show empty message for no alerts #7523
Conversation
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.
@debsmita1 When visiting the Alerts tab page starts to hang and becomes unresponsive. according to the warning in the console, useEffect hook is being called repeatedly.
@debsmita1 Unit tests are failing |
return <LoadingBox />; | ||
} | ||
if (thanosAlertsAndRules?.alerts?.length === 0) { | ||
return <EmptyBox label="Alerts" />; |
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.
localize the string.
@debsmita1: This pull request references Bugzilla bug 1906896, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
db7490d
to
0920284
Compare
fixed |
@debsmita1: This pull request references Bugzilla bug 1906896, which is valid. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/test frontend |
/retest |
it('should render monitoring alerts', () => { | ||
const wrapper = shallow(<MonitoringAlerts {...monitoringAlertsProps} />); | ||
expect(wrapper.find(FilterToolbar).exists()).toBe(true); | ||
expect(wrapper.find(Table).exists()).toBe(true); | ||
expect(wrapper.find(TableHeader).exists()).toBe(true); | ||
expect(wrapper.find(TableBody).exists()).toBe(true); | ||
}); | ||
spyPrometheusRulesPoll.mockReturnValueOnce([{}, null, false]); | ||
it('should show empty state message', () => { | ||
const wrapper = shallow(<MonitoringAlerts {...monitoringAlertsProps} />); | ||
expect(wrapper.find(EmptyBox).exists()).toBe(true); | ||
}); |
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.
@debsmita1 Really great to see more tests coming. In jest all testcases and code which is required to run a test case should be part of a it
or beforeEach
, afterEach
, etc. function. Only test setup calls which are similar for all tests could be done before all tests.
In your case you modify the spyPrometheusRulesPoll
mock between two test functions. This works only fine when you run your test from top to bottom 'once'. The first mock call saved one result, the second one the second (empty) version.
The it
calls just register "test" calls (your callback function) and it will be run later. When you add console.log statements you can see that the tests are runned in this order:
console.log('1')
it('test 1' => {
console.log('3')
})
console.log('2')
it('test 2' => {
console.log('4')
})
And this is an issue if you don't run all tests at the same time or in a different order. You can test this with this command:
yarn test packages/dev-console/src/components/monitoring/alerts/__tests__/MonitoringAlerts.spec.tsx -t empty
This runs both mock "Once" calls and then runs the second it callback. But the mock returns the first value here.
So the general idea should be that each test works completely independent. You can reach this by just moving the setup of spyPrometheusRulesPoll
also into the it function.
/retest |
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.
Empty message was shown and I really like the new tests here, but found a small nit in the tests, also if they are green.
After this small change I would like to add a lgtm here. :)
ef7344e
to
bfb963f
Compare
@debsmita1: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
return <LoadingBox />; | ||
} | ||
if (_.isEmpty(response?.data)) { | ||
return <EmptyBox label={t('devconsle~Alerts')} />; |
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.
return <EmptyBox label={t('devconsle~Alerts')} />; | |
return <EmptyBox label={t('devconsole~Alerts')} />; |
if (loading && !loadError) { | ||
return <LoadingBox />; | ||
} | ||
if (_.isEmpty(response?.data)) { |
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.
if (_.isEmpty(response?.data)) { | |
if (_.isEmpty(response?.data?.groups)) { |
bfb963f
to
683afe6
Compare
/retest Please review the full test history for this PR and help us cut down flakes. |
4 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/test kubevirt-plugin |
/retest Please review the full test history for this PR and help us cut down flakes. |
16 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
@debsmita1: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/retest Please review the full test history for this PR and help us cut down flakes. |
@debsmita1: All pull requests linked via external trackers have merged: Bugzilla bug 1906896 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/kind bug |
Fixes:
https://issues.redhat.com/browse/ODC-5116
Analysis / Root cause:
Solution Description:
No Alerts found
if there are no alertsUnit test coverage report:
Added new test
Screen shots / Gifs for design review:
Browser conformance: