Fix live pipeline status updates on the last commit widget
What does this MR do and why?
The last commit widget on the repository page subscribes to ciPipelineStatusUpdated so the pipeline status icon updates live. The subscription's updateQuery read the pipeline from project.repository.paginatedTree.nodes[0].lastCommit, but the pathLastCommit query returns project.repository.lastCommit. The lookup always fell back to {}, so every live update was dropped and the status only refreshed on the 30 second poll.
This points updateQuery at the path the query actually returns.
Spec changes in last_commit_spec.js:
- New test: the status icon reflects the status pushed by the subscription. It fails without the fix.
createComponentnow seedsprojectPathandrefinto the Apollo cache, like the app bootstrap (repository/index.js) and the sibling repository specs do. Without that, theprojectPathandrefclient queries resolve after mount, the last commit query refetches with new variables, and the mock response overwrites the live update.- The
renders a CommitInfo componenttest read the same stalepaginatedTreepath from the mock data, so it compared against{}and could never fail. It now compares against the actual commit fields (excludingpipelines, which the subscription updates).
References
Closes #630943 (closed)
How to set up and validate locally
- Open a project's repository page where the last commit has a running pipeline.
- Watch the pipeline status icon next to the last commit as the pipeline progresses.
- Before: the icon only changes on the 30 second poll. After: it updates as soon as the pipeline status changes.
Locally, yarn jest spec/frontend/repository/components/last_commit_spec.js passes (22 tests), the new test fails against the old code, and ESLint and Prettier are clean on both files.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.