Commit 7699975e authored by Tiffany Rea's avatar Tiffany Rea Committed by Dan Davison

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

parent cbd76096
...@@ -169,6 +169,7 @@ export default { ...@@ -169,6 +169,7 @@ export default {
role="button" role="button"
href="#" href="#"
class="btn btn-sm btn-default js-cancel-auto-merge" class="btn btn-sm btn-default js-cancel-auto-merge"
data-qa-selector="cancel_auto_merge_button"
data-testid="cancelAutomaticMergeButton" data-testid="cancelAutomaticMergeButton"
@click.prevent="cancelAutomaticMerge" @click.prevent="cancelAutomaticMerge"
> >
......
...@@ -119,6 +119,10 @@ module QA ...@@ -119,6 +119,10 @@ module QA
element :commit_with_custom_message_button element :commit_with_custom_message_button
end 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 def start_review
click_element(:start_review_button) click_element(:start_review_button)
...@@ -385,6 +389,10 @@ module QA ...@@ -385,6 +389,10 @@ module QA
click_element(:revert_button, Page::Component::CommitModal) click_element(:revert_button, Page::Component::CommitModal)
click_element(:submit_commit_button) click_element(:submit_commit_button)
end end
def cancel_auto_merge!
click_element(:cancel_auto_merge_button)
end
end end
end end
end end
......
...@@ -4,28 +4,24 @@ require 'faker' ...@@ -4,28 +4,24 @@ require 'faker'
module QA module QA
RSpec.describe 'Verify' do RSpec.describe 'Verify' do
describe 'Merge train', :runner, :requires_admin, quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/324122', type: :bug } do describe 'Cancelling merge request in merge train', :runner, :requires_admin do
let(:file_name) { Faker::Lorem.word } before(:all) do
let(:mr_title) { Faker::Lorem.sentence } executor = "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}"
let(: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 @project = Resource::Project.fabricate_via_api! do |project|
Resource::Project.fabricate_via_api! do |project|
project.name = 'pipeline-for-merge-train' project.name = 'pipeline-for-merge-train'
end end
end
let!(:runner) do @runner = Resource::Runner.fabricate_via_api! do |runner|
Resource::Runner.fabricate_via_api! do |runner| runner.project = @project
runner.project = project
runner.name = executor runner.name = executor
runner.tags = [executor] runner.tags = [executor]
end end
end
let!(:original_files) do
Resource::Repository::Commit.fabricate_via_api! do |commit| Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project commit.project = @project
commit.commit_message = 'Add .gitlab-ci.yml' commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files( commit.add_files(
[ [
...@@ -43,42 +39,44 @@ module QA ...@@ -43,42 +39,44 @@ module QA
YAML YAML
}, },
{ {
file_path: file_name, file_path: @file_name,
content: Faker::Lorem.sentence content: Faker::Lorem.sentence
} }
] ]
) )
end end
end
let(:user) do Flow::Login.sign_in
Resource::User.fabricate_via_api! do |resource| @project.visit!
resource.api_client = admin_api_client Flow::MergeRequest.enable_merge_trains
end
end end
let(:user_api_client) { Runtime::API::Client.new(:gitlab, user: user) } after(:all) do
let(:admin_api_client) { Runtime::API::Client.as_admin } @runner.remove_via_api!
@project.remove_via_api!
end
before do before do
Runtime::Feature.enable(:invite_members_group_modal, project: project) @mr_title = Faker::Lorem.sentence
Flow::Login.sign_in @user = Resource::User.fabricate_via_api! do |resource|
project.visit! resource.api_client = @admin_api_client
Flow::MergeRequest.enable_merge_trains end
project.add_member(user, Resource::Members::AccessLevel::MAINTAINER)
@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 = Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.api_client = user_api_client merge_request.api_client = @user_api_client
merge_request.title = mr_title merge_request.title = @mr_title
merge_request.project = project merge_request.project = @project
merge_request.description = Faker::Lorem.sentence merge_request.description = Faker::Lorem.sentence
merge_request.target_new_branch = false 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 merge_request.file_content = Faker::Lorem.sentence
end end
Flow::Login.sign_in(as: user) Flow::Login.sign_in(as: @user)
merge_request.visit! merge_request.visit!
Page::MergeRequest::Show.perform do |show| Page::MergeRequest::Show.perform do |show|
...@@ -88,22 +86,20 @@ module QA ...@@ -88,22 +86,20 @@ module QA
end end
after do after do
runner.remove_via_api! @user.remove_via_api!
user.remove_via_api!
project.remove_via_api!
end 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 it 'creates a TODO task', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1741' do
# Create a merge conflict # Create a merge conflict
Resource::Repository::Commit.fabricate_via_api! do |commit| Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.api_client = user_api_client commit.api_client = @user_api_client
commit.project = project commit.project = @project
commit.commit_message = 'changing text file' commit.commit_message = 'changing text file'
commit.update_files( commit.update_files(
[ [
{ {
file_path: file_name, file_path: @file_name,
content: 'Has to be different than before.' content: 'Has to be different than before.'
} }
] ]
...@@ -111,7 +107,7 @@ module QA ...@@ -111,7 +107,7 @@ module QA
end end
Page::MergeRequest::Show.perform do |show| 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 end
Page::Main::Menu.perform do |main| Page::Main::Menu.perform do |main|
...@@ -125,6 +121,25 @@ module QA ...@@ -125,6 +121,25 @@ module QA
end end
end 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 end
end end
...@@ -40,6 +40,7 @@ exports[`MRWidgetAutoMergeEnabled when graphql is disabled template should have ...@@ -40,6 +40,7 @@ exports[`MRWidgetAutoMergeEnabled when graphql is disabled template should have
<a <a
class="btn btn-sm btn-default js-cancel-auto-merge" class="btn btn-sm btn-default js-cancel-auto-merge"
data-qa-selector="cancel_auto_merge_button"
data-testid="cancelAutomaticMergeButton" data-testid="cancelAutomaticMergeButton"
href="#" href="#"
role="button" role="button"
...@@ -132,6 +133,7 @@ exports[`MRWidgetAutoMergeEnabled when graphql is enabled template should have c ...@@ -132,6 +133,7 @@ exports[`MRWidgetAutoMergeEnabled when graphql is enabled template should have c
<a <a
class="btn btn-sm btn-default js-cancel-auto-merge" class="btn btn-sm btn-default js-cancel-auto-merge"
data-qa-selector="cancel_auto_merge_button"
data-testid="cancelAutomaticMergeButton" data-testid="cancelAutomaticMergeButton"
href="#" href="#"
role="button" 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