Commit a562cd92 authored by Mark Lapierre's avatar Mark Lapierre

Clean up method calls

Non-DSL method calls should use brackets
parent 4cc86e3c
......@@ -32,7 +32,7 @@ export default {
<gl-icon :size="12" name="angle-down" class="position-absolute" />
</a>
<div class="dropdown-menu dropdown-select dropdown-menu-selectable">
<div class="dropdown-content">
<div class="dropdown-content" data-qa-selector="dropdown_content">
<ul>
<li v-for="version in versions" :key="version.id">
<a :class="{ 'is-active': version.selected }" :href="version.href">
......
......@@ -100,6 +100,7 @@ export default {
<compare-dropdown-layout
:versions="diffCompareDropdownTargetVersions"
class="mr-version-compare-dropdown"
data-qa-selector="target_version_dropdown"
/>
</template>
<template #source>
......
......@@ -245,7 +245,14 @@ export default {
></strong>
</span>
<strong v-else v-gl-tooltip :title="filePath" class="file-title-name" data-container="body">
<strong
v-else
v-gl-tooltip
:title="filePath"
class="file-title-name"
data-container="body"
data-qa-selector="file_name_content"
>
{{ filePath }}
</strong>
</a>
......
......@@ -49,6 +49,18 @@ module QA
element :diffs_tab
end
view 'app/assets/javascripts/diffs/components/compare_dropdown_layout.vue' do
element :dropdown_content
end
view 'app/assets/javascripts/diffs/components/compare_versions.vue' do
element :target_version_dropdown
end
view 'app/assets/javascripts/diffs/components/diff_file_header.vue' do
element :file_name_content
end
view 'app/assets/javascripts/diffs/components/inline_diff_table_row.vue' do
element :new_diff_line
end
......@@ -79,46 +91,54 @@ module QA
end
def start_review
click_element :start_review_button
click_element(:start_review_button)
# After clicking the button, wait for it to disappear
# before moving on to the next part of the test
has_no_element? :start_review_button
has_no_element?(:start_review_button)
end
def click_target_version_dropdown
click_element(:target_version_dropdown)
end
def comment_now
click_element :comment_now_button
click_element(:comment_now_button)
# After clicking the button, wait for it to disappear
# before moving on to the next part of the test
has_no_element? :comment_now_button
has_no_element?(:comment_now_button)
end
def version_dropdown_content
find_element(:dropdown_content).text
end
def submit_pending_reviews
within_element :review_bar do
click_element :review_preview_toggle
click_element :submit_review
within_element(:review_bar) do
click_element(:review_preview_toggle)
click_element(:submit_review)
# After clicking the button, wait for it to disappear
# before moving on to the next part of the test
has_no_element? :submit_review
has_no_element?(:submit_review)
end
end
def discard_pending_reviews
within_element :review_bar do
click_element :discard_review
within_element(:review_bar) do
click_element(:discard_review)
end
click_element :modal_delete_pending_comments
click_element(:modal_delete_pending_comments)
end
def resolve_review_discussion
scroll_to_element :start_review_button
check_element :resolve_review_discussion_checkbox
scroll_to_element(:start_review_button)
check_element(:resolve_review_discussion_checkbox)
end
def unresolve_review_discussion
check_element :unresolve_review_discussion_checkbox
check_element(:unresolve_review_discussion_checkbox)
end
def add_comment_to_diff(text)
......@@ -156,6 +176,10 @@ module QA
has_no_text?('Fast-forward merge is not possible')
end
def has_file?(file_name)
has_element?(:file_name_content, text: file_name)
end
def has_merge_button?
refresh
......@@ -186,7 +210,7 @@ module QA
!find_element(:squash_checkbox).disabled?
end
click_element :squash_checkbox
click_element(:squash_checkbox)
end
def merge!
......@@ -231,7 +255,7 @@ module QA
!find_element(:mr_rebase_button).disabled?
end
click_element :mr_rebase_button
click_element(:mr_rebase_button)
success = wait_until do
has_text?('Fast-forward merge without a merge commit')
......@@ -247,12 +271,12 @@ module QA
end
def view_email_patches
click_element :download_dropdown
click_element(:download_dropdown)
visit_link_in_element(:download_email_patches)
end
def view_plain_diff
click_element :download_dropdown
click_element(:download_dropdown)
visit_link_in_element(:download_plain_diff)
end
......
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
describe 'View merge request merge-ref diff' do
let(:merge_request) do
Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.title = 'This is a merge request'
merge_request.description = '... for viewing merge-ref and merge-base diffs'
merge_request.file_content = 'This exists on the source branch only'
end
end
let(:new_file_name) { "added_file-#{SecureRandom.hex(8)}.txt" }
before do
commit_to_branch(merge_request.target_branch, new_file_name)
commit_to_branch(merge_request.source_branch, new_file_name)
Flow::Login.sign_in
end
context 'when the feature flag default_merge_ref_for_diffs is enabled' do
before do
Runtime::Feature.enable('default_merge_ref_for_diffs', project: merge_request.project)
merge_request.visit!
end
it 'views the merge-ref diff by default' do
Page::MergeRequest::Show.perform do |mr_page|
mr_page.click_diffs_tab
mr_page.click_target_version_dropdown
expect(mr_page.version_dropdown_content).to include('master (HEAD)')
expect(mr_page.version_dropdown_content).not_to include('master (base)')
expect(mr_page).to have_file(merge_request.file_name)
expect(mr_page).not_to have_file(new_file_name)
end
end
end
context 'when the feature flag default_merge_ref_for_diffs is disabled' do
before do
Runtime::Feature.disable('default_merge_ref_for_diffs', project: merge_request.project)
merge_request.visit!
end
it 'views the merge-base diff by default' do
Page::MergeRequest::Show.perform do |mr_page|
mr_page.click_diffs_tab
mr_page.click_target_version_dropdown
expect(mr_page.version_dropdown_content).to include('master (HEAD)')
expect(mr_page.version_dropdown_content).to include('master (base)')
expect(mr_page).to have_file(merge_request.file_name)
expect(mr_page).to have_file(new_file_name)
end
end
end
def commit_to_branch(branch, file)
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = merge_request.project
commit.branch = branch
commit.commit_message = "Add new file on #{branch}"
commit.add_files(
[
{
file_path: file,
content: "This exists on source and target branches"
}
]
)
end
end
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