Commit 1720cbc8 authored by Mark Lapierre's avatar Mark Lapierre

Update merge request page object and rebase test

Use logged methods from Page::Base.
Raise errors if rebase! and merge! don't leave the UI in the
expected state.
parent 43f1a6b2
......@@ -50,17 +50,17 @@ module QA
end
def fast_forward_possible?
!has_text?('Fast-forward merge is not possible')
has_no_text?('Fast-forward merge is not possible')
end
def has_merge_button?
refresh
has_css?(element_selector_css(:merge_button))
has_element?(:merge_button)
end
def has_merge_options?
has_css?(element_selector_css(:merge_moment_dropdown))
has_element?(:merge_moment_dropdown)
end
def merge_immediately
......@@ -75,19 +75,21 @@ module QA
def rebase!
# The rebase button is disabled on load
wait do
has_css?(element_selector_css(:mr_rebase_button))
has_element?(:mr_rebase_button)
end
# The rebase button is enabled via JS
wait(reload: false) do
!first(element_selector_css(:mr_rebase_button)).disabled?
!find_element(:mr_rebase_button).disabled?
end
click_element :mr_rebase_button
wait(reload: false) do
success = wait(reload: false) do
has_text?('Fast-forward merge without a merge commit')
end
raise "Rebase did not appear to be successful" unless success
end
def has_assignee?(username)
......@@ -106,30 +108,32 @@ module QA
def merge!
# The merge button is disabled on load
wait do
has_css?(element_selector_css(:merge_button))
has_element?(:merge_button)
end
# The merge button is enabled via JS
wait(reload: false) do
!first(element_selector_css(:merge_button)).disabled?
!find_element(:merge_button).disabled?
end
merge_immediately
wait(reload: false) do
success = wait(reload: false) do
has_text?('The changes were merged into')
end
raise "Merge did not appear to be successful" unless success
end
def mark_to_squash
# The squash checkbox is disabled on load
wait do
has_css?(element_selector_css(:squash_checkbox))
has_element?(:squash_checkbox)
end
# The squash checkbox is enabled via JS
wait(reload: false) do
!first(element_selector_css(:squash_checkbox)).disabled?
!find_element(:squash_checkbox).disabled?
end
click_element :squash_checkbox
......@@ -145,7 +149,7 @@ module QA
def add_comment_to_diff(text)
wait(time: 5) do
page.has_text?("No newline at end of file")
has_text?("No newline at end of file")
end
all_elements(:new_diff_line).first.hover
click_element :diff_comment
......
......@@ -5,15 +5,15 @@ module QA
describe 'Merge request rebasing' do
it 'user rebases source branch of merge request' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
Page::Main::Login.perform(&:sign_in_using_credentials)
project = Resource::Project.fabricate! do |project|
project.name = "only-fast-forward"
end
project.visit!
Page::Project::Menu.act { go_to_settings }
Page::Project::Settings::MergeRequest.act { enable_ff_only }
Page::Project::Menu.perform(&:go_to_settings)
Page::Project::Settings::MergeRequest.perform(&:enable_ff_only)
merge_request = Resource::MergeRequest.fabricate! do |merge_request|
merge_request.project = project
......@@ -38,7 +38,7 @@ module QA
merge_request.rebase!
expect(merge_request).to have_merge_button
expect(merge_request.fast_forward_possible?).to be_truthy
expect(merge_request).to be_fast_forward_possible
end
end
end
......
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