Commit 7530be6f authored by Jacques Erasmus's avatar Jacques Erasmus

Merge branch 'integrations/jira_issues_list_spec' into 'master'

Add new E2E test for Jira issues List

See merge request gitlab-org/gitlab!76064
parents c3e01ac3 1c7ea5f9
......@@ -117,7 +117,11 @@ export default {
</p>
<template v-if="showJiraIssuesIntegration">
<input name="service[issues_enabled]" type="hidden" :value="enableJiraIssues || false" />
<gl-form-checkbox v-model="enableJiraIssues" :disabled="isInheriting">
<gl-form-checkbox
v-model="enableJiraIssues"
:disabled="isInheriting"
data-qa-selector="service_jira_issues_enabled_checkbox"
>
{{ $options.i18n.enableCheckboxLabel }}
<template #help>
{{ $options.i18n.enableCheckboxHelp }}
......@@ -162,6 +166,7 @@ export default {
id="service_project_key"
v-model="projectKey"
name="service[project_key]"
data-qa-selector="service_jira_project_key_field"
:placeholder="$options.i18n.projectKeyPlaceholder"
:required="enableJiraIssues"
:state="validProjectKey"
......
......@@ -166,6 +166,8 @@ export default {
class="issue gl-display-flex! gl-px-5!"
:class="{ closed: issuable.closedAt, today: createdInPastDay }"
:data-labels="labelIdsString"
data-qa-selector="issuable_item_container"
:data-qa-issue-id="issuableId"
>
<gl-form-checkbox
v-if="showCheckbox"
......
......@@ -100,7 +100,7 @@ export default {
</script>
<template>
<div class="issuable-show-container">
<div class="issuable-show-container" data-qa-selector="issuable_show_container">
<issuable-header
:status-badge-class="statusBadgeClass"
:status-icon="statusIcon"
......
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Issue
module Jira
class Index < QA::Page::Base
view 'app/assets/javascripts/vue_shared/issuable/list/components/issuable_list_root.vue' do
element :issuable_search_container
end
view 'app/assets/javascripts/vue_shared/issuable/list/components/issuable_item.vue' do
element :issuable_item_container
end
def search_issues(issue_search_text)
within_element(:issuable_search_container) do
find('input.gl-filtered-search-term-input').click
find('input[aria-label="Search"]').set(issue_search_text)
find('button[aria-label="Search"]').click
end
wait_for_loading
end
def visible_issues
find_all('li.issue')
end
def click_issue(issue_key)
id = issue_key.split('-')[-1]
within_element(:issuable_item_container, issue_id: id) do
find('a.issue-title-text').click
end
end
def wait_for_loading
QA::Support::Waiter.wait_until(max_duration: 10, raise_on_failure: false) do
!has_css?('div.animation-container')
end
end
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Issue
module Jira
class Show < QA::Page::Base
view 'app/assets/javascripts/vue_shared/issuable/show/components/issuable_show_root.vue' do
element :issuable_show_container
end
def description_content
within_element(:issuable_show_container) do
find('.description').text
end
end
def summary_content
within_element(:issuable_show_container) do
find('.qa-title').text
end
end
end
end
end
end
end
end
end
......@@ -23,6 +23,11 @@ module QA
element :save_changes_button
end
view 'app/assets/javascripts/integrations/edit/components/jira_issues_fields.vue' do
element :service_jira_issues_enabled_checkbox
element :service_jira_project_key_field
end
def setup_service_with(url:)
QA::Runtime::Logger.info "Setting up JIRA"
......@@ -34,12 +39,22 @@ module QA
use_custom_transitions
set_transition_ids('11,21,31,41')
yield self if block_given?
click_save_changes_button
wait_until(reload: false) do
has_element?(:save_changes_button, wait: 1) ? !find_element(:save_changes_button).disabled? : true
end
end
def enable_jira_issues
check_element(:service_jira_issues_enabled_checkbox, true)
end
def set_jira_project_key(key)
fill_element(:service_jira_project_key_field, key)
end
private
def set_jira_server_url(url)
......
......@@ -51,6 +51,14 @@ module QA
end
end
def go_to_jira_issues
hover_issues do
within_submenu do
click_element(:sidebar_menu_item_link, menu_item: 'Jira issues')
end
end
end
private
def hover_issues
......
# frozen_string_literal: true
module QA
RSpec.describe 'Plan' do
describe 'Jira issues integration', :jira, :orchestrated, :requires_admin do
before(:context) do
jira_project_key = Vendor::Jira::JiraAPI.perform(&:create_project)
@project = Resource::Project.fabricate_via_api! do |project|
project.name = "jira_issue_list"
end
@summary_one = "Summary #{SecureRandom.hex(6)}"
@description_one = 'First Description'
@summary_two = "Summary #{SecureRandom.hex(6)}"
@description_two = 'Second Description'
@issue_key_one = Vendor::Jira::JiraAPI.perform do |jira|
jira.create_issue(jira_project_key, issue_type: 'Task', summary: @summary_one, description: @description_one)
end
@issue_key_two = Vendor::Jira::JiraAPI.perform do |jira|
jira.create_issue(jira_project_key, issue_type: 'Task', summary: @summary_two, description: @description_two)
end
setup_jira_integration(jira_project_key)
end
before do
login!
Page::Project::Menu.perform(&:go_to_jira_issues)
EE::Page::Project::Issue::Jira::Index.perform(&:wait_for_loading)
end
it(
'searching issues returns results',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348238'
) do
EE::Page::Project::Issue::Jira::Index.perform do |jira_index_page|
jira_index_page.search_issues(@summary_one)
end
issues = EE::Page::Project::Issue::Jira::Index.perform(&:visible_issues).map(&:text)
aggregate_failures do
expect(issues.size).to be(1)
expect(issues).to include(match(/#{@issue_key_one}/))
end
end
it 'shows open issues', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348237' do
issues = EE::Page::Project::Issue::Jira::Index.perform(&:visible_issues).map(&:text)
aggregate_failures do
expect(issues.size).to be(2)
expect(issues).to include(match(/#{@issue_key_one}/), match(/#{@issue_key_two}/))
end
end
it 'views an issue', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348236' do
EE::Page::Project::Issue::Jira::Index.perform do |jira_index_page|
jira_index_page.click_issue(@issue_key_two)
end
EE::Page::Project::Issue::Jira::Show.perform do |jira_show_page|
expect(jira_show_page.summary_content).to eql(@summary_two)
expect(jira_show_page.description_content).to eql(@description_two)
end
end
def login!
page.visit Runtime::Scenario.gitlab_address
Flow::Login.sign_in_unless_signed_in
@project.visit!
end
def setup_jira_integration(jira_project_key)
url = Vendor::Jira::JiraAPI.perform(&:base_url)
Runtime::ApplicationSettings.set_application_settings(allow_local_requests_from_web_hooks_and_services: true)
login!
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: url) do |service|
service.enable_jira_issues
service.set_jira_project_key(jira_project_key)
end
end
end
end
end
end
......@@ -7,6 +7,9 @@ module QA
include Scenario::Actable
include Support::API
DEFAULT_ISSUE_SUMMARY = 'REST ye merry gentlemen.'
DEFAULT_ISSUE_DESCRIPTION = 'Creating of an issue using project keys and issue type names using the REST API'
def base_url
host = QA::Runtime::Env.jira_hostname || 'localhost'
......@@ -18,27 +21,58 @@ module QA
end
def fetch_issue(issue_key)
response = get("#{api_url}/issue/#{issue_key}", user: Runtime::Env.jira_admin_username, password: Runtime::Env.jira_admin_password)
response = get("#{api_url}/issue/#{issue_key}",
user: Runtime::Env.jira_admin_username,
password: Runtime::Env.jira_admin_password)
parse_body(response)
end
def create_issue(jira_project_key)
def create_project(project_key = "GL#{SecureRandom.hex(4)}".upcase)
payload = {
key: project_key,
name: "Project #{project_key}",
description: "New Project #{project_key}",
lead: Runtime::Env.jira_admin_username,
projectTypeKey: 'software'
}
response = post(
"#{api_url}/project",
payload.to_json,
headers: { 'Content-Type' => 'application/json' },
user: Runtime::Env.jira_admin_username,
password: Runtime::Env.jira_admin_password)
returned_project_key = parse_body(response)[:key]
QA::Runtime::Logger.debug("Created JIRA project with key: '#{project_key}'")
returned_project_key
end
def create_issue(
jira_project_key,
issue_type: 'Bug',
summary: DEFAULT_ISSUE_SUMMARY,
description: DEFAULT_ISSUE_DESCRIPTION
)
payload = {
fields: {
project: {
key: jira_project_key
},
summary: 'REST ye merry gentlemen.',
description: 'Creating of an issue using project keys and issue type names using the REST API',
summary: summary,
description: description,
issuetype: {
name: 'Bug'
name: issue_type
}
}
}
response = post("#{api_url}/issue",
payload.to_json, headers: { 'Content-Type': 'application/json' },
response = post(
"#{api_url}/issue",
payload.to_json,
headers: { 'Content-Type': 'application/json' },
user: Runtime::Env.jira_admin_username,
password: Runtime::Env.jira_admin_password)
......
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