Commit 93c7c8db authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/323913/widgetUseHeadPipeline' into 'master'

Use headPipeline in GraphQL widget queries

See merge request gitlab-org/gitlab!57216
parents 71535a99 bf2faf39
......@@ -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,11 +11,10 @@ query getState($projectPath: ID!, $iid: String!) {
mergeError
mergeStatus
mergeableDiscussionsState
pipelines(first: 1) {
nodes {
status
warnings
}
headPipeline {
id
status
warnings
}
shouldBeRebased
sourceBranchExists
......
......@@ -30,13 +30,11 @@ fragment ReadyToMerge on Project {
message
}
}
pipelines(first: 1) {
nodes {
id
status
path
active
}
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