Skip to content

Recache coverage data when it's fully loaded

What does this MR do and why?

For #345987 (closed) and #342139 (closed)

This MR adds another parameter (coverageLoaded) to the cache key for the memoize-ation of the functions that get the coverage data for a line of code in the MR diff view (coverageStateLeft and coverageStateRight) so that the data will be recached when the coverage data is fully loaded. Without this parameter, if blank coverage data gets cached by memoize while the polling function is still waiting for incoming coverage data, the test coverage visualization won't appear until the page is reloaded (#342139 (closed)) or the diff view mode is changed (#345987 (closed)).

See the first commit in this MR for a test that would fail on master that demonstrates the caching issue.

The second commit adds the new parameter to the cache key to fix the caching issue, fixing the test from the first commit along with it.

Screenshots or screen recordings

There should be no visual changes, but here's the feature in question: Screen_Shot_2021-12-14_at_16.54.56

How to set up and validate locally

Setup:

  1. set up coverage reports for a project (or clone this test project)
  2. open a new MR that adds some untested code
  3. open the devtools network panel and navigate to the Changes tab of the MR
  4. watch for requests for coverage_reports.json as the MR's pipeline finishes, don't refresh the page, there should be a few responses with 204 No content status while it's still polling and a final 200 OK response with test coverage data for the files/lines that the MR changed

🐛 To see the bug:

  1. git checkout master
  2. (do the setup section above)
  3. when coverage data is received, the test coverage visualization will not appear without a page refresh
  4. (optional) refresh the page (or switch the diff view between inline and side-by-side) to make the test coverage visualization appear

👷🏻 To verify the fix:

  1. git checkout 345987-rememoize-inline-coverage-when-finished-loading
  2. (do the setup section above)
  3. the test coverage visualization should appear when coverage data is received, without needing to refresh the page

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Miranda Fluharty

Merge request reports

Loading