Commit 6df0233c authored by Dan Davison's avatar Dan Davison

Merge branch 'qa-update-radio-e2e-functionality' into 'master'

Update radio button e2e functionality

See merge request gitlab-org/gitlab!56871
parents 08c42ed7 aaa07596
......@@ -78,9 +78,12 @@ export default {
};
</script>
<template>
<div data-qa-selector="admin_license_compliance_row">
<div
data-qa-selector="admin_license_compliance_container"
data-testid="admin-license-compliance-row"
>
<issue-status-icon :status="status" class="float-left gl-mr-3" />
<span class="js-license-name" data-qa-selector="license_name_content">{{ license.name }}</span>
<span class="js-license-name">{{ license.name }}</span>
<div class="float-right">
<div class="d-flex">
<gl-loading-icon v-if="loading" class="js-loading-icon d-flex align-items-center mr-2" />
......
......@@ -13,7 +13,7 @@
.container.blank-state-container
.text-center
= custom_icon("missing_license")
%h4{ data: { qa_selector: 'missing_license' } }
%h4{ data: { qa_selector: 'missing_license_content' } }
= s_('License|You do not have a license.')
- if License.eligible_for_trial?
%p.trial-description= s_('License|You can start a free trial of GitLab Ultimate without any obligation or payment details.')
......
......@@ -31,7 +31,7 @@
.option-title
Upload <code>.gitlab-license</code> file
.form-check
= radio_button_tag :license_type, :key, @license.data.present?, class: 'form-check-input'
= radio_button_tag :license_type, :key, @license.data.present?, class: 'form-check-input', data: { qa_selector: 'license_type_key_radio' }
= label_tag :license_type_key, class: 'form-check-label' do
.option-title
Enter license key
......@@ -46,14 +46,14 @@
.col-sm-2.col-form-label
= f.label :data, "License key"
.col-sm-10
= f.text_area :data, class: "form-control license-key-field", rows: 20
= f.text_area :data, class: "form-control license-key-field", data: { qa_selector: 'license_key_field' }, rows: 20
.form-group.row
.col-sm-2
.col-sm-10
= label_tag :accept_eula, nil, class: 'form-check-label' do
= check_box_tag :accept_eula, data: { qa_selector: 'accept_eula' }
= check_box_tag :accept_eula, nil, false, data: { qa_selector: 'accept_eula_checkbox' }
= _('Unless otherwise agreed to in writing with GitLab, by clicking "Upload License" you agree that your use of GitLab Software is subject to the %{eula_link_start}Terms of Service%{eula_link_end}.').html_safe % { eula_link_start: eula_link_start, eula_url: eula_url, eula_link_end: '</a>'.html_safe }
.form-actions
= f.submit 'Upload License', class: 'gl-button btn btn-confirm', disabled: true, id: 'js-upload-license'
= f.submit 'Upload License', class: 'gl-button btn btn-confirm', data: { qa_selector: 'license_upload_button' }, disabled: true, id: 'js-upload-license'
......@@ -51,7 +51,7 @@ RSpec.describe 'EE > Projects > Licenses > Maintainer views policies', :js do
end
it 'displays the classification' do
selector = "div[data-qa-selector='admin_license_compliance_row']"
selector = "div[data-testid='admin-license-compliance-row']"
expect(page).to have_selector(selector)
row = page.find(selector)
......
......@@ -145,7 +145,6 @@ module QA
autoload :Integrations, 'qa/ee/page/project/settings/integrations'
autoload :Repository, 'qa/ee/page/project/settings/repository'
autoload :PushRules, 'qa/ee/page/project/settings/push_rules'
autoload :LicenseCompliance, 'qa/ee/page/project/settings/license_compliance'
autoload :IssueTemplateDefault, 'qa/ee/page/project/settings/issue_template_default.rb'
autoload :CICD, 'qa/ee/page/project/settings/ci_cd'
autoload :PipelineSubscriptions, 'qa/ee/page/project/settings/pipeline_subscriptions'
......
......@@ -6,7 +6,7 @@ module QA
module Admin
class License < QA::Page::Base
view 'ee/app/views/admin/licenses/missing.html.haml' do
element :missing_license
element :missing_license_content
end
view 'ee/app/views/admin/licenses/show.html.haml' do
......@@ -18,25 +18,24 @@ module QA
end
view 'ee/app/views/admin/licenses/new.html.haml' do
element :license_type, 'radio_button_tag :license_type' # rubocop:disable QA/ElementWithPattern
element :license_type_placeholder, 'Enter license key' # rubocop:disable QA/ElementWithPattern
element :license_key_field, 'text_area :data' # rubocop:disable QA/ElementWithPattern
element :license_key_placeholder, 'label :data, "License key"' # rubocop:disable QA/ElementWithPattern
element :license_upload_button, "submit 'Upload License'" # rubocop:disable QA/ElementWithPattern
element :accept_eula_checkbox
element :license_key_field
element :license_type_key_radio
element :license_upload_button
end
def license?
has_element?(:remove_license_link) || !has_element?(:missing_license)
has_element?(:remove_license_link) || !has_element?(:missing_license_content)
end
def add_new_license(key)
raise 'License key empty!' if key.to_s.empty?
click_link 'Upload New License'
choose 'Enter license key'
fill_in 'License key', with: key
check 'accept_eula'
click_button 'Upload License'
click_element(:license_upload_link)
choose_element(:license_type_key_radio)
fill_element(:license_key_field, key)
check_element(:accept_eula_checkbox)
click_element(:license_upload_button)
end
end
end
......
......@@ -21,46 +21,45 @@ module QA
end
view 'ee/app/assets/javascripts/vue_shared/license_compliance/components/admin_license_management_row.vue' do
element :admin_license_compliance_row
element :license_name_content
element :admin_license_compliance_container
end
def approve_license(license)
click_element :license_add_button
click_element(:license_add_button)
expand_select_list
search_and_select_exact license
find('.custom-control-label', text: 'Allow').click
click_element :add_license_submit_button
search_and_select_exact(license)
choose_element(:approved_license_radio, true)
click_element(:add_license_submit_button)
has_approved_license? license
has_approved_license?(license)
end
def has_approved_license?(name)
has_element?(:admin_license_compliance_row, text: name)
within_element(:admin_license_compliance_row, text: name) do
has_element?(:admin_license_compliance_container, text: name)
within_element(:admin_license_compliance_container, text: name) do
has_element?(:status_success_icon)
end
end
def deny_license(license)
click_element :license_add_button
click_element(:license_add_button)
expand_select_list
search_and_select_exact license
find('.custom-control-label', text: 'Deny').click
click_element :add_license_submit_button
search_and_select_exact(license)
choose_element(:blacklisted_license_radio, true)
click_element(:add_license_submit_button)
has_denied_license? license
has_denied_license?(license)
end
def has_denied_license?(name)
has_element?(:admin_license_compliance_row, text: name)
within_element(:admin_license_compliance_row, text: name) do
has_element?(:admin_license_compliance_container, text: name)
within_element(:admin_license_compliance_container, text: name) do
has_element?(:status_failed_icon)
end
end
def open_tab
click_element :policies_tab
click_element(:policies_tab)
end
end
end
......
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Settings
class LicenseCompliance < QA::Page::Base
include QA::Page::Component::Select2 # Select2 is an external library, so we can't add our own selectors
view 'ee/app/assets/javascripts/vue_shared/license_compliance/license_management.vue' do
element :license_add_button
end
view 'ee/app/assets/javascripts/vue_shared/license_compliance/components/add_license_form.vue' do
element :license_radio, 'data-qa-selector="`${option.value}_license_radio`"' # rubocop:disable QA/ElementWithPattern
element :add_license_submit_button
end
view 'ee/app/assets/javascripts/vue_shared/license_compliance/license_management.vue' do
element :license_compliance_list
end
view 'ee/app/assets/javascripts/vue_shared/license_compliance/components/admin_license_management_row.vue' do
element :admin_license_compliance_row
element :license_name_content
end
view 'app/assets/javascripts/reports/components/issue_status_icon.vue' do
element :icon_status, ':data-qa-selector="`status_${status}_icon`" ' # rubocop:disable QA/ElementWithPattern
end
def has_approved_license?(name)
within_element(:admin_license_compliance_row, text: name) do
has_element?(:status_success_icon)
end
end
def has_denied_license?(name)
within_element(:admin_license_compliance_row, text: name) do
has_element?(:status_failed_icon)
end
end
def approve_license(license)
click_element :license_add_button
expand_select_list
search_and_select license
click_element :approved_license_radio
click_element :add_license_submit_button
has_approved_license? license
end
def deny_license(license)
click_element :license_add_button
expand_select_list
search_and_select license
click_element :blacklisted_license_radio
click_element :add_license_submit_button
has_denied_license? license
end
end
end
end
end
end
end
......@@ -166,6 +166,26 @@ module QA
end
end
# Method for selecting radios
def choose_element(name, click_by_js = false)
if find_element(name, visible: false).checked?
QA::Runtime::Logger.debug("#{name} is already selected")
return
end
retry_until(sleep_interval: 1) do
radio = find_element(name, visible: false)
# Some radio buttons are hidden by their labels and cannot be clicked directly
click_by_js ? page.execute_script("arguments[0].click();", radio) : radio.click
selected = find_element(name, visible: false).checked?
QA::Runtime::Logger.debug(selected ? "#{name} was selected" : "#{name} was not selected")
selected
end
end
# Use this to simulate moving the pointer to an element's coordinate
# and sending a click event.
# This is a helpful workaround when there is a transparent element overlapping
......
......@@ -20,11 +20,11 @@ module QA
end
def click_save_changes
click_element :save_merge_request_changes_button
click_element(:save_merge_request_changes_button)
end
def enable_ff_only
click_element :merge_ff_radio_button
click_element(:merge_ff_radio_button)
click_save_changes
end
......
......@@ -81,7 +81,7 @@ module QA
end
def fill_element(name, content)
masked_content = name.to_s.include?('password') ? '*****' : content
masked_content = name.to_s.match?(/token|key|password/) ? '*****' : content
log(%Q(filling :#{name} with "#{masked_content}"))
......
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