Commit 20e834aa authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch '344927-refactor-admin-deploy-keys-table-to-vue-update-feature-specs' into 'master'

Updates admin deploy keys feature specs after refactoring to Vue

See merge request gitlab-org/gitlab!75574
parents a912c833 c52e2fc1
...@@ -3,17 +3,19 @@ ...@@ -3,17 +3,19 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'admin deploy keys' do RSpec.describe 'admin deploy keys' do
include Spec::Support::Helpers::ModalHelpers
let_it_be(:admin) { create(:admin) } let_it_be(:admin) { create(:admin) }
let!(:deploy_key) { create(:deploy_key, public: true) } let!(:deploy_key) { create(:deploy_key, public: true) }
let!(:another_deploy_key) { create(:another_deploy_key, public: true) } let!(:another_deploy_key) { create(:another_deploy_key, public: true) }
before do before do
stub_feature_flags(admin_deploy_keys_vue: false)
sign_in(admin) sign_in(admin)
gitlab_enable_admin_mode_sign_in(admin) gitlab_enable_admin_mode_sign_in(admin)
end end
shared_examples 'renders deploy keys correctly' do
it 'show all public deploy keys' do it 'show all public deploy keys' do
visit admin_deploy_keys_path visit admin_deploy_keys_path
...@@ -57,7 +59,9 @@ RSpec.describe 'admin deploy keys' do ...@@ -57,7 +59,9 @@ RSpec.describe 'admin deploy keys' do
describe 'update an existing deploy key' do describe 'update an existing deploy key' do
before do before do
visit admin_deploy_keys_path visit admin_deploy_keys_path
find('tr', text: deploy_key.title).click_link('Edit') page.within('tr', text: deploy_key.title) do
click_link(_('Edit deploy key'))
end
end end
it 'updates an existing deploy key' do it 'updates an existing deploy key' do
...@@ -71,6 +75,10 @@ RSpec.describe 'admin deploy keys' do ...@@ -71,6 +75,10 @@ RSpec.describe 'admin deploy keys' do
end end
end end
end end
end
context 'when `admin_deploy_keys_vue` feature flag is enabled', :js do
it_behaves_like 'renders deploy keys correctly'
describe 'remove an existing deploy key' do describe 'remove an existing deploy key' do
before do before do
...@@ -78,7 +86,11 @@ RSpec.describe 'admin deploy keys' do ...@@ -78,7 +86,11 @@ RSpec.describe 'admin deploy keys' do
end end
it 'removes an existing deploy key' do it 'removes an existing deploy key' do
find('tr', text: deploy_key.title).click_link('Remove') accept_gl_confirm('Are you sure you want to delete this deploy key?', button_text: 'Delete') do
page.within('tr', text: deploy_key.title) do
click_button _('Delete deploy key')
end
end
expect(current_path).to eq admin_deploy_keys_path expect(current_path).to eq admin_deploy_keys_path
page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
...@@ -86,18 +98,30 @@ RSpec.describe 'admin deploy keys' do ...@@ -86,18 +98,30 @@ RSpec.describe 'admin deploy keys' do
end end
end end
end end
end
context 'when `admin_deploy_keys_vue` feature flag is enabled', :js do context 'when `admin_deploy_keys_vue` feature flag is disabled' do
before do before do
stub_feature_flags(admin_deploy_keys_vue: true) stub_feature_flags(admin_deploy_keys_vue: false)
end
it_behaves_like 'renders deploy keys correctly'
describe 'remove an existing deploy key' do
before do
visit admin_deploy_keys_path visit admin_deploy_keys_path
end end
it 'renders the Vue app', :aggregate_failures do it 'removes an existing deploy key' do
expect(page).to have_content('Public deploy keys') page.within('tr', text: deploy_key.title) do
expect(page).to have_selector('[data-testid="deploy-keys-list"]') click_link _('Remove deploy key')
expect(page).to have_link('New deploy key', href: new_admin_deploy_key_path) end
expect(current_path).to eq admin_deploy_keys_path
page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do
expect(page).not_to have_content(deploy_key.title)
end
end
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