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:
How to set up and validate locally
- set up coverage reports for a project (or clone this test project)
- open a new MR that adds some untested code
- open the devtools network panel and navigate to the
Changes
tab of the MR - watch for requests for
coverage_reports.json
as the MR's pipeline finishes, don't refresh the page, there should be a few responses with204 No content
status while it's still polling and a final200 OK
response with test coverage data for the files/lines that the MR changed
git checkout master
- (do the setup section above)
- when coverage data is received, the test coverage visualization will not appear without a page refresh
- (optional) refresh the page (or switch the diff view between inline and side-by-side) to make the test coverage visualization appear
git checkout 345987-rememoize-inline-coverage-when-finished-loading
- (do the setup section above)
- 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.
-
I have evaluated the MR acceptance checklist for this MR.