Commit 268c99c9 authored by Dan Davison's avatar Dan Davison

Merge branch 'qa-add-jira-issue-import-spec' into 'master'

Add Jira issue import e2e spec

Closes gitlab-org/quality/testcases#823

See merge request gitlab-org/gitlab!32816
parents 9eb0b043 19e09a52
......@@ -70,6 +70,7 @@ export default {
>
<gl-form-select
id="jira-project-select"
data-qa-selector="jira_project_dropdown"
class="mb-2"
:options="jiraProjects"
:state="selectState"
......@@ -135,7 +136,13 @@ export default {
</gl-form-group>
<div class="footer-block row-content-block d-flex justify-content-between">
<gl-button type="submit" category="primary" variant="success" class="js-no-auto-disable">
<gl-button
type="submit"
category="primary"
variant="success"
class="js-no-auto-disable"
data-qa-selector="jira_issues_import_button"
>
{{ __('Next') }}
</gl-button>
<gl-button :href="issuesPath">{{ __('Cancel') }}</gl-button>
......
......@@ -3,7 +3,7 @@
.dropdown.btn-group
%button.btn.rounded-right.text-center{ class: ('has-tooltip' if type == :icon), title: (_('Import issues') if type == :icon),
data: { toggle: 'dropdown' }, 'aria-label' => _('Import issues'), 'aria-haspopup' => 'true', 'aria-expanded' => 'false' }
data: { toggle: 'dropdown', qa_selector: 'import_issues_button' }, 'aria-label' => _('Import issues'), 'aria-haspopup' => 'true', 'aria-expanded' => 'false' }
- if type == :icon
= sprite_icon('import')
- else
......@@ -13,4 +13,5 @@
%button{ data: { toggle: 'modal', target: '.issues-import-modal' } }
= _('Import CSV')
- if can_edit
%li= link_to _('Import from Jira'), project_import_jira_path(@project)
%li{ data: { qa_selector: 'import_from_jira_link' } }
= link_to _('Import from Jira'), project_import_jira_path(@project)
......@@ -309,6 +309,7 @@ module QA
autoload :New, 'qa/page/project/issue/new'
autoload :Show, 'qa/page/project/issue/show'
autoload :Index, 'qa/page/project/issue/index'
autoload :JiraImport, 'qa/page/project/issue/jira_import'
end
module Fork
......
......@@ -18,6 +18,11 @@ module QA
element :export_issues_modal
end
view 'app/views/projects/issues/import_csv/_button.html.haml' do
element :import_issues_button
element :import_from_jira_link
end
view 'app/views/projects/issues/_issue.html.haml' do
element :issue
element :issue_link, 'link_to issue.title' # rubocop:disable QA/ElementWithPattern
......@@ -51,10 +56,25 @@ module QA
click_element(:export_issues_button)
end
def click_import_from_jira_link
click_element(:import_from_jira_link)
end
def click_import_issues_dropdown
# When there are no issues, the image that loads causes the buttons to jump
has_loaded_all_images?
click_element(:import_issues_button)
end
def export_issues_modal
find_element(:export_issues_modal)
end
def go_to_jira_import_form
click_import_issues_dropdown
click_import_from_jira_link
end
def has_assignee_link_count?(count)
all_elements(:assignee_link, count: count)
end
......
# frozen_string_literal: true
module QA
module Page
module Project
module Issue
class JiraImport < Page::Base
view 'app/assets/javascripts/jira_import/components/jira_import_form.vue' do
element :jira_project_dropdown
element :jira_issues_import_button
end
def select_jira_project(jira_project)
select_element(:jira_project_dropdown, jira_project)
end
def select_project_and_import(jira_project)
select_jira_project(jira_project)
click_element(:jira_issues_import_button)
end
end
end
end
end
end
# frozen_string_literal: true
module QA
context 'Plan' do
describe 'Jira issue import', :jira, :orchestrated, :requires_admin do
let(:jira_project_key) { "JITD" }
let(:jira_issue_title) { "[#{jira_project_key}-1] Jira to GitLab Test Issue" }
let(:jira_issue_description) { "This issue is for testing importing Jira issues to GitLab." }
let(:jira_issue_label_1) { "jira-import::#{jira_project_key}-1" }
let(:jira_issue_label_2) { "QA" }
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = "jira_issue_import"
end
end
it 'imports issues from Jira' do
set_up_jira_integration
import_jira_issues
QA::Support::Retrier.retry_on_exception do
Page::Project::Menu.perform(&:click_issues)
Page::Project::Issue::Index.perform do |issues_page|
issues_page.click_issue_link(jira_issue_title)
end
end
expect(page).to have_content(jira_issue_description)
Page::Project::Issue::Show.perform do |issue|
expect(issue).to have_label(jira_issue_label_1)
expect(issue).to have_label(jira_issue_label_2)
end
end
private
def set_up_jira_integration
# Retry is required because allow_local_requests_from_web_hooks_and_services
# takes some time to get enabled.
# Bug issue: https://gitlab.com/gitlab-org/gitlab/-/issues/217010
QA::Support::Retrier.retry_on_exception(max_attempts: 5, sleep_interval: 3) do
Runtime::ApplicationSettings.set_application_settings(allow_local_requests_from_web_hooks_and_services: true)
page.visit Runtime::Scenario.gitlab_address
Flow::Login.sign_in_unless_signed_in
project.visit!
Page::Project::Menu.perform(&:go_to_integrations_settings)
QA::Page::Project::Settings::Integrations.perform(&:click_jira_link)
QA::Page::Project::Settings::Services::Jira.perform do |jira|
jira.setup_service_with(url: Vendor::Jira::JiraAPI.perform(&:base_url))
end
expect(page).not_to have_text("Url is blocked")
expect(page).to have_text("Jira activated")
end
end
def import_jira_issues
Page::Project::Menu.perform(&:click_issues)
Page::Project::Issue::Index.perform(&:go_to_jira_import_form)
Page::Project::Issue::JiraImport.perform do |form|
form.select_project_and_import(jira_project_key)
end
expect(page).to have_content("Import in progress")
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