Skip to content
代码片段 群组 项目
提交 7534d6b9 编辑于 作者: Nikola Milojevic's avatar Nikola Milojevic
浏览文件

Merge branch '426374-cs-to-ga-ui-changes' into 'master'

Update AI-powered admin settings on CS GA day

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/138523



Merged-by: default avatarNikola Milojevic <nmilojevic@gitlab.com>
Approved-by: default avatarNikola Milojevic <nmilojevic@gitlab.com>
Reviewed-by: default avatarRoy Zwambag <rzwambag@gitlab.com>
Co-authored-by: default avatarAleksei Lipniagov <alipniagov@gitlab.com>
No related branches found
No related tags found
无相关合并请求
- return if Gitlab.org_or_com?
- return unless License.feature_available?(:code_suggestions) || License.feature_available?(:ai_chat)
- ga_started = CodeSuggestions::SelfManaged::GA_SERVICE_START_TIME.past?
-# TODO: clean-up after Code Suggestions is GA (16.9+)
-# Details (internal): https://gitlab.com/gitlab-org/gitlab/-/issues/425047#note_1673643291
- if ga_started
- return unless License.feature_available?(:ai_chat)
- else
- return unless License.feature_available?(:code_suggestions) || License.feature_available?(:ai_chat)
- expanded = false
......@@ -18,16 +25,22 @@
%fieldset
.form-group
%h5.settings-header-controls
= s_('CodeSuggestionsSM|Code Suggestions %{beta}').html_safe % { beta: gl_badge_tag(_('Beta'), variant: :neutral, size: :sm) }
= f.gitlab_ui_checkbox_component :instance_level_code_suggestions_enabled,
s_('CodeSuggestionsSM|Enable Code Suggestions for this instance'),
help_text: ai_powered_testing_agreement
- if ga_started
= f.gitlab_ui_checkbox_component :instance_level_ai_beta_features_enabled,
s_('AIPoweredSM|Enable Experiment and Beta AI-powered features'),
help_text: ai_powered_testing_agreement
- else
-# TODO: remove this block after Code Suggestions is GA (16.9+)
%h5.settings-header-controls
= s_('CodeSuggestionsSM|Code Suggestions %{beta}').html_safe % { beta: gl_badge_tag(_('Beta'), variant: :neutral, size: :sm) }
= f.gitlab_ui_checkbox_component :instance_level_code_suggestions_enabled,
s_('CodeSuggestionsSM|Enable Code Suggestions for this instance'),
help_text: ai_powered_testing_agreement
%h5.settings-header-controls
= s_('AIPoweredSM|AI-powered features')
= f.gitlab_ui_checkbox_component :instance_level_ai_beta_features_enabled,
s_('AIPoweredSM|Enable Experiment and Beta AI-powered features'),
help_text: ai_powered_testing_agreement
%h5.settings-header-controls
= s_('AIPoweredSM|AI-powered features')
= f.gitlab_ui_checkbox_component :instance_level_ai_beta_features_enabled,
s_('AIPoweredSM|Enable Experiment and Beta AI-powered features'),
help_text: ai_powered_testing_agreement
= f.submit _('Save changes'), pajamas_button: true
# frozen_string_literal: true
module CodeSuggestions
class SelfManaged
GA_SERVICE_START_TIME = Time.zone.parse('2024-02-15T00:00:00Z')
end
end
......@@ -135,14 +135,14 @@
end
end
describe 'instance-level code suggestions settings', feature_category: :code_suggestions do
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?)
stub_licensed_features(code_suggestions: false)
end
shared_examples 'does not render the form' do
it 'does not render the form' do
shared_examples 'does not render Code Suggestions toggle' do
it 'does not render Code Suggestions toggle' do
render
expect(rendered).not_to have_field('application_setting_instance_level_code_suggestions_enabled')
end
......@@ -151,7 +151,7 @@
context 'when on .com or .org' do
let(:gitlab_org_or_com?) { true }
it_behaves_like 'does not render the form'
it_behaves_like 'does not render Code Suggestions toggle'
end
context 'when not on .com and not on .org' do
......@@ -163,9 +163,28 @@
stub_licensed_features(code_suggestions: true)
end
it 'renders the form' do
render
expect(rendered).to have_field('application_setting_instance_level_code_suggestions_enabled')
# TODO: clean up date-related tests after the Code Suggestions feature becomes GA (16.9+)
context 'when before the service start date' do
around do |example|
travel_to(CodeSuggestions::SelfManaged::GA_SERVICE_START_TIME - 1.day) do
example.run
end
end
it 'renders Code Suggestions toggle' do
render
expect(rendered).to have_field('application_setting_instance_level_code_suggestions_enabled')
end
end
context 'when after the service start date' do
around do |example|
travel_to(CodeSuggestions::SelfManaged::GA_SERVICE_START_TIME + 1.day) do
example.run
end
end
it_behaves_like 'does not render Code Suggestions toggle'
end
end
......@@ -174,12 +193,12 @@
stub_licensed_features(code_suggestions: false)
end
it_behaves_like 'does not render the form'
it_behaves_like 'does not render Code Suggestions toggle'
end
end
context 'with no license', :without_license do
it_behaves_like 'does not render the form'
it_behaves_like 'does not render Code Suggestions toggle'
end
end
end
......@@ -190,8 +209,8 @@
stub_licensed_features(ai_chat: false)
end
shared_examples 'does not render the form' do
it 'does not render the form' do
shared_examples 'does not render AI Beta features toggle' do
it 'does not render AI Beta features toggle' do
render
expect(rendered).not_to have_field('application_setting_instance_level_ai_beta_features_enabled')
end
......@@ -200,7 +219,7 @@
context 'when on .com or .org' do
let(:gitlab_org_or_com?) { true }
it_behaves_like 'does not render the form'
it_behaves_like 'does not render AI Beta features toggle'
end
context 'when not on .com and not on .org' do
......@@ -212,7 +231,7 @@
stub_licensed_features(ai_chat: true)
end
it 'renders the form' do
it 'renders AI Beta features toggle' do
render
expect(rendered).to have_field('application_setting_instance_level_ai_beta_features_enabled')
end
......@@ -222,7 +241,7 @@
stub_feature_flags(updated_ai_powered_features_menu_for_sm: false)
end
it_behaves_like 'does not render the form'
it_behaves_like 'does not render AI Beta features toggle'
end
end
......@@ -231,12 +250,48 @@
stub_licensed_features(ai_chat: false)
end
it_behaves_like 'does not render the form'
it_behaves_like 'does not render AI Beta features toggle'
end
end
context 'with no license', :without_license do
it_behaves_like 'does not render the form'
it_behaves_like 'does not render AI Beta features toggle'
end
end
end
# Tests specific license-related UI change that happens when the Code Suggestions feature becomes GA:
# (internal) https://gitlab.com/gitlab-org/gitlab/-/issues/425047#note_1673643291
# TODO: clean-up after Code Suggestions is GA (16.9+)
describe 'entire instance-level ai-powered menu section visibility', feature_category: :duo_chat do
where(:before_ga, :ai_chat_available, :code_suggestions_available, :expect_section_is_visible) do
true | false | false | false
true | false | true | true
true | true | false | true
true | true | true | true
false | false | false | false
false | false | true | false
false | true | false | true
false | true | true | true
end
with_them do
it 'sets entire ai-powered menu section visibility correctly' do
allow(::Gitlab).to receive(:org_or_com?).and_return(false)
stub_licensed_features(ai_chat: ai_chat_available, code_suggestions: code_suggestions_available)
ga_time = CodeSuggestions::SelfManaged::GA_SERVICE_START_TIME
test_time = before_ga ? ga_time - 1.day : ga_time + 1.day
travel_to(test_time) do
render
if expect_section_is_visible
expect(rendered).to have_content('AI-powered features')
else
expect(rendered).not_to have_content('AI-powered features')
end
end
end
end
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册