From 2b5079efdb7c4e7d5a607d95747ddeb0b8af9678 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 15 May 2023 21:07:42 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/factories/organizations.rb | 13 ++- .../components/editor/ci_editor_header_spec.js | 38 ++++++- .../components/pipeline_editor_tabs_spec.js | 2 + .../pipeline_editor/pipeline_editor_home_spec.js | 1 + .../list/__snapshots__/item_spec.js.snap | 8 +- .../pages/__snapshots__/index_spec.js.snap | 8 +- .../super_sidebar/components/sidebar_menu_spec.js | 47 +++++++-- spec/helpers/ci/pipeline_editor_helper_spec.rb | 5 + .../helpers/projects/ml/experiments_helper_spec.rb | 35 ------- .../admin/menus/admin_settings_menu_spec.rb | 3 +- .../sidebars/groups/menus/settings_menu_spec.rb | 6 ++ spec/lib/sidebars/menu_spec.rb | 2 + .../sidebars/projects/menus/settings_menu_spec.rb | 6 ++ ...20230509131736_add_default_organization_spec.rb | 20 ++++ spec/models/organization_spec.rb | 96 +++++++++++++++++- .../ml/candidate_details_presenter_spec.rb | 111 +++++++++++++++++++++ spec/support/helpers/test_env.rb | 1 + .../admin/menus/admin_menus_shared_examples.rb | 6 +- 18 files changed, 352 insertions(+), 56 deletions(-) create mode 100644 spec/migrations/20230509131736_add_default_organization_spec.rb create mode 100644 spec/presenters/ml/candidate_details_presenter_spec.rb (limited to 'spec') diff --git a/spec/factories/organizations.rb b/spec/factories/organizations.rb index a6684a8f95f..7ff0493d140 100644 --- a/spec/factories/organizations.rb +++ b/spec/factories/organizations.rb @@ -1,5 +1,16 @@ # frozen_string_literal: true FactoryBot.define do - factory :organization + factory :organization do + sequence(:name) { |n| "Organization ##{n}" } + + trait :default do + id { Organization::DEFAULT_ORGANIZATION_ID } + name { 'Default' } + initialize_with do + # Ensure we only use one default organization + Organization.find_by(id: Organization::DEFAULT_ORGANIZATION_ID) || new(**attributes) + end + end + end end diff --git a/spec/frontend/ci/pipeline_editor/components/editor/ci_editor_header_spec.js b/spec/frontend/ci/pipeline_editor/components/editor/ci_editor_header_spec.js index 2861fc35342..f1a5c4169fb 100644 --- a/spec/frontend/ci/pipeline_editor/components/editor/ci_editor_header_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/editor/ci_editor_header_spec.js @@ -11,12 +11,25 @@ describe('CI Editor Header', () => { let wrapper; let trackingSpy = null; - const createComponent = ({ showDrawer = false, showJobAssistantDrawer = false } = {}) => { + const createComponent = ({ + showDrawer = false, + showJobAssistantDrawer = false, + showAiAssistantDrawer = false, + aiChatAvailable = false, + aiCiConfigGenerator = false, + } = {}) => { wrapper = extendedWrapper( shallowMount(CiEditorHeader, { + provide: { + aiChatAvailable, + glFeatures: { + aiCiConfigGenerator, + }, + }, propsData: { showDrawer, showJobAssistantDrawer, + showAiAssistantDrawer, }, }), ); @@ -24,6 +37,7 @@ describe('CI Editor Header', () => { const findLinkBtn = () => wrapper.findByTestId('template-repo-link'); const findHelpBtn = () => wrapper.findByTestId('drawer-toggle'); + const findAiAssistnantBtn = () => wrapper.findByTestId('ai-assistant-drawer-toggle'); afterEach(() => { unmockTracking(); @@ -39,7 +53,29 @@ describe('CI Editor Header', () => { label, }); }; + describe('Ai Assistant toggle button', () => { + describe('when feature is unavailable', () => { + it('should not show ai button when feature toggle is off', () => { + createComponent({ aiChatAvailable: true }); + mockTracking(undefined, wrapper.element, jest.spyOn); + expect(findAiAssistnantBtn().exists()).toBe(false); + }); + + it('should not show ai button when feature is unavailable', () => { + createComponent({ aiCiConfigGenerator: true }); + mockTracking(undefined, wrapper.element, jest.spyOn); + expect(findAiAssistnantBtn().exists()).toBe(false); + }); + }); + describe('when feature is available', () => { + it('should show ai button', () => { + createComponent({ aiCiConfigGenerator: true, aiChatAvailable: true }); + mockTracking(undefined, wrapper.element, jest.spyOn); + expect(findAiAssistnantBtn().exists()).toBe(true); + }); + }); + }); describe('link button', () => { beforeEach(() => { createComponent(); diff --git a/spec/frontend/ci/pipeline_editor/components/pipeline_editor_tabs_spec.js b/spec/frontend/ci/pipeline_editor/components/pipeline_editor_tabs_spec.js index cbdf01105c7..471b033913b 100644 --- a/spec/frontend/ci/pipeline_editor/components/pipeline_editor_tabs_spec.js +++ b/spec/frontend/ci/pipeline_editor/components/pipeline_editor_tabs_spec.js @@ -57,6 +57,7 @@ describe('Pipeline editor tabs component', () => { isNewCiConfigFile: true, showDrawer: false, showJobAssistantDrawer: false, + showAiAssistantDrawer: false, ...props, }, data() { @@ -65,6 +66,7 @@ describe('Pipeline editor tabs component', () => { }; }, provide: { + aiChatAvailable: false, ciConfigPath: '/path/to/ci-config', ciLintPath: mockCiLintPath, currentBranch: 'main', diff --git a/spec/frontend/ci/pipeline_editor/pipeline_editor_home_spec.js b/spec/frontend/ci/pipeline_editor/pipeline_editor_home_spec.js index 7ec6d4c6a01..576263d5418 100644 --- a/spec/frontend/ci/pipeline_editor/pipeline_editor_home_spec.js +++ b/spec/frontend/ci/pipeline_editor/pipeline_editor_home_spec.js @@ -41,6 +41,7 @@ describe('Pipeline editor home wrapper', () => { ...props, }, provide: { + aiChatAvailable: false, projectFullPath: '', totalBranches: 19, glFeatures: { diff --git a/spec/frontend/design_management/components/list/__snapshots__/item_spec.js.snap b/spec/frontend/design_management/components/list/__snapshots__/item_spec.js.snap index 7773950708f..9451f35ac5b 100644 --- a/spec/frontend/design_management/components/list/__snapshots__/item_spec.js.snap +++ b/spec/frontend/design_management/components/list/__snapshots__/item_spec.js.snap @@ -38,13 +38,13 @@ exports[`Design management list item component with notes renders item with mult