Commit bf2faf39 authored by Phil Hughes's avatar Phil Hughes

Use headPipeline in GraphQL widget queries

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/323913
parent fe2022ba
......@@ -124,7 +124,7 @@ export default {
},
pipeline() {
if (this.glFeatures.mergeRequestWidgetGraphql) {
return this.state.pipelines?.nodes?.[0];
return this.state.headPipeline;
}
return this.mr.pipeline;
......
......@@ -11,12 +11,11 @@ query getState($projectPath: ID!, $iid: String!) {
mergeError
mergeStatus
mergeableDiscussionsState
pipelines(first: 1) {
nodes {
headPipeline {
id
status
warnings
}
}
shouldBeRebased
sourceBranchExists
state
......
......@@ -30,13 +30,11 @@ fragment ReadyToMerge on Project {
message
}
}
pipelines(first: 1) {
nodes {
headPipeline {
id
status
path
active
}
}
}
}
......@@ -163,7 +163,7 @@ export default class MergeRequestStore {
setGraphqlData(project) {
const { mergeRequest } = project;
const pipeline = mergeRequest.pipelines?.nodes?.[0];
const pipeline = mergeRequest.headPipeline;
this.projectArchived = project.archived;
this.onlyAllowMergeIfPipelineSucceeds = project.onlyAllowMergeIfPipelineSucceeds;
......
......@@ -17,6 +17,7 @@ RSpec.describe 'User adds a merge request to a merge train', :js do
end
before do
stub_const('Gitlab::QueryLimiting::Transaction::THRESHOLD', 200)
stub_feature_flags(disable_merge_trains: false)
stub_licensed_features(merge_pipelines: true, merge_trains: true)
project.add_maintainer(user)
......@@ -84,6 +85,12 @@ RSpec.describe 'User adds a merge request to a merge train', :js do
context "when user clicks 'Remove from merge train' button" do
before do
click_link 'Remove from merge train'
# Currently, this page shows "Add to merge train" button instead of "Start merge train",
# even though the merge train is empty.
# This likely is caused by the stale cache in client side. Frontend
# would need to refresh the mergiability data, specifically `stateData.mergeTrainsCount` periodically e.g. polling.
# As a workaround, we're doing a hard reload by executing `visit` here.
visit project_merge_request_path(project, merge_request)
end
it 'cancels automatic merge' do
......
......@@ -333,6 +333,31 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request',
end
end
context 'when the latest pipeline is running in the parent project' do
before do
Ci::CreatePipelineService.new(project, user, ref: 'feature')
.execute(:merge_request_event, merge_request: merge_request)
end
context 'when the previous pipeline failed in the fork project' do
before do
detached_merge_request_pipeline.drop!
end
context 'when the parent project enables pipeline must succeed' do
before do
project.update!(only_allow_merge_if_pipeline_succeeds: true)
end
it 'shows MWPS button' do
visit project_merge_request_path(project, merge_request)
expect(page).to have_button('Merge when pipeline succeeds')
end
end
end
end
context 'when a user merges a merge request from a forked project to the parent project' do
before do
click_link("Overview")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment