Commit 8b2532a3 authored by Dan Davison's avatar Dan Davison

Merge branch 'qa-add-click-by-js-to-checkboxes' into 'master'

Fix e2e checkbox workarounds

See merge request gitlab-org/gitlab!58958
parents 99cfad50 e80e136c
......@@ -214,7 +214,7 @@ export default {
<gl-form-checkbox
v-model="issueTransitionEnabled"
:disabled="isInheriting"
data-qa-selector="service_jira_issue_transition_enabled"
data-qa-selector="service_jira_issue_transition_enabled_checkbox"
>
{{ s__('JiraService|Enable Jira transitions') }}
</gl-form-checkbox>
......@@ -232,7 +232,7 @@ export default {
name="service[jira_issue_transition_automatic]"
:value="issueTransitionOption.value"
:disabled="isInheriting"
:data-qa-selector="`service_jira_issue_transition_automatic_${issueTransitionOption.value}`"
:data-qa-selector="`service_jira_issue_transition_automatic_${issueTransitionOption.value}_radio`"
>
{{ issueTransitionOption.label }}
......
......@@ -44,7 +44,8 @@ export default {
:checked="value"
:disabled="isDisabled"
name="squash"
class="qa-squash-checkbox js-squash-checkbox gl-mr-2 gl-display-flex gl-align-items-center"
class="js-squash-checkbox gl-mr-2 gl-display-flex gl-align-items-center"
data-qa-selector="squash_checkbox"
:title="tooltipTitle"
@change="(checked) => $emit('input', checked)"
>
......
......@@ -162,14 +162,11 @@ export default {
</template>
</markdown-field>
</gl-form-group>
<gl-form-group
:label="__('Confidentiality')"
label-for="epic-confidentiality"
data-qa-selector="confidential_epic_checkbox"
>
<gl-form-group :label="__('Confidentiality')" label-for="epic-confidentiality">
<gl-form-checkbox
id="epic-confidentiality"
v-model="confidential"
data-qa-selector="confidential_epic_checkbox"
data-testid="epic-confidentiality"
>
{{ $options.i18n.confidentialityLabel }}
......
......@@ -17,8 +17,7 @@ module QA
end
def enable_confidential_epic
# TODO: Fix this workaround for checkbox hidden by label
find_element(:confidential_epic_checkbox, visible: false).click
check_element(:confidential_epic_checkbox, true)
end
def set_title(title)
......
......@@ -132,7 +132,7 @@ module QA
all(element_selector_css(name), **kwargs)
end
def check_element(name)
def check_element(name, click_by_js = false)
if find_element(name, visible: false).checked?
QA::Runtime::Logger.debug("#{name} is already checked")
......@@ -140,7 +140,7 @@ module QA
end
retry_until(sleep_interval: 1) do
find_element(name, visible: false).click
click_checkbox_or_radio(name, click_by_js)
checked = find_element(name, visible: false).checked?
QA::Runtime::Logger.debug(checked ? "#{name} was checked" : "#{name} was not checked")
......@@ -149,7 +149,7 @@ module QA
end
end
def uncheck_element(name)
def uncheck_element(name, click_by_js = false)
unless find_element(name, visible: false).checked?
QA::Runtime::Logger.debug("#{name} is already unchecked")
......@@ -157,7 +157,7 @@ module QA
end
retry_until(sleep_interval: 1) do
find_element(name, visible: false).click
click_checkbox_or_radio(name, click_by_js)
unchecked = !find_element(name, visible: false).checked?
QA::Runtime::Logger.debug(unchecked ? "#{name} was unchecked" : "#{name} was not unchecked")
......@@ -175,9 +175,7 @@ module QA
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
click_checkbox_or_radio(name, click_by_js)
selected = find_element(name, visible: false).checked?
QA::Runtime::Logger.debug(selected ? "#{name} was selected" : "#{name} was not selected")
......@@ -423,6 +421,14 @@ module QA
end
end
end
private
def click_checkbox_or_radio(name, click_by_js)
box = find_element(name, visible: false)
# Some checkboxes and radio buttons are hidden by their labels and cannot be clicked directly
click_by_js ? page.execute_script("arguments[0].click();", box) : box.click
end
end
end
end
......@@ -238,18 +238,12 @@ module QA
end
def mark_to_squash
# The squash checkbox is disabled on load
wait_until do
has_element?(:squash_checkbox)
end
# The squash checkbox is enabled via JS
wait_until(reload: false) do
!find_element(:squash_checkbox).disabled?
!find_element(:squash_checkbox, visible: false).disabled?
end
# TODO: Fix workaround for data-qa-selector failure
click_element(:squash_checkbox)
check_element(:squash_checkbox, true)
end
def merge!
......
......@@ -13,9 +13,9 @@ module QA
end
view 'app/assets/javascripts/integrations/edit/components/jira_trigger_fields.vue' do
element :service_jira_issue_transition_enabled
element :service_jira_issue_transition_automatic_true, ':data-qa-selector="`service_jira_issue_transition_automatic_${issueTransitionOption.value}`"' # rubocop:disable QA/ElementWithPattern
element :service_jira_issue_transition_automatic_false, ':data-qa-selector="`service_jira_issue_transition_automatic_${issueTransitionOption.value}`"' # rubocop:disable QA/ElementWithPattern
element :service_jira_issue_transition_enabled_checkbox
element :service_jira_issue_transition_automatic_true_radio, ':data-qa-selector="`service_jira_issue_transition_automatic_${issueTransitionOption.value}_radio`"' # rubocop:disable QA/ElementWithPattern
element :service_jira_issue_transition_automatic_false_radio, ':data-qa-selector="`service_jira_issue_transition_automatic_${issueTransitionOption.value}_radio`"' # rubocop:disable QA/ElementWithPattern
element :service_jira_issue_transition_id_field
end
......@@ -55,15 +55,15 @@ module QA
end
def enable_transitions
click_element_coordinates(:service_jira_issue_transition_enabled, visible: false)
check_element(:service_jira_issue_transition_enabled_checkbox, true)
end
def use_automatic_transitions
click_element_coordinates(:service_jira_issue_transition_automatic_true, visible: false)
choose_element(:service_jira_issue_transition_automatic_true_radio, true)
end
def use_custom_transitions
click_element_coordinates(:service_jira_issue_transition_automatic_false, visible: false)
choose_element(:service_jira_issue_transition_automatic_false_radio, true)
end
def set_transition_ids(transition_ids)
......
......@@ -52,13 +52,13 @@ module QA
elements
end
def check_element(name)
def check_element(name, click_by_js = nil)
log("checking :#{name}")
super
end
def uncheck_element(name)
def uncheck_element(name, click_by_js = nil)
log("unchecking :#{name}")
super
......
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