Commit 19e09a52 authored by Désirée Chevalier's avatar Désirée Chevalier Committed by Dan Davison

Add Jira issue import e2e spec

Adds an E2E spec for Jira Issue Importer
parent ebe5d683
...@@ -70,6 +70,7 @@ export default { ...@@ -70,6 +70,7 @@ export default {
> >
<gl-form-select <gl-form-select
id="jira-project-select" id="jira-project-select"
data-qa-selector="jira_project_dropdown"
class="mb-2" class="mb-2"
:options="jiraProjects" :options="jiraProjects"
:state="selectState" :state="selectState"
...@@ -135,7 +136,13 @@ export default { ...@@ -135,7 +136,13 @@ export default {
</gl-form-group> </gl-form-group>
<div class="footer-block row-content-block d-flex justify-content-between"> <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') }} {{ __('Next') }}
</gl-button> </gl-button>
<gl-button :href="issuesPath">{{ __('Cancel') }}</gl-button> <gl-button :href="issuesPath">{{ __('Cancel') }}</gl-button>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
.dropdown.btn-group .dropdown.btn-group
%button.btn.rounded-right.text-center{ class: ('has-tooltip' if type == :icon), title: (_('Import issues') if type == :icon), %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 - if type == :icon
= sprite_icon('import') = sprite_icon('import')
- else - else
...@@ -13,4 +13,5 @@ ...@@ -13,4 +13,5 @@
%button{ data: { toggle: 'modal', target: '.issues-import-modal' } } %button{ data: { toggle: 'modal', target: '.issues-import-modal' } }
= _('Import CSV') = _('Import CSV')
- if can_edit - 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)
...@@ -308,6 +308,7 @@ module QA ...@@ -308,6 +308,7 @@ module QA
autoload :New, 'qa/page/project/issue/new' autoload :New, 'qa/page/project/issue/new'
autoload :Show, 'qa/page/project/issue/show' autoload :Show, 'qa/page/project/issue/show'
autoload :Index, 'qa/page/project/issue/index' autoload :Index, 'qa/page/project/issue/index'
autoload :JiraImport, 'qa/page/project/issue/jira_import'
end end
module Fork module Fork
......
...@@ -18,6 +18,11 @@ module QA ...@@ -18,6 +18,11 @@ module QA
element :export_issues_modal element :export_issues_modal
end 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 view 'app/views/projects/issues/_issue.html.haml' do
element :issue element :issue
element :issue_link, 'link_to issue.title' # rubocop:disable QA/ElementWithPattern element :issue_link, 'link_to issue.title' # rubocop:disable QA/ElementWithPattern
...@@ -51,10 +56,25 @@ module QA ...@@ -51,10 +56,25 @@ module QA
click_element(:export_issues_button) click_element(:export_issues_button)
end 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 def export_issues_modal
find_element(:export_issues_modal) find_element(:export_issues_modal)
end end
def go_to_jira_import_form
click_import_issues_dropdown
click_import_from_jira_link
end
def has_assignee_link_count?(count) def has_assignee_link_count?(count)
all_elements(:assignee_link, count: count) all_elements(:assignee_link, count: count)
end 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