Commit 3a81ca2f authored by pburdette's avatar pburdette

Update QA ci variables spec

Updated page object and relative
spec to ensure E2E is working
like it should.
parent f66aaf08
...@@ -65,12 +65,6 @@ export default { ...@@ -65,12 +65,6 @@ export default {
modalActionText() { modalActionText() {
return this.variableBeingEdited ? __('Update variable') : __('Add variable'); return this.variableBeingEdited ? __('Update variable') : __('Add variable');
}, },
primaryAction() {
return {
text: this.modalActionText,
attributes: { variant: 'success', disabled: !this.canSubmit },
};
},
maskedFeedback() { maskedFeedback() {
return __('This variable can not be masked'); return __('This variable can not be masked');
}, },
...@@ -120,6 +114,8 @@ export default { ...@@ -120,6 +114,8 @@ export default {
ref="modal" ref="modal"
:modal-id="$options.modalId" :modal-id="$options.modalId"
:title="modalActionText" :title="modalActionText"
static
lazy
@hidden="resetModalHandler" @hidden="resetModalHandler"
> >
<form> <form>
...@@ -127,7 +123,7 @@ export default { ...@@ -127,7 +123,7 @@ export default {
<gl-form-input <gl-form-input
id="ci-variable-key" id="ci-variable-key"
v-model="variableData.key" v-model="variableData.key"
data-qa-selector="variable_key" data-qa-selector="ci_variable_key_field"
/> />
</gl-form-group> </gl-form-group>
...@@ -142,7 +138,7 @@ export default { ...@@ -142,7 +138,7 @@ export default {
v-model="variableData.secret_value" v-model="variableData.secret_value"
rows="3" rows="3"
max-rows="6" max-rows="6"
data-qa-selector="variable_value" data-qa-selector="ci_variable_value_field"
/> />
</gl-form-group> </gl-form-group>
...@@ -189,7 +185,7 @@ export default { ...@@ -189,7 +185,7 @@ export default {
<gl-form-checkbox <gl-form-checkbox
ref="masked-ci-variable" ref="masked-ci-variable"
v-model="variableData.masked" v-model="variableData.masked"
data-qa-selector="variable_masked" data-qa-selector="ci_variable_masked_checkbox"
> >
{{ __('Mask variable') }} {{ __('Mask variable') }}
<gl-link href="/help/ci/variables/README#masked-variables"> <gl-link href="/help/ci/variables/README#masked-variables">
...@@ -218,6 +214,7 @@ export default { ...@@ -218,6 +214,7 @@ export default {
ref="deleteCiVariable" ref="deleteCiVariable"
category="secondary" category="secondary"
variant="danger" variant="danger"
data-qa-selector="ci_variable_delete_button"
@click="deleteVarAndClose" @click="deleteVarAndClose"
>{{ __('Delete variable') }}</gl-deprecated-button >{{ __('Delete variable') }}</gl-deprecated-button
> >
...@@ -225,6 +222,7 @@ export default { ...@@ -225,6 +222,7 @@ export default {
ref="updateOrAddVariable" ref="updateOrAddVariable"
:disabled="!canSubmit" :disabled="!canSubmit"
variant="success" variant="success"
data-qa-selector="ci_variable_save_button"
@click="updateOrAddVariable" @click="updateOrAddVariable"
>{{ modalActionText }} >{{ modalActionText }}
</gl-deprecated-button> </gl-deprecated-button>
......
...@@ -26,7 +26,6 @@ export default { ...@@ -26,7 +26,6 @@ export default {
{ {
key: 'value', key: 'value',
label: s__('CiVariables|Value'), label: s__('CiVariables|Value'),
tdClass: 'qa-ci-variable-input-value',
customStyle: { width: '40%' }, customStyle: { width: '40%' },
}, },
{ {
...@@ -89,6 +88,7 @@ export default { ...@@ -89,6 +88,7 @@ export default {
:fields="fields" :fields="fields"
:items="variables" :items="variables"
tbody-tr-class="js-ci-variable-row" tbody-tr-class="js-ci-variable-row"
data-qa-selector="ci_variable_table_content"
sort-by="key" sort-by="key"
sort-direction="asc" sort-direction="asc"
stacked="lg" stacked="lg"
...@@ -150,6 +150,7 @@ export default { ...@@ -150,6 +150,7 @@ export default {
<gl-deprecated-button <gl-deprecated-button
ref="edit-ci-variable" ref="edit-ci-variable"
v-gl-modal-directive="$options.modalId" v-gl-modal-directive="$options.modalId"
data-qa-selector="edit_ci_variable_button"
@click="editVariable(item)" @click="editVariable(item)"
> >
<gl-icon :size="$options.iconSize" name="pencil" /> <gl-icon :size="$options.iconSize" name="pencil" />
...@@ -168,7 +169,7 @@ export default { ...@@ -168,7 +169,7 @@ export default {
<gl-deprecated-button <gl-deprecated-button
v-if="tableIsNotEmpty" v-if="tableIsNotEmpty"
ref="secret-value-reveal-button" ref="secret-value-reveal-button"
data-qa-selector="reveal_ci_variable_value" data-qa-selector="reveal_ci_variable_value_button"
class="append-right-8" class="append-right-8"
@click="toggleValues(!valuesHidden)" @click="toggleValues(!valuesHidden)"
>{{ valuesButtonText }}</gl-deprecated-button >{{ valuesButtonText }}</gl-deprecated-button
...@@ -176,7 +177,7 @@ export default { ...@@ -176,7 +177,7 @@ export default {
<gl-deprecated-button <gl-deprecated-button
ref="add-ci-variable" ref="add-ci-variable"
v-gl-modal-directive="$options.modalId" v-gl-modal-directive="$options.modalId"
data-qa-selector="add_ci_variable" data-qa-selector="add_ci_variable_button"
variant="success" variant="success"
>{{ __('Add Variable') }}</gl-deprecated-button >{{ __('Add Variable') }}</gl-deprecated-button
> >
......
---
title: Fix failing ci variable e2e test
merge_request: 25924
author:
type: fixed
...@@ -7,75 +7,47 @@ module QA ...@@ -7,75 +7,47 @@ module QA
class CiVariables < Page::Base class CiVariables < Page::Base
include Common include Common
view 'app/views/ci/variables/_variable_row.html.haml' do view 'app/assets/javascripts/ci_variable_list/components/ci_variable_modal.vue' do
element :variable_row, '.ci-variable-row-body' # rubocop:disable QA/ElementWithPattern element :ci_variable_key_field
element :variable_key, '.qa-ci-variable-input-key' # rubocop:disable QA/ElementWithPattern element :ci_variable_value_field
element :variable_value, '.qa-ci-variable-input-value' # rubocop:disable QA/ElementWithPattern element :ci_variable_masked_checkbox
element :variable_masked element :ci_variable_save_button
element :ci_variable_delete_button
end end
view 'app/views/ci/variables/_index.html.haml' do view 'app/assets/javascripts/ci_variable_list/components/ci_variable_table.vue' do
element :save_variables, '.js-ci-variables-save-button' # rubocop:disable QA/ElementWithPattern element :ci_variable_table_content
element :reveal_values, '.js-secret-value-reveal-button' # rubocop:disable QA/ElementWithPattern element :add_ci_variable_button
element :edit_ci_variable_button
element :reveal_ci_variable_value_button
end end
def fill_variable(key, value, masked) def fill_variable(key, value, masked)
keys = all_elements(:ci_variable_input_key, minimum: 1) fill_element :ci_variable_key_field, key
index = keys.size - 1 fill_element :ci_variable_value_field, value
click_ci_variable_save_button
# After we fill the key, JS would generate another field so
# we need to use the same index to find the corresponding one.
keys[index].set(key)
node = all_elements(:ci_variable_input_value, count: keys.size + 1)[index]
# Simply run `node.set(value)` is too slow for long text here,
# so we need to run JavaScript directly to set the value.
# The code was inspired from:
# https://github.com/teamcapybara/capybara/blob/679548cea10773d45e32808f4d964377cfe5e892/lib/capybara/selenium/node.rb#L217
execute_script("arguments[0].value = #{value.to_json}", node)
masked_node = all_elements(:variable_masked, count: keys.size + 1)[index]
toggle_masked(masked_node, masked)
end
def save_variables
find('.js-ci-variables-save-button').click
end
def reveal_variables
find('.js-secret-value-reveal-button').click
end end
def variable_value(key) def click_add_variable
within('.ci-variable-row-body', text: key) do click_element :add_ci_variable_button
find('.qa-ci-variable-input-value').value
end
end end
def remove_variable(location: :first) def click_edit_ci_variable
within('.ci-variable-row-body', match: location) do within_element(:ci_variable_table_content) do
find('button.ci-variable-row-remove-button').click click_element :edit_ci_variable_button
end end
save_variables
end end
private def click_ci_variable_save_button
click_element :ci_variable_save_button
def toggle_masked(masked_node, masked)
wait_until(reload: false) do
masked_node.click
masked ? masked_enabled?(masked_node) : masked_disabled?(masked_node)
end
end end
def masked_enabled?(masked_node) def click_reveal_ci_variable_value_button
masked_node[:class].include?('is-checked') click_element :reveal_ci_variable_value_button
end end
def masked_disabled?(masked_node) def click_ci_variable_delete_button
!masked_enabled?(masked_node) click_element :ci_variable_delete_button
end end
end end
end end
......
...@@ -19,9 +19,8 @@ module QA ...@@ -19,9 +19,8 @@ module QA
Page::Project::Settings::CICD.perform do |setting| Page::Project::Settings::CICD.perform do |setting|
setting.expand_ci_variables do |page| setting.expand_ci_variables do |page|
page.click_add_variable
page.fill_variable(key, value, masked) page.fill_variable(key, value, masked)
page.save_variables
end end
end end
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module QA module QA
context 'Verify' do context 'Verify' do
describe 'Add or Remove CI variable via UI', :smoke, quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/issues/207915', type: :stale } do describe 'Add or Remove CI variable via UI', :smoke do
let!(:project) do let!(:project) do
Resource::Project.fabricate_via_api! do |project| Resource::Project.fabricate_via_api! do |project|
project.name = 'project-with-ci-variables' project.name = 'project-with-ci-variables'
...@@ -10,6 +10,14 @@ module QA ...@@ -10,6 +10,14 @@ module QA
end end
end end
before(:all) do
Runtime::Feature.enable_and_verify('new_variables_ui')
end
after(:all) do
Runtime::Feature.remove('new_variables_ui')
end
before do before do
Flow::Login.sign_in Flow::Login.sign_in
add_ci_variable add_ci_variable
...@@ -19,12 +27,12 @@ module QA ...@@ -19,12 +27,12 @@ module QA
it 'user adds a CI variable' do it 'user adds a CI variable' do
Page::Project::Settings::CICD.perform do |settings| Page::Project::Settings::CICD.perform do |settings|
settings.expand_ci_variables do |page| settings.expand_ci_variables do |page|
expect(page).to have_field(with: 'VARIABLE_KEY') expect(page).to have_text('VARIABLE_KEY')
expect(page).not_to have_field(with: 'some_CI_variable') expect(page).not_to have_text('some_CI_variable')
page.reveal_variables page.click_reveal_ci_variable_value_button
expect(page).to have_field(with: 'some_CI_variable') expect(page).to have_text('some_CI_variable')
end end
end end
end end
...@@ -32,9 +40,10 @@ module QA ...@@ -32,9 +40,10 @@ module QA
it 'user removes a CI variable' do it 'user removes a CI variable' do
Page::Project::Settings::CICD.perform do |settings| Page::Project::Settings::CICD.perform do |settings|
settings.expand_ci_variables do |page| settings.expand_ci_variables do |page|
page.remove_variable page.click_edit_ci_variable
page.click_ci_variable_delete_button
expect(page).not_to have_field(with: 'VARIABLE_KEY') expect(page).not_to have_text('VARIABLE_KEY')
end end
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