Refactor end-to-end test to make it more robust

And simpler.
parent b0ece70a
......@@ -3,19 +3,18 @@
module QA
context 'Plan' do
describe 'Close issue' do
let(:issue_title) { 'issue title' }
let(:commit_message) { 'Closes' }
let(:issue) do
Resource::Issue.fabricate_via_api! do |issue|
issue.title = 'Issue to be closed via pushing a commit'
end
end
let(:project) { issue.project }
let(:issue_id) { issue.api_response[:iid] }
before do
Flow::Login.sign_in
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-foss/issues/38965
......@@ -23,24 +22,15 @@ module QA
end
it 'user closes an issue by pushing commit' do
push_commit("#{commit_message} ##{@issue_id}", false)
push_commit("Closes ##{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
issue.visit!
Page::Project::Issue::Show.perform do |show|
show.select_all_activities_filter
expect(show).to have_element(:reopen_issue_button)
expect(show).to have_content("closed via commit #{commit_sha}")
reopen_issue_button_visible = show.wait(reload: true) do
show.has_element?(:reopen_issue_button, wait: 1.0)
end
expect(reopen_issue_button_visible).to be_truthy
end
end
......@@ -49,7 +39,7 @@ module QA
push.commit_message = commit_message
push.new_branch = new_branch
push.file_content = commit_message
push.project = @project
push.project = project
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