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.
  • createComponent now seeds projectPath and ref into the Apollo cache, like the app bootstrap (repository/index.js) and the sibling repository specs do. Without that, the projectPath and ref client queries resolve after mount, the last commit query refetches with new variables, and the mock response overwrites the live update.
  • The renders a CommitInfo component test read the same stale paginatedTree path from the mock data, so it compared against {} and could never fail. It now compares against the actual commit fields (excluding pipelines, which the subscription updates).

References

Closes #630943 (closed)

How to set up and validate locally

  1. Open a project's repository page where the last commit has a running pipeline.
  2. Watch the pipeline status icon next to the last commit as the pipeline progresses.
  3. 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.

Merge request reports

Loading
Loading