Commit 53295e35 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'pb-use-data-testid-for-ci-variable-table' into 'master'

Use testing selector for variable list feature spec

See merge request gitlab-org/gitlab!56123
parents 639adaf7 13dc5124
...@@ -84,7 +84,7 @@ export default { ...@@ -84,7 +84,7 @@ export default {
</script> </script>
<template> <template>
<div class="ci-variable-table"> <div class="ci-variable-table" data-testid="ci-variable-table">
<gl-table <gl-table
:fields="fields" :fields="fields"
:items="variables" :items="variables"
......
...@@ -57,7 +57,7 @@ RSpec.describe 'Project group variables', :js do ...@@ -57,7 +57,7 @@ RSpec.describe 'Project group variables', :js do
wait_for_requests wait_for_requests
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
expect(find('.js-ci-variable-row:nth-child(1) [data-label="Key"]').text).to eq(key1) expect(find('.js-ci-variable-row:nth-child(1) [data-label="Key"]').text).to eq(key1)
end end
end end
......
...@@ -32,7 +32,7 @@ RSpec.describe 'Project variables', :js do ...@@ -32,7 +32,7 @@ RSpec.describe 'Project variables', :js do
wait_for_requests wait_for_requests
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
expect(find('.js-ci-variable-row:first-child [data-label="Environments"]').text).to eq('review/*') expect(find('.js-ci-variable-row:first-child [data-label="Environments"]').text).to eq('review/*')
end end
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
RSpec.shared_examples 'variable list' do RSpec.shared_examples 'variable list' do
it 'shows a list of variables' do it 'shows a list of variables' do
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Key"]').text).to eq(variable.key) expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Key"]').text).to eq(variable.key)
end end
end end
...@@ -16,7 +16,7 @@ RSpec.shared_examples 'variable list' do ...@@ -16,7 +16,7 @@ RSpec.shared_examples 'variable list' do
wait_for_requests wait_for_requests
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Key"]').text).to eq('key') expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Key"]').text).to eq('key')
end end
end end
...@@ -30,7 +30,7 @@ RSpec.shared_examples 'variable list' do ...@@ -30,7 +30,7 @@ RSpec.shared_examples 'variable list' do
wait_for_requests wait_for_requests
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Key"]').text).to eq('key') expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Key"]').text).to eq('key')
expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Protected"] svg[data-testid="mobile-issue-close-icon"]')).to be_present expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Protected"] svg[data-testid="mobile-issue-close-icon"]')).to be_present
end end
...@@ -45,14 +45,14 @@ RSpec.shared_examples 'variable list' do ...@@ -45,14 +45,14 @@ RSpec.shared_examples 'variable list' do
wait_for_requests wait_for_requests
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Key"]').text).to eq('key') expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Key"]').text).to eq('key')
expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Masked"] svg[data-testid="close-icon"]')).to be_present expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Masked"] svg[data-testid="close-icon"]')).to be_present
end end
end end
it 'reveals and hides variables' do it 'reveals and hides variables' do
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
expect(first('.js-ci-variable-row td[data-label="Key"]').text).to eq(variable.key) expect(first('.js-ci-variable-row td[data-label="Key"]').text).to eq(variable.key)
expect(page).to have_content('*' * 17) expect(page).to have_content('*' * 17)
...@@ -72,7 +72,7 @@ RSpec.shared_examples 'variable list' do ...@@ -72,7 +72,7 @@ RSpec.shared_examples 'variable list' do
it 'deletes a variable' do it 'deletes a variable' do
expect(page).to have_selector('.js-ci-variable-row', count: 1) expect(page).to have_selector('.js-ci-variable-row', count: 1)
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
click_button('Edit') click_button('Edit')
end end
...@@ -86,7 +86,7 @@ RSpec.shared_examples 'variable list' do ...@@ -86,7 +86,7 @@ RSpec.shared_examples 'variable list' do
end end
it 'edits a variable' do it 'edits a variable' do
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
click_button('Edit') click_button('Edit')
end end
...@@ -102,7 +102,7 @@ RSpec.shared_examples 'variable list' do ...@@ -102,7 +102,7 @@ RSpec.shared_examples 'variable list' do
end end
it 'edits a variable to be unmasked' do it 'edits a variable to be unmasked' do
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
click_button('Edit') click_button('Edit')
end end
...@@ -115,13 +115,13 @@ RSpec.shared_examples 'variable list' do ...@@ -115,13 +115,13 @@ RSpec.shared_examples 'variable list' do
wait_for_requests wait_for_requests
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Masked"] svg[data-testid="close-icon"]')).to be_present expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Masked"] svg[data-testid="close-icon"]')).to be_present
end end
end end
it 'edits a variable to be masked' do it 'edits a variable to be masked' do
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
click_button('Edit') click_button('Edit')
end end
...@@ -133,7 +133,7 @@ RSpec.shared_examples 'variable list' do ...@@ -133,7 +133,7 @@ RSpec.shared_examples 'variable list' do
wait_for_requests wait_for_requests
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
click_button('Edit') click_button('Edit')
end end
...@@ -143,7 +143,7 @@ RSpec.shared_examples 'variable list' do ...@@ -143,7 +143,7 @@ RSpec.shared_examples 'variable list' do
click_button('Update variable') click_button('Update variable')
end end
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Masked"] svg[data-testid="mobile-issue-close-icon"]')).to be_present expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Masked"] svg[data-testid="mobile-issue-close-icon"]')).to be_present
end end
end end
...@@ -211,7 +211,7 @@ RSpec.shared_examples 'variable list' do ...@@ -211,7 +211,7 @@ RSpec.shared_examples 'variable list' do
expect(page).to have_selector('.js-ci-variable-row', count: 3) expect(page).to have_selector('.js-ci-variable-row', count: 3)
# Remove the `akey` variable # Remove the `akey` variable
page.within('.ci-variable-table') do page.within('[data-testid="ci-variable-table"]') do
page.within('.js-ci-variable-row:first-child') do page.within('.js-ci-variable-row:first-child') do
click_button('Edit') click_button('Edit')
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