Code Quality MR widget: Status of report comparison is not taken into account
### Summary The backend code quality comparison returns JSON data that includes a `status` property, but we are not taking it into account in **three cases**: :one: ~~The code quality MR widget reports "No changes to code quality" when the arrays of changed issues are empty, but the message is not accurate when the `status` is `failed`. The widget should instead use the "Failed to load code quality report" status/message in this case.~~ (on further investigation, `failed` refers to the status of the scan and not to the status of the report comparison, so we don't need to change the behavior in this case) :two: The code quality MR widget correctly reports "Base pipeline code quality artifact not found" when that is the case, but it is determined from the data source that we used before moving the comparison to the backend. We should instead show this message when the `status` is `not_found` so that we can remove the redundant code from the frontend. This could be combined with [moving the message into the body of the widget to make it more discoverable](https://gitlab.com/gitlab-org/gitlab/-/issues/293716) ![image](/uploads/ab7819ccc9507c18c02ff5dec38d06e5/image.png) :three: The code quality MR widget incorrectly reports "No changes to code quality" when the backend is still parsing and comparing the base and head reports (indicated by the HTTP status `204 No Content`). In this case we should display a loading icon and continue to poll until we get a response with a different HTTP status so we can display the results in the widget once they have been generated. ### Steps to reproduce For :one: 1. Run code quality on the base commit of an MR 1. Somehow cause an error when running code quality on the head commit of the MR 1. The JSON response should show a status of `failed` but the widget will say "No changes to code quality" For :two: 1. Run code quality on the head commit of an MR, but not the base commit 1. The JSON response should show a status of `not_found` and the widget will say "Failed to load codeclimate report" 1. The widget should have a question mark icon with a popover that says "Base pipeline code quality artifact not found" and links to the docs For :three: 1. Run code quality on the base commit and head commit of an MR with code quality changes 1. Once the job is done for the head commit, refresh the MR page until you can see the code quality widget 1. On the first load that you can see the widget, it should display "No changes to code quality" even though there are changes, and the network panel in your browser's dev tools should show a request for `codequality_reports.json` with a `204 No Content` response 1. Refresh the page again until the widget displays the real result ### Example Project <!-- If possible, please create an example project here on GitLab.com that exhibits the problematic behavior, and link to it here in the bug report. If you are using an older version of GitLab, this will also determine whether the bug is fixed in a more recent version. --> ### What is the current *bug* behavior? The code quality MR widget reports "No changes to code quality" when the report comparison has failed/errored The code quality MR widget reports "No changes to code quality" when the reports are still being parsed/compared ### What is the expected *correct* behavior? The code quality MR widget should show "Failed to load code quality" (or some other more specific/helpful error message) when the report comparison has failed/errored The code quality MR widget should show a loading indicator while the reports are being parsed/compared, continue to poll for results until the endpoint returns a different result, then display the corresponding message for that result. ### Relevant logs and/or screenshots <!-- Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's tough to read otherwise. --> ### Output of checks <!-- If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com --> #### Results of GitLab environment info <!-- Input any relevant GitLab environment information if needed. --> <details> <summary>Expand for output related to GitLab environment info</summary> <pre> (For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`) </pre> </details> #### Results of GitLab application Check <!-- Input any relevant GitLab application check information if needed. --> <details> <summary>Expand for output related to the GitLab application check</summary> <pre> (For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:check SANITIZE=true`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true`) (we will only investigate if the tests are passing) </pre> </details> ### Possible fixes <!-- If you can, link to the line of code that might be responsible for the problem. -->
issue