diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-10 21:13:10 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-10 21:13:10 +0000 |
commit | d9710d79c52bc73438022e79c79cfe3ab35b084b (patch) | |
tree | 4ccba377283753036ad28a75d061f7ee61afa806 /spec | |
parent | 20a86e7f6fd58882025b1c85b21e891d75220da5 (diff) | |
download | gitlab-ce-d9710d79c52bc73438022e79c79cfe3ab35b084b.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
15 files changed, 126 insertions, 287 deletions
diff --git a/spec/features/broadcast_messages_spec.rb b/spec/features/broadcast_messages_spec.rb index 3e4289347e3..2fad15c8a1f 100644 --- a/spec/features/broadcast_messages_spec.rb +++ b/spec/features/broadcast_messages_spec.rb @@ -7,7 +7,7 @@ RSpec.describe 'Broadcast Messages', feature_category: :onboarding do shared_examples 'a Broadcast Messages' do |type| it 'shows broadcast message' do - visit root_path + visit explore_projects_path expect(page).to have_content 'SampleMessage' end @@ -15,17 +15,17 @@ RSpec.describe 'Broadcast Messages', feature_category: :onboarding do it 'renders styled links' do create(:broadcast_message, type, message: "<a href='gitlab.com' style='color: purple'>click me</a>") - visit root_path + visit explore_projects_path expected_html = "<p><a href=\"gitlab.com\" style=\"color: purple\">click me</a></p>" expect(page.body).to include(expected_html) end end - shared_examples 'a dismissable Broadcast Messages' do + shared_examples 'a dismissible Broadcast Messages' do it 'hides broadcast message after dismiss', :js, quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/390900' do - visit root_path + visit explore_projects_path find('.js-dismiss-current-broadcast-notification').click @@ -34,25 +34,25 @@ RSpec.describe 'Broadcast Messages', feature_category: :onboarding do it 'broadcast message is still hidden after refresh', :js, quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/391406' do - visit root_path + visit explore_projects_path find('.js-dismiss-current-broadcast-notification').click wait_for_cookie_set("hide_broadcast_message_#{broadcast_message.id}") - visit root_path + visit explore_projects_path expect(page).not_to have_content 'SampleMessage' end end describe 'banner type' do - let!(:broadcast_message) { create(:broadcast_message, message: 'SampleMessage') } + let_it_be(:broadcast_message) { create(:broadcast_message, message: 'SampleMessage') } it_behaves_like 'a Broadcast Messages' - it 'is not dismissable' do - visit root_path + it 'is not dismissible' do + visit explore_projects_path expect(page).not_to have_selector('.js-dismiss-current-broadcast-notification') end @@ -62,33 +62,33 @@ RSpec.describe 'Broadcast Messages', feature_category: :onboarding do sign_in(user) - visit root_path + visit explore_projects_path expect(page).to have_content 'Hi {{name}}' end end - describe 'dismissable banner type' do - let!(:broadcast_message) { create(:broadcast_message, dismissable: true, message: 'SampleMessage') } + describe 'dismissible banner type' do + let_it_be(:broadcast_message) { create(:broadcast_message, dismissable: true, message: 'SampleMessage') } it_behaves_like 'a Broadcast Messages' - it_behaves_like 'a dismissable Broadcast Messages' + it_behaves_like 'a dismissible Broadcast Messages' end describe 'notification type' do - let!(:broadcast_message) { create(:broadcast_message, :notification, message: 'SampleMessage') } + let_it_be(:broadcast_message) { create(:broadcast_message, :notification, message: 'SampleMessage') } it_behaves_like 'a Broadcast Messages', :notification - it_behaves_like 'a dismissable Broadcast Messages' + it_behaves_like 'a dismissible Broadcast Messages' it 'replaces placeholders' do create(:broadcast_message, :notification, message: 'Hi {{name}}') sign_in(user) - visit root_path + visit explore_projects_path expect(page).to have_content "Hi #{user.name}" end diff --git a/spec/frontend/boards/components/board_content_spec.js b/spec/frontend/boards/components/board_content_spec.js index b109c2a3ab1..e14f661a8bd 100644 --- a/spec/frontend/boards/components/board_content_spec.js +++ b/spec/frontend/boards/components/board_content_spec.js @@ -1,9 +1,8 @@ import { GlAlert } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; -import Vue, { nextTick } from 'vue'; +import Vue from 'vue'; import Draggable from 'vuedraggable'; import Vuex from 'vuex'; - import eventHub from '~/boards/eventhub'; import { stubComponent } from 'helpers/stub_component'; import waitForPromises from 'helpers/wait_for_promises'; @@ -77,29 +76,6 @@ describe('BoardContent', () => { }); }; - beforeAll(() => { - global.ResizeObserver = class MockResizeObserver { - constructor(callback) { - this.callback = callback; - - this.entries = []; - } - - observe(entry) { - this.entries.push(entry); - } - - disconnect() { - this.entries = []; - this.callback = null; - } - - trigger() { - this.callback(this.entries); - } - }; - }); - describe('default', () => { beforeEach(() => { createComponent(); @@ -118,34 +94,6 @@ describe('BoardContent', () => { expect(wrapper.findComponent(GlAlert).exists()).toBe(false); }); - it('on small screens, sets board container height to full height', async () => { - window.innerHeight = 1000; - window.innerWidth = 767; - jest.spyOn(Element.prototype, 'getBoundingClientRect').mockReturnValue({ top: 100 }); - - wrapper.vm.resizeObserver.trigger(); - - await nextTick(); - - const style = wrapper.findComponent({ ref: 'list' }).attributes('style'); - - expect(style).toBe('height: 1000px;'); - }); - - it('on large screens, sets board container height fill area below filters', async () => { - window.innerHeight = 1000; - window.innerWidth = 768; - jest.spyOn(Element.prototype, 'getBoundingClientRect').mockReturnValue({ top: 100 }); - - wrapper.vm.resizeObserver.trigger(); - - await nextTick(); - - const style = wrapper.findComponent({ ref: 'list' }).attributes('style'); - - expect(style).toBe('height: 900px;'); - }); - it('sets delay and delayOnTouchOnly attributes on board list', () => { const listEl = wrapper.findComponent({ ref: 'list' }); diff --git a/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js b/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js index 6fc6c0b6085..c3d33c88422 100644 --- a/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js +++ b/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js @@ -60,8 +60,6 @@ import { mockRegistrationToken, newRunnerPath, emptyPageInfo, - emptyStateSvgPath, - emptyStateFilteredSvgPath, } from '../mock_data'; const mockRunners = allRunnersData.data.runners.nodes; @@ -122,8 +120,6 @@ describe('AdminRunnersApp', () => { localMutations, onlineContactTimeoutSecs, staleTimeoutSecs, - emptyStateSvgPath, - emptyStateFilteredSvgPath, ...provide, }, ...options, @@ -448,9 +444,7 @@ describe('AdminRunnersApp', () => { expect(findRunnerListEmptyState().props()).toEqual({ newRunnerPath, isSearchFiltered: false, - filteredSvgPath: emptyStateFilteredSvgPath, registrationToken: mockRegistrationToken, - svgPath: emptyStateSvgPath, }); }); diff --git a/spec/frontend/ci/runner/components/runner_jobs_empty_state_spec.js b/spec/frontend/ci/runner/components/runner_jobs_empty_state_spec.js index e64308f49d1..59c9383cb31 100644 --- a/spec/frontend/ci/runner/components/runner_jobs_empty_state_spec.js +++ b/spec/frontend/ci/runner/components/runner_jobs_empty_state_spec.js @@ -1,3 +1,5 @@ +import EMPTY_STATE_SVG_URL from '@gitlab/svgs/dist/illustrations/pipelines_empty.svg?url'; + import { shallowMount } from '@vue/test-utils'; import { GlEmptyState } from '@gitlab/ui'; import RunnerJobsEmptyState from '~/ci/runner/components/runner_jobs_empty_state.vue'; @@ -12,11 +14,7 @@ describe('RunnerJobsEmptyStateComponent', () => { let wrapper; const mountComponent = () => { - wrapper = shallowMount(RunnerJobsEmptyState, { - provide: { - emptyStateImage: 'emptyStateImage', - }, - }); + wrapper = shallowMount(RunnerJobsEmptyState); }; const findEmptyState = () => wrapper.findComponent(GlEmptyState); @@ -29,7 +27,7 @@ describe('RunnerJobsEmptyStateComponent', () => { it('should show an empty state if it is empty', () => { const emptyState = findEmptyState(); - expect(emptyState.props('svgPath')).toBe('emptyStateImage'); + expect(emptyState.props('svgPath')).toBe(EMPTY_STATE_SVG_URL); expect(emptyState.props('title')).toBe(DEFAULT_PROPS.emptyTitle); expect(emptyState.text()).toContain(DEFAULT_PROPS.emptyDescription); }); diff --git a/spec/frontend/ci/runner/components/runner_list_empty_state_spec.js b/spec/frontend/ci/runner/components/runner_list_empty_state_spec.js index f4e93e83ce8..0de2759ea8a 100644 --- a/spec/frontend/ci/runner/components/runner_list_empty_state_spec.js +++ b/spec/frontend/ci/runner/components/runner_list_empty_state_spec.js @@ -1,15 +1,12 @@ +import EMPTY_STATE_SVG_URL from '@gitlab/svgs/dist/illustrations/pipelines_empty.svg?url'; +import FILTERED_SVG_URL from '@gitlab/svgs/dist/illustrations/magnifying-glass.svg?url'; import { GlEmptyState, GlLink, GlSprintf } from '@gitlab/ui'; import { s__ } from '~/locale'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import RunnerInstructionsModal from '~/vue_shared/components/runner_instructions/runner_instructions_modal.vue'; -import { - mockRegistrationToken, - newRunnerPath, - emptyStateSvgPath, - emptyStateFilteredSvgPath, -} from 'jest/ci/runner/mock_data'; +import { mockRegistrationToken, newRunnerPath } from 'jest/ci/runner/mock_data'; import RunnerListEmptyState from '~/ci/runner/components/runner_list_empty_state.vue'; @@ -23,8 +20,6 @@ describe('RunnerListEmptyState', () => { const createComponent = ({ props, mountFn = shallowMountExtended, ...options } = {}) => { wrapper = mountFn(RunnerListEmptyState, { propsData: { - svgPath: emptyStateSvgPath, - filteredSvgPath: emptyStateFilteredSvgPath, registrationToken: mockRegistrationToken, newRunnerPath, ...props, @@ -50,7 +45,7 @@ describe('RunnerListEmptyState', () => { }); it('renders an illustration', () => { - expect(findEmptyState().props('svgPath')).toBe(emptyStateSvgPath); + expect(findEmptyState().props('svgPath')).toBe(EMPTY_STATE_SVG_URL); }); it('displays "no results" text with instructions', () => { @@ -125,7 +120,7 @@ describe('RunnerListEmptyState', () => { }); it('renders an illustration', () => { - expect(findEmptyState().props('svgPath')).toBe(emptyStateSvgPath); + expect(findEmptyState().props('svgPath')).toBe(EMPTY_STATE_SVG_URL); }); it('displays "no results" text', () => { @@ -148,7 +143,7 @@ describe('RunnerListEmptyState', () => { }); it('renders a "filtered search" illustration', () => { - expect(findEmptyState().props('svgPath')).toBe(emptyStateFilteredSvgPath); + expect(findEmptyState().props('svgPath')).toBe(FILTERED_SVG_URL); }); it('displays "no filtered results" text', () => { diff --git a/spec/frontend/ci/runner/group_runners/group_runners_app_spec.js b/spec/frontend/ci/runner/group_runners/group_runners_app_spec.js index e750327294c..41be72b1645 100644 --- a/spec/frontend/ci/runner/group_runners/group_runners_app_spec.js +++ b/spec/frontend/ci/runner/group_runners/group_runners_app_spec.js @@ -61,8 +61,6 @@ import { mockRegistrationToken, newRunnerPath, emptyPageInfo, - emptyStateSvgPath, - emptyStateFilteredSvgPath, } from '../mock_data'; Vue.use(VueApollo); @@ -123,8 +121,6 @@ describe('GroupRunnersApp', () => { localMutations, onlineContactTimeoutSecs, staleTimeoutSecs, - emptyStateSvgPath, - emptyStateFilteredSvgPath, ...provide, }, ...options, @@ -424,8 +420,6 @@ describe('GroupRunnersApp', () => { isSearchFiltered: false, newRunnerPath, registrationToken: mockRegistrationToken, - svgPath: 'emptyStateSvgPath.svg', - filteredSvgPath: 'emptyStateFilteredSvgPath.svg', }); }); }); diff --git a/spec/frontend/ci/runner/mock_data.js b/spec/frontend/ci/runner/mock_data.js index d47a95f5c07..223a156795c 100644 --- a/spec/frontend/ci/runner/mock_data.js +++ b/spec/frontend/ci/runner/mock_data.js @@ -322,8 +322,6 @@ export const mockRegistrationToken = 'MOCK_REGISTRATION_TOKEN'; export const mockAuthenticationToken = 'MOCK_AUTHENTICATION_TOKEN'; export const newRunnerPath = '/runners/new'; -export const emptyStateSvgPath = 'emptyStateSvgPath.svg'; -export const emptyStateFilteredSvgPath = 'emptyStateFilteredSvgPath.svg'; export { allRunnersData, diff --git a/spec/frontend/content_editor/components/bubble_menus/bubble_menu_spec.js b/spec/frontend/content_editor/components/bubble_menus/bubble_menu_spec.js index 271e63abf21..97716ce848c 100644 --- a/spec/frontend/content_editor/components/bubble_menus/bubble_menu_spec.js +++ b/spec/frontend/content_editor/components/bubble_menus/bubble_menu_spec.js @@ -64,10 +64,12 @@ describe('content_editor/components/bubble_menus/bubble_menu', () => { tippyOptions: expect.objectContaining({ onHidden: expect.any(Function), onShow: expect.any(Function), + appendTo: expect.any(Function), ...tippyOptions, }), }); + expect(BubbleMenuPlugin.mock.calls[0][0].tippyOptions.appendTo()).toBe(document.body); expect(tiptapEditor.registerPlugin).toHaveBeenCalledWith(pluginInitializationResult); }); diff --git a/spec/helpers/ci/runners_helper_spec.rb b/spec/helpers/ci/runners_helper_spec.rb index ab3f0b193ac..c170d7fae67 100644 --- a/spec/helpers/ci/runners_helper_spec.rb +++ b/spec/helpers/ci/runners_helper_spec.rb @@ -96,9 +96,7 @@ RSpec.describe Ci::RunnersHelper, feature_category: :runner_fleet do runner_install_help_page: 'https://docs.gitlab.com/runner/install/', registration_token: Gitlab::CurrentSettings.runners_registration_token, online_contact_timeout_secs: 7200, - stale_timeout_secs: 7889238, - empty_state_svg_path: start_with('/assets/illustrations/pipelines_empty'), - empty_state_filtered_svg_path: start_with('/assets/illustrations/magnifying-glass') + stale_timeout_secs: 7889238 ) end end @@ -168,9 +166,7 @@ RSpec.describe Ci::RunnersHelper, feature_category: :runner_fleet do group_full_path: group.full_path, runner_install_help_page: 'https://docs.gitlab.com/runner/install/', online_contact_timeout_secs: 7200, - stale_timeout_secs: 7889238, - empty_state_svg_path: start_with('/assets/illustrations/pipelines_empty'), - empty_state_filtered_svg_path: start_with('/assets/illustrations/magnifying-glass') + stale_timeout_secs: 7889238 ) end end diff --git a/spec/initializers/circuitbox_spec.rb b/spec/initializers/circuitbox_spec.rb new file mode 100644 index 00000000000..64e384e4d22 --- /dev/null +++ b/spec/initializers/circuitbox_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'circuitbox', feature_category: :shared do + it 'does not configure Circuitbox', unless: Gitlab.ee? do + expect(Circuitbox.default_circuit_store).to be_a(Circuitbox::MemoryStore) + expect(Circuitbox.default_notifier).to be_a(Circuitbox::Notifier::ActiveSupport) + end + + it 'configures Circuitbox', if: Gitlab.ee? do + expect(Circuitbox.default_circuit_store).to be_a(Gitlab::CircuitBreaker::Store) + expect(Circuitbox.default_notifier).to be_a(Gitlab::CircuitBreaker::Notifier) + end +end diff --git a/spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb b/spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb index 5fbaae58a73..18ac8a7b42b 100644 --- a/spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb +++ b/spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb @@ -5,20 +5,7 @@ require 'spec_helper' RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, feature_category: :vulnerability_management do let_it_be(:project) { create(:project) } - let(:current_dast_versions) { described_class::CURRENT_VERSIONS[:dast].join(', ') } let(:supported_dast_versions) { described_class::SUPPORTED_VERSIONS[:dast].join(', ') } - let(:deprecated_schema_version_message) {} - let(:missing_schema_version_message) do - "Report version not provided, dast report type supports versions: #{supported_dast_versions}" - end - - let(:scanner) do - { - 'id' => 'gemnasium', - 'name' => 'Gemnasium', - 'version' => '2.1.0' - } - end let(:analyzer_vendor) do { 'name' => 'A DAST analyzer' } @@ -28,7 +15,18 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu { 'name' => 'A DAST scanner' } end - let(:report_data) do + let(:scanner) do + { + 'id' => 'my-dast-scanner', + 'name' => 'My DAST scanner', + 'version' => '0.2.0', + 'vendor' => scanner_vendor + } + end + + let(:report_type) { :dast } + + let(:valid_data) do { 'scan' => { 'analyzer' => { @@ -39,21 +37,18 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu }, 'end_time' => '2020-01-28T03:26:02', 'scanned_resources' => [], - 'scanner' => { - 'id' => 'my-dast-scanner', - 'name' => 'My DAST scanner', - 'version' => '0.2.0', - 'vendor' => scanner_vendor - }, + 'scanner' => scanner, 'start_time' => '2020-01-28T03:26:01', 'status' => 'success', - 'type' => 'dast' + 'type' => report_type.to_s }, 'version' => report_version, 'vulnerabilities' => [] } end + let(:report_data) { valid_data } + let(:validator) { described_class.new(report_type, report_data, report_version, project: project, scanner: scanner) } shared_examples 'report is valid' do @@ -70,8 +65,8 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu security_report_version: report_version, project_id: project.id, security_report_failure: security_report_failure, - security_report_scanner_id: 'gemnasium', - security_report_scanner_version: '2.1.0' + security_report_scanner_id: scanner['id'], + security_report_scanner_version: scanner['version'] ) subject @@ -142,7 +137,6 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu subject { validator.valid? } context 'when given a supported MAJOR.MINOR schema version' do - let(:report_type) { :dast } let(:report_version) do latest_vendored_version = described_class::SUPPORTED_VERSIONS[report_type].last.split(".") (latest_vendored_version[0...2] << "34").join(".") @@ -153,7 +147,6 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'when given a supported schema version' do - let(:report_type) { :dast } let(:report_version) { described_class::SUPPORTED_VERSIONS[report_type].last } it_behaves_like 'report is valid' @@ -161,7 +154,6 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'when given a deprecated schema version' do - let(:report_type) { :dast } let(:deprecations_hash) do { dast: %w[10.0.0] @@ -175,13 +167,6 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'and the report passes schema validation' do - let(:report_data) do - { - 'version' => '10.0.0', - 'vulnerabilities' => [] - } - end - let(:security_report_failure) { 'using_deprecated_schema_version' } it { is_expected.to be_truthy } @@ -191,9 +176,8 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu context 'and the report does not pass schema validation' do let(:report_data) do - { - 'version' => 'V2.7.0' - } + valid_data.delete('vulnerabilities') + valid_data end it { is_expected.to be_falsey } @@ -201,17 +185,9 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'when given an unsupported schema version' do - let(:report_type) { :dast } let(:report_version) { "12.37.0" } context 'and the report is valid' do - let(:report_data) do - { - 'version' => report_version, - 'vulnerabilities' => [] - } - end - let(:security_report_failure) { 'using_unsupported_schema_version' } it { is_expected.to be_falsey } @@ -259,8 +235,8 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'when not given a schema version' do - let(:report_type) { :dast } let(:report_version) { nil } + let(:report_data) do { 'vulnerabilities' => [] @@ -285,21 +261,19 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu subject { validator.errors } context 'when given a supported schema version' do - let(:report_type) { :dast } let(:report_version) { described_class::SUPPORTED_VERSIONS[report_type].last } it_behaves_like 'report is valid with no error' context 'and the report is invalid' do let(:report_data) do - { - 'version' => report_version - } + valid_data.delete('vulnerabilities') + valid_data end let(:expected_errors) do [ - 'root is missing required keys: scan, vulnerabilities' + 'root is missing required keys: vulnerabilities' ] end @@ -308,7 +282,6 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'when given a deprecated schema version' do - let(:report_type) { :dast } let(:deprecations_hash) do { dast: %w[10.0.0] @@ -325,9 +298,9 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu context 'and the report does not pass schema validation' do let(:report_data) do - { - 'version' => 'V2.7.0' - } + valid_data['version'] = "V2.7.0" + valid_data.delete('vulnerabilities') + valid_data end let(:expected_errors) do @@ -342,7 +315,6 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'when given an unsupported schema version' do - let(:report_type) { :dast } let(:report_version) { "12.37.0" } let(:expected_unsupported_message) do "Version #{report_version} for report type #{report_type} is unsupported, supported versions for this report type are: "\ @@ -351,13 +323,6 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'and the report is valid' do - let(:report_data) do - { - 'version' => report_version, - 'vulnerabilities' => [] - } - end - let(:expected_errors) do [ expected_unsupported_message @@ -369,9 +334,8 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu context 'and the report is invalid' do let(:report_data) do - { - 'version' => report_version - } + valid_data.delete('vulnerabilities') + valid_data end let(:expected_errors) do @@ -386,7 +350,6 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'when not given a schema version' do - let(:report_type) { :dast } let(:report_version) { nil } let(:expected_missing_version_message) do "Report version not provided, #{report_type} report type supports versions: #{supported_dast_versions}. GitLab "\ @@ -395,9 +358,8 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end let(:report_data) do - { - 'vulnerabilities' => [] - } + valid_data.delete('version') + valid_data end let(:expected_errors) do @@ -413,13 +375,6 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu shared_examples 'report is valid with no warning' do context 'and the report is valid' do - let(:report_data) do - { - 'version' => report_version, - 'vulnerabilities' => [] - } - end - it { is_expected.to be_empty } end end @@ -432,25 +387,16 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu subject { validator.deprecation_warnings } context 'when given a supported schema version' do - let(:report_type) { :dast } let(:report_version) { described_class::SUPPORTED_VERSIONS[report_type].last } context 'and the report is valid' do - let(:report_data) do - { - 'version' => report_version, - 'vulnerabilities' => [] - } - end - it { is_expected.to be_empty } end context 'and the report is invalid' do let(:report_data) do - { - 'version' => report_version - } + valid_data.delete('vulnerabilities') + valid_data end it { is_expected.to be_empty } @@ -458,7 +404,6 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'when given a deprecated schema version' do - let(:report_type) { :dast } let(:deprecations_hash) do { dast: %w[V2.7.0] @@ -466,6 +411,7 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end let(:report_version) { described_class::DEPRECATED_VERSIONS[report_type].last } + let(:current_dast_versions) { described_class::CURRENT_VERSIONS[:dast].join(', ') } let(:expected_deprecation_message) do "version #{report_version} for report type #{report_type} is deprecated. "\ "However, GitLab will still attempt to parse and ingest this report. "\ @@ -483,21 +429,14 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'and the report passes schema validation' do - let(:report_data) do - { - 'version' => report_version, - 'vulnerabilities' => [] - } - end - it_behaves_like 'report with expected warnings' end context 'and the report does not pass schema validation' do let(:report_data) do - { - 'version' => 'V2.7.0' - } + valid_data['version'] = "V2.7.0" + valid_data.delete('vulnerabilities') + valid_data end it_behaves_like 'report with expected warnings' @@ -521,15 +460,8 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'when given an unsupported schema version' do - let(:report_type) { :dast } let(:report_version) { "21.37.0" } let(:expected_deprecation_warnings) { [] } - let(:report_data) do - { - 'version' => report_version, - 'vulnerabilities' => [] - } - end it_behaves_like 'report with expected warnings' end @@ -539,7 +471,6 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu subject { validator.warnings } context 'when given a supported MAJOR.MINOR schema version' do - let(:report_type) { :dast } let(:report_version) do latest_vendored_version = described_class::SUPPORTED_VERSIONS[report_type].last.split(".") (latest_vendored_version[0...2] << "34").join(".") @@ -559,13 +490,6 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'and the report is valid' do - let(:report_data) do - { - 'version' => report_version, - 'vulnerabilities' => [] - } - end - it { is_expected.to match_array([message]) } context 'without license', unless: Gitlab.ee? do @@ -607,7 +531,6 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'when given a supported schema version' do - let(:report_type) { :dast } let(:report_version) { described_class::SUPPORTED_VERSIONS[report_type].last } it_behaves_like 'report is valid with no warning' @@ -624,34 +547,26 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'when given a deprecated schema version' do - let(:report_type) { :dast } + let(:deprecated_version) { '14.1.3' } + let(:report_version) { deprecated_version } let(:deprecations_hash) do { - dast: %w[V2.7.0] + dast: %w[deprecated_version] } end - let(:report_version) { described_class::DEPRECATED_VERSIONS[report_type].last } - before do stub_const("#{described_class}::DEPRECATED_VERSIONS", deprecations_hash) end context 'and the report passes schema validation' do - let(:report_data) do - { - 'vulnerabilities' => [] - } - end - it { is_expected.to be_empty } end context 'and the report does not pass schema validation' do let(:report_data) do - { - 'version' => 'V2.7.0' - } + valid_data.delete('vulnerabilities') + valid_data end it { is_expected.to be_empty } @@ -659,7 +574,6 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'when given an unsupported schema version' do - let(:report_type) { :dast } let(:report_version) { "12.37.0" } it_behaves_like 'report is valid with no warning' @@ -676,13 +590,7 @@ RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator, featu end context 'when not given a schema version' do - let(:report_type) { :dast } let(:report_version) { nil } - let(:report_data) do - { - 'vulnerabilities' => [] - } - end it { is_expected.to be_empty } end diff --git a/spec/lib/sidebars/admin/panel_spec.rb b/spec/lib/sidebars/admin/panel_spec.rb index 12bd83a4b88..9c362f527f5 100644 --- a/spec/lib/sidebars/admin/panel_spec.rb +++ b/spec/lib/sidebars/admin/panel_spec.rb @@ -6,11 +6,25 @@ RSpec.describe Sidebars::Admin::Panel, feature_category: :navigation do let_it_be(:user) { build(:admin) } let(:context) { Sidebars::Context.new(current_user: user, container: nil) } + let(:panel) { described_class.new(context) } subject { described_class.new(context) } - it 'implements #super_sidebar_context_header' do - expect(subject.super_sidebar_context_header).to eq({ title: 'Admin Area' }) + describe '#aria_label' do + it 'returns the correct aria label' do + expect(panel.aria_label).to eq(_('Admin Area')) + end + end + + describe '#super_sidebar_context_header' do + it 'returns a hash with the correct title and icon' do + expected_header = { + title: panel.aria_label, + icon: 'admin' + } + + expect(panel.super_sidebar_context_header).to eq(expected_header) + end end it_behaves_like 'a panel with uniquely identifiable menu items' diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index 30cfb92ba06..8a0c8f519b0 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -1399,34 +1399,11 @@ RSpec.describe QuickActions::InterpretService, feature_category: :team_planning let(:issuable) { issue } end - # /draft is a toggle (ff disabled) - it_behaves_like 'draft command' do - let(:content) { '/draft' } - let(:issuable) { merge_request } - - before do - stub_feature_flags(draft_quick_action_non_toggle: false) - end - end - - # /draft is a toggle (ff disabled) - it_behaves_like 'ready command' do - let(:content) { '/draft' } - let(:issuable) { merge_request } - - before do - stub_feature_flags(draft_quick_action_non_toggle: false) - issuable.update!(title: issuable.draft_title) - end - end - - # /draft is one way (ff enabled) it_behaves_like 'draft command' do let(:content) { '/draft' } let(:issuable) { merge_request } end - # /draft is one way (ff enabled) it_behaves_like 'draft/ready command no action' do let(:content) { '/draft' } let(:issuable) { merge_request } @@ -2754,27 +2731,6 @@ RSpec.describe QuickActions::InterpretService, feature_category: :team_planning end end - describe 'draft command toggle (deprecated)' do - let(:content) { '/draft' } - - before do - stub_feature_flags(draft_quick_action_non_toggle: false) - end - - it 'includes the new status' do - _, explanations = service.explain(content, merge_request) - - expect(explanations).to match_array(['Marks this merge request as a draft.']) - end - - it 'sets the ready status on a draft' do - merge_request.update!(title: merge_request.draft_title) - _, explanations = service.explain(content, merge_request) - - expect(explanations).to match_array(["Marks this merge request as ready."]) - end - end - describe 'draft command set' do let(:content) { '/draft' } diff --git a/spec/views/layouts/devise.html.haml_spec.rb b/spec/views/layouts/devise.html.haml_spec.rb index b37bdeceb7e..a9215730370 100644 --- a/spec/views/layouts/devise.html.haml_spec.rb +++ b/spec/views/layouts/devise.html.haml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'layouts/devise' do +RSpec.describe 'layouts/devise', feature_category: :user_management do it_behaves_like 'a layout which reflects the application theme setting' describe 'logo' do @@ -22,4 +22,12 @@ RSpec.describe 'layouts/devise' do end end end + + context 'without broadcast messaging' do + it 'does not render the broadcast layout' do + render + + expect(rendered).not_to render_template('layouts/_broadcast') + end + end end diff --git a/spec/views/layouts/minimal.html.haml_spec.rb b/spec/views/layouts/minimal.html.haml_spec.rb new file mode 100644 index 00000000000..97cd699d32f --- /dev/null +++ b/spec/views/layouts/minimal.html.haml_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'layouts/minimal', feature_category: :onboarding do + context 'without broadcast messaging' do + it 'does not render the broadcast layout' do + render + + expect(rendered).not_to render_template('layouts/_broadcast') + end + end +end |