Commit ad666a69 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'qa-close-issue-spec' into 'master'

Add E2E spec to ensure that issue closes with commit message

Closes gitlab-org/quality/testcases#15

See merge request gitlab-org/gitlab-ce!32347
parents a3c25718 8a5aa528
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
= render partial: 'signature', object: @commit.signature = render partial: 'signature', object: @commit.signature
%strong %strong
#{ s_('CommitBoxTitle|Commit') } #{ s_('CommitBoxTitle|Commit') }
%span.commit-sha= @commit.short_id %span.commit-sha{ data: { qa_selector: 'commit_sha_content' } }= @commit.short_id
= clipboard_button(text: @commit.id, title: _('Copy commit SHA to clipboard')) = clipboard_button(text: @commit.id, title: _('Copy commit SHA to clipboard'))
%span.d-none.d-sm-inline= _('authored') %span.d-none.d-sm-inline= _('authored')
#{time_ago_with_tooltip(@commit.authored_date)} #{time_ago_with_tooltip(@commit.authored_date)}
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
class: "d-none d-sm-none d-md-block btn btn-grouped btn-close js-btn-issue-action #{issuable_button_visibility(issuable, true)}", title: "Close #{display_issuable_type}" class: "d-none d-sm-none d-md-block btn btn-grouped btn-close js-btn-issue-action #{issuable_button_visibility(issuable, true)}", title: "Close #{display_issuable_type}"
- if can_reopen - if can_reopen
= link_to "Reopen #{display_issuable_type}", reopen_issuable_path(issuable), method: button_method, = link_to "Reopen #{display_issuable_type}", reopen_issuable_path(issuable), method: button_method,
class: "d-none d-sm-none d-md-block btn btn-grouped btn-reopen js-btn-issue-action #{issuable_button_visibility(issuable, false)}", title: "Reopen #{display_issuable_type}" class: "d-none d-sm-none d-md-block btn btn-grouped btn-reopen js-btn-issue-action #{issuable_button_visibility(issuable, false)}", title: "Reopen #{display_issuable_type}", data: { qa_selector: 'reopen_issue_button' }
- else - else
- if can_update && !are_close_and_open_buttons_hidden - if can_update && !are_close_and_open_buttons_hidden
= render 'shared/issuable/close_reopen_report_toggle', issuable: issuable = render 'shared/issuable/close_reopen_report_toggle', issuable: issuable
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#{issuables_state_counter_text(type, :closed, display_count)} #{issuables_state_counter_text(type, :closed, display_count)}
- else - else
%li{ class: active_when(params[:state] == 'closed') }> %li{ class: active_when(params[:state] == 'closed') }>
= link_to page_filter_path(state: 'closed'), id: 'state-closed', title: 'Filter by issues that are currently closed.', data: { state: 'closed' } do = link_to page_filter_path(state: 'closed'), id: 'state-closed', title: 'Filter by issues that are currently closed.', data: { state: 'closed', qa_selector: 'closed_issues_link' } do
#{issuables_state_counter_text(type, :closed, display_count)} #{issuables_state_counter_text(type, :closed, display_count)}
= render 'shared/issuable/nav_links/all', page_context_word: page_context_word, counter: issuables_state_counter_text(type, :all, display_count) = render 'shared/issuable/nav_links/all', page_context_word: page_context_word, counter: issuables_state_counter_text(type, :all, display_count)
...@@ -9,6 +9,7 @@ module QA ...@@ -9,6 +9,7 @@ module QA
element :options_button element :options_button
element :email_patches element :email_patches
element :plain_diff element :plain_diff
element :commit_sha_content
end end
def select_email_patches def select_email_patches
...@@ -20,6 +21,10 @@ module QA ...@@ -20,6 +21,10 @@ module QA
click_element :options_button click_element :options_button
click_element :plain_diff click_element :plain_diff
end end
def commit_sha
find_element(:commit_sha_content).text
end
end end
end end
end end
......
...@@ -9,9 +9,17 @@ module QA ...@@ -9,9 +9,17 @@ module QA
element :issue_link, 'link_to issue.title' # rubocop:disable QA/ElementWithPattern element :issue_link, 'link_to issue.title' # rubocop:disable QA/ElementWithPattern
end end
view 'app/views/shared/issuable/_nav.html.haml' do
element :closed_issues_link
end
def click_issue_link(title) def click_issue_link(title)
click_link(title) click_link(title)
end end
def click_closed_issues_link
click_element :closed_issues_link
end
end end
end end
end end
......
...@@ -37,6 +37,10 @@ module QA ...@@ -37,6 +37,10 @@ module QA
element :dropdown_menu_labels element :dropdown_menu_labels
end end
view 'app/views/shared/issuable/_close_reopen_button.html.haml' do
element :reopen_issue_button
end
# Adds a comment to an issue # Adds a comment to an issue
# attachment option should be an absolute path # attachment option should be an absolute path
def comment(text, attachment: nil, filter: :all_activities) def comment(text, attachment: nil, filter: :all_activities)
......
# frozen_string_literal: true
module QA
context 'Plan' do
describe 'Close issue' do
let(:issue_title) { 'issue title' }
let(:commit_message) { 'Closes' }
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
issue = Resource::Issue.fabricate_via_api! do |issue|
issue.title = issue_title
end
@project = issue.project
@issue_id = issue.api_response[:iid]
# Initial commit should be pushed because
# the very first commit to the project doesn't close the issue
# https://gitlab.com/gitlab-org/gitlab-ce/issues/38965
push_commit('Initial commit')
end
it 'user closes an issue by pushing commit' do
push_commit("#{commit_message} ##{@issue_id}", false)
@project.visit!
Page::Project::Show.perform do |show|
show.click_commit(commit_message)
end
commit_sha = Page::Project::Commit::Show.perform(&:commit_sha)
Page::Project::Menu.perform(&:click_issues)
Page::Project::Issue::Index.perform do |index|
index.click_closed_issues_link
index.click_issue_link(issue_title)
end
Page::Project::Issue::Show.perform do |show|
expect(show).to have_element(:reopen_issue_button)
expect(show).to have_content("closed via commit #{commit_sha}")
end
end
def push_commit(commit_message, new_branch = true)
Resource::Repository::ProjectPush.fabricate! do |push|
push.commit_message = commit_message
push.new_branch = new_branch
push.file_content = commit_message
push.project = @project
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