diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-08 15:08:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-08 15:08:54 +0300 |
commit | 473b876fe3d7e0b36eb6268cc44a4fe0d94f4422 (patch) | |
tree | 2f6d5f2ecad53015024b6b1509896f5933c5c3e6 /spec/views | |
parent | dca8df0c90d8727d69b3501b15b481546897f3cd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/admin/application_settings/_ai_access.html.haml_spec.rb | 38 | ||||
-rw-r--r-- | spec/views/admin/application_settings/general.html.haml_spec.rb | 26 |
2 files changed, 64 insertions, 0 deletions
diff --git a/spec/views/admin/application_settings/_ai_access.html.haml_spec.rb b/spec/views/admin/application_settings/_ai_access.html.haml_spec.rb new file mode 100644 index 00000000000..e9e640f7cc6 --- /dev/null +++ b/spec/views/admin/application_settings/_ai_access.html.haml_spec.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'admin/application_settings/_ai_access.html.haml', feature_category: :code_suggestions do + let_it_be(:admin) { build_stubbed(:admin) } + let(:page) { Capybara::Node::Simple.new(rendered) } + + before do + allow(::Gitlab).to receive(:org_or_com?).and_return(false) # Will not render partial for .com or .org + assign(:application_setting, application_setting) + allow(view).to receive(:current_user) { admin } + allow(view).to receive(:expanded).and_return(true) + end + + context 'when ai_access_token is not set' do + let(:application_setting) { build(:application_setting) } + + it 'renders an empty password field' do + render + expect(rendered).to have_field('Personal access token', type: 'password') + expect(page.find_field('Personal access token').value).to be_blank + end + end + + context 'when ai_access_token is set' do + let(:application_setting) do + build(:application_setting, ai_access_token: 'ai_access_token', + instance_level_code_suggestions_enabled: true) + end + + it 'renders masked password field' do + render + expect(rendered).to have_field('Enter new personal access token', type: 'password') + expect(page.find_field('Enter new personal access token').value).to eq(ApplicationSettingMaskedAttrs::MASK) + end + end +end diff --git a/spec/views/admin/application_settings/general.html.haml_spec.rb b/spec/views/admin/application_settings/general.html.haml_spec.rb index dd49de8f880..861f3fffa83 100644 --- a/spec/views/admin/application_settings/general.html.haml_spec.rb +++ b/spec/views/admin/application_settings/general.html.haml_spec.rb @@ -110,4 +110,30 @@ RSpec.describe 'admin/application_settings/general.html.haml' do end end end + + describe 'instance-level code suggestions settings', feature_category: :code_suggestions do + before do + allow(::Gitlab).to receive(:org_or_com?).and_return(gitlab_org_or_com?) + + render + end + + context 'when on .com or .org' do + let(:gitlab_org_or_com?) { true } + + it 'does not render the form' do + expect(rendered).not_to have_field('application_setting_instance_level_code_suggestions_enabled') + expect(rendered).not_to have_field('application_setting_ai_access_token') + end + end + + context 'when not on .com and not on .org' do + let(:gitlab_org_or_com?) { false } + + it 'renders the form' do + expect(rendered).to have_field('application_setting_instance_level_code_suggestions_enabled') + expect(rendered).to have_field('application_setting_ai_access_token') + end + end + end end |