Commit df0a7fc6 authored by Dan Davison's avatar Dan Davison

Merge branch 'e2e-user-cancel-mr-in-merge-trains' into 'master'

E2E test user cancels MR in merge trains doesn't create To-Do item

See merge request gitlab-org/gitlab!60737
parents cd590145 7699975e
......@@ -169,6 +169,7 @@ export default {
role="button"
href="#"
class="btn btn-sm btn-default js-cancel-auto-merge"
data-qa-selector="cancel_auto_merge_button"
data-testid="cancelAutomaticMergeButton"
@click.prevent="cancelAutomaticMerge"
>
......
......@@ -115,6 +115,10 @@ module QA
element :diffs_tab
end
view 'app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_auto_merge_enabled.vue' do
element :cancel_auto_merge_button
end
def start_review
click_element(:start_review_button)
......@@ -348,6 +352,10 @@ module QA
click_element(:revert_button, Page::Component::CommitModal)
click_element(:submit_commit_button)
end
def cancel_auto_merge!
click_element(:cancel_auto_merge_button)
end
end
end
end
......
......@@ -4,28 +4,24 @@ require 'faker'
module QA
RSpec.describe 'Verify' do
describe 'Merge train', :runner, :requires_admin, quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/324122', type: :bug } do
let(:file_name) { Faker::Lorem.word }
let(:mr_title) { Faker::Lorem.sentence }
let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}" }
describe 'Cancelling merge request in merge train', :runner, :requires_admin do
before(:all) do
executor = "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}"
@file_name = Faker::File.unique.file_name
@admin_api_client = Runtime::API::Client.as_admin
let(:project) do
Resource::Project.fabricate_via_api! do |project|
@project = Resource::Project.fabricate_via_api! do |project|
project.name = 'pipeline-for-merge-train'
end
end
let!(:runner) do
Resource::Runner.fabricate_via_api! do |runner|
runner.project = project
@runner = Resource::Runner.fabricate_via_api! do |runner|
runner.project = @project
runner.name = executor
runner.tags = [executor]
end
end
let!(:original_files) do
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.project = @project
commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files(
[
......@@ -43,42 +39,44 @@ module QA
YAML
},
{
file_path: file_name,
file_path: @file_name,
content: Faker::Lorem.sentence
}
]
)
end
end
let(:user) do
Resource::User.fabricate_via_api! do |resource|
resource.api_client = admin_api_client
end
Flow::Login.sign_in
@project.visit!
Flow::MergeRequest.enable_merge_trains
end
let(:user_api_client) { Runtime::API::Client.new(:gitlab, user: user) }
let(:admin_api_client) { Runtime::API::Client.as_admin }
after(:all) do
@runner.remove_via_api!
@project.remove_via_api!
end
before do
Runtime::Feature.enable(:invite_members_group_modal, project: project)
@mr_title = Faker::Lorem.sentence
Flow::Login.sign_in
project.visit!
Flow::MergeRequest.enable_merge_trains
project.add_member(user, Resource::Members::AccessLevel::MAINTAINER)
@user = Resource::User.fabricate_via_api! do |resource|
resource.api_client = @admin_api_client
end
@user_api_client = Runtime::API::Client.new(:gitlab, user: @user)
@project.add_member(@user, Resource::Members::AccessLevel::MAINTAINER)
merge_request = Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.api_client = user_api_client
merge_request.title = mr_title
merge_request.project = project
merge_request.api_client = @user_api_client
merge_request.title = @mr_title
merge_request.project = @project
merge_request.description = Faker::Lorem.sentence
merge_request.target_new_branch = false
merge_request.file_name = file_name
merge_request.file_name = @file_name
merge_request.file_content = Faker::Lorem.sentence
end
Flow::Login.sign_in(as: user)
Flow::Login.sign_in(as: @user)
merge_request.visit!
Page::MergeRequest::Show.perform do |show|
......@@ -88,22 +86,20 @@ module QA
end
after do
runner.remove_via_api!
user.remove_via_api!
project.remove_via_api!
@user.remove_via_api!
end
context 'when system cancels a merge request' do
context 'when system cancels the merge request', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/324122', type: :bug } do
it 'creates a TODO task', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1741' do
# Create a merge conflict
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.api_client = user_api_client
commit.project = project
commit.api_client = @user_api_client
commit.project = @project
commit.commit_message = 'changing text file'
commit.update_files(
[
{
file_path: file_name,
file_path: @file_name,
content: 'Has to be different than before.'
}
]
......@@ -111,7 +107,7 @@ module QA
end
Page::MergeRequest::Show.perform do |show|
show.wait_until(max_duration: 90, reload: false) { show.has_content?('removed this merge request from the merge train') }
expect(show).to have_system_note('removed this merge request from the merge train')
end
Page::Main::Menu.perform do |main|
......@@ -125,6 +121,25 @@ module QA
end
end
end
context 'when user cancels the merge request' do
it 'does not create a TODO task', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1044' do
# Manually removes merge request from the train
Page::MergeRequest::Show.perform do |show|
show.cancel_auto_merge!
expect(show).to have_system_note('removed this merge request from the merge train')
end
Page::Main::Menu.perform do |main|
main.go_to_page_by_shortcut(:todos_shortcut_button)
end
Page::Dashboard::Todos.perform do |todos|
expect(todos).not_to have_todo_list, 'This user should not have any to-do item but found at least one!'
end
end
end
end
end
end
......@@ -39,6 +39,7 @@ exports[`MRWidgetAutoMergeEnabled when graphql is disabled template should have
<a
class="btn btn-sm btn-default js-cancel-auto-merge"
data-qa-selector="cancel_auto_merge_button"
data-testid="cancelAutomaticMergeButton"
href="#"
role="button"
......@@ -130,6 +131,7 @@ exports[`MRWidgetAutoMergeEnabled when graphql is enabled template should have c
<a
class="btn btn-sm btn-default js-cancel-auto-merge"
data-qa-selector="cancel_auto_merge_button"
data-testid="cancelAutomaticMergeButton"
href="#"
role="button"
......
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