Return zero recent failures for empty suites/reports
What does this MR do and why?
For #364226 (closed)
Makes countRecentlyFailedTests
return 0 when the subject
being passed to it is null or undefined so that if it is called before the test report widget has data, it doesn't throw an error.
Screenshots or screen recordings
before | after |
---|---|
Screen_Recording_2022-06-22_at_16.18.56 | Screen_Recording_2022-06-22_at_16.25.59 |
How to set up and validate locally
Reproduce the bug:
git checkout master
echo "Feature.enable(:refactor_mr_widget_test_summary)" | bundle exec rails console
- find/clone a project with test reports
- run a pipeline for the default branch in the project
- find/create a branch that modifies the results of the test report (
feature-branch
in the demo project) - open a merge request for that branch, ensure a pipeline runs for it, watch the widget as it loads while the pipeline completes
- the widget should show a loading state and then an error state
🐛 (refreshing the page afterwards shows the data that should have appeared) - (optional) to recreate the bug again after this, you can
gdk restart
or retry the pipeline's test job(s)
Validate the fix:
git checkout 364226-return-zero-recent-failures-when-suites-is-null
- refresh the page to make sure the new version is running
-
gdk restart
or retry the pipeline's test job(s), watch the widget as it tries to load new data - the widget should show a loading state and then show data
✨ (the same data that appeared after refreshing when the bug was there)
Run the new unit test on the old code to validate that it would catch a regression:
-
git checkout master
and apply this patch:
patch
diff --git a/app/assets/javascripts/vue_merge_request_widget/extensions/test_report/index.js b/app/assets/javascripts/vue_merge_request_widget/extensions/test_report/index.js
index 164bda33b95..0af84cf4dad 100644
--- a/app/assets/javascripts/vue_merge_request_widget/extensions/test_report/index.js
+++ b/app/assets/javascripts/vue_merge_request_widget/extensions/test_report/index.js
@@ -32,9 +32,6 @@ export default {
};
},
statusIcon(data) {
- if (data.parsingInProgress) {
- return null;
- }
if (data.status === TESTS_FAILED_STATUS) {
return EXTENSION_ICONS.warning;
}
diff --git a/spec/frontend/vue_mr_widget/extensions/test_report/index_spec.js b/spec/frontend/vue_mr_widget/extensions/test_report/index_spec.js
index da4b990c078..6466d5d8486 100644
--- a/spec/frontend/vue_mr_widget/extensions/test_report/index_spec.js
+++ b/spec/frontend/vue_mr_widget/extensions/test_report/index_spec.js
@@ -79,6 +79,15 @@ describe('Test report extension', () => {
expect(wrapper.text()).toContain(i18n.loading);
});
+ it('with a 204 response, continues to display loading state', async () => {
+ mockApi(httpStatusCodes.NO_CONTENT, '');
+ createComponent();
+
+ await waitForPromises();
+
+ expect(wrapper.text()).toContain(i18n.loading);
+ });
+
it('displays failed loading text', async () => {
mockApi(httpStatusCodes.INTERNAL_SERVER_ERROR);
createComponent();
yarn jest spec/frontend/vue_mr_widget/extensions/test_report/index_spec.js
- the
with a 204 response, continues to display loading state
test case should fail
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Miranda Fluharty