diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-18 18:10:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-18 18:10:19 +0300 |
commit | 884d6a4ece823bcb85dc0fe7f0c28ff2c3126867 (patch) | |
tree | eeaeec800aa21cd6b2080ba96d3602a323227647 /spec | |
parent | 3aab29eacb2d35d90d93ed005b6fc825955b4d23 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
8 files changed, 117 insertions, 42 deletions
diff --git a/spec/controllers/admin/jobs_controller_spec.rb b/spec/controllers/admin/jobs_controller_spec.rb index 2d1482f40d4..c99bb6ff695 100644 --- a/spec/controllers/admin/jobs_controller_spec.rb +++ b/spec/controllers/admin/jobs_controller_spec.rb @@ -14,8 +14,6 @@ RSpec.describe Admin::JobsController do get :index expect(response).to have_gitlab_http_status(:ok) - expect(assigns(:builds)).to be_a(Kaminari::PaginatableWithoutCount) - expect(assigns(:builds).count).to be(1) end end diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb index df5280d52df..9851153bd39 100644 --- a/spec/controllers/projects/jobs_controller_spec.rb +++ b/spec/controllers/projects/jobs_controller_spec.rb @@ -47,7 +47,6 @@ RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state, featu it 'has only pending builds' do expect(response).to have_gitlab_http_status(:ok) - expect(assigns(:builds).first.status).to eq('pending') end end @@ -60,7 +59,6 @@ RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state, featu it 'has only running jobs' do expect(response).to have_gitlab_http_status(:ok) - expect(assigns(:builds).first.status).to eq('running') end end @@ -73,7 +71,6 @@ RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state, featu it 'has only finished jobs' do expect(response).to have_gitlab_http_status(:ok) - expect(assigns(:builds).first.status).to eq('success') end end @@ -89,7 +86,6 @@ RSpec.describe Projects::JobsController, :clean_gitlab_redis_shared_state, featu it 'redirects to the page' do expect(response).to have_gitlab_http_status(:ok) - expect(assigns(:builds).current_page).to eq(last_page) end end end diff --git a/spec/frontend/lib/utils/breadcrumbs_spec.js b/spec/frontend/lib/utils/breadcrumbs_spec.js new file mode 100644 index 00000000000..3c29e3723d3 --- /dev/null +++ b/spec/frontend/lib/utils/breadcrumbs_spec.js @@ -0,0 +1,84 @@ +import { createWrapper } from '@vue/test-utils'; +import Vue from 'vue'; +import { injectVueAppBreadcrumbs } from '~/lib/utils/breadcrumbs'; +import { resetHTMLFixture, setHTMLFixture } from 'helpers/fixtures'; +import createMockApollo from 'helpers/mock_apollo_helper'; + +describe('Breadcrumbs utils', () => { + const breadcrumbsHTML = ` + <nav> + <ul class="js-breadcrumbs-list"> + <li> + <a href="/group-name" data-testid="existing-crumb">Group name</a> + </li> + <li> + <a href="/group-name/project-name/-/subpage" data-testid="last-crumb">Subpage</a> + </li> + </ul> + </nav> + `; + + const emptyBreadcrumbsHTML = ` + <nav> + <ul class="js-breadcrumbs-list" data-testid="breadcumbs-list"> + </ul> + </nav> + `; + + const mockRouter = jest.fn(); + let MockComponent; + let mockApolloProvider; + + beforeEach(() => { + MockComponent = Vue.component('MockComponent', { + render: (createElement) => + createElement('span', { + attrs: { + 'data-testid': 'mock-component', + }, + }), + }); + mockApolloProvider = createMockApollo(); + }); + + afterEach(() => { + resetHTMLFixture(); + MockComponent = null; + }); + + describe('injectVueAppBreadcrumbs', () => { + describe('without any breadcrumbs', () => { + beforeEach(() => { + setHTMLFixture(emptyBreadcrumbsHTML); + }); + + it('returns early and stops trying to inject', () => { + expect(injectVueAppBreadcrumbs(mockRouter, MockComponent)).toBe(false); + }); + }); + + describe('with breadcrumbs', () => { + beforeEach(() => { + setHTMLFixture(breadcrumbsHTML); + }); + + describe.each` + testLabel | apolloProvider + ${'set'} | ${mockApolloProvider} + ${'not set'} | ${null} + `('given the apollo provider is $testLabel', ({ apolloProvider }) => { + beforeEach(() => { + createWrapper(injectVueAppBreadcrumbs(mockRouter, MockComponent, apolloProvider)); + }); + + it('returns a new breadcrumbs component replacing the inject HTML', () => { + // Using `querySelectorAll` because we're not testing a full Vue app. + // We are testing a partial Vue app added into the pages HTML. + expect(document.querySelectorAll('[data-testid="existing-crumb"]')).toHaveLength(1); + expect(document.querySelectorAll('[data-testid="last-crumb"]')).toHaveLength(0); + expect(document.querySelectorAll('[data-testid="mock-component"]')).toHaveLength(1); + }); + }); + }); + }); +}); diff --git a/spec/frontend/search/sidebar/components/app_spec.js b/spec/frontend/search/sidebar/components/app_spec.js index 72c9537bd61..8e23f9c1680 100644 --- a/spec/frontend/search/sidebar/components/app_spec.js +++ b/spec/frontend/search/sidebar/components/app_spec.js @@ -15,6 +15,7 @@ import MergeRequestsFilters from '~/search/sidebar/components/merge_requests_fil import BlobsFilters from '~/search/sidebar/components/blobs_filters.vue'; import ProjectsFilters from '~/search/sidebar/components/projects_filters.vue'; import NotesFilters from '~/search/sidebar/components/notes_filters.vue'; +import CommitsFilters from '~/search/sidebar/components/commits_filters.vue'; import ScopeLegacyNavigation from '~/search/sidebar/components/scope_legacy_navigation.vue'; import SmallScreenDrawerNavigation from '~/search/sidebar/components/small_screen_drawer_navigation.vue'; import ScopeSidebarNavigation from '~/search/sidebar/components/scope_sidebar_navigation.vue'; @@ -45,6 +46,7 @@ describe('GlobalSearchSidebar', () => { provide: { glFeatures: { searchNotesHideArchivedProjects: true, + searchCommitsHideArchivedProjects: true, }, }, }); @@ -56,6 +58,7 @@ describe('GlobalSearchSidebar', () => { const findBlobsFilters = () => wrapper.findComponent(BlobsFilters); const findProjectsFilters = () => wrapper.findComponent(ProjectsFilters); const findNotesFilters = () => wrapper.findComponent(NotesFilters); + const findCommitsFilters = () => wrapper.findComponent(CommitsFilters); const findScopeLegacyNavigation = () => wrapper.findComponent(ScopeLegacyNavigation); const findSmallScreenDrawerNavigation = () => wrapper.findComponent(SmallScreenDrawerNavigation); const findScopeSidebarNavigation = () => wrapper.findComponent(ScopeSidebarNavigation); @@ -82,6 +85,8 @@ describe('GlobalSearchSidebar', () => { ${'blobs'} | ${findBlobsFilters} | ${SEARCH_TYPE_ZOEKT} | ${false} ${'notes'} | ${findNotesFilters} | ${SEARCH_TYPE_BASIC} | ${false} ${'notes'} | ${findNotesFilters} | ${SEARCH_TYPE_ADVANCED} | ${true} + ${'commits'} | ${findCommitsFilters} | ${SEARCH_TYPE_BASIC} | ${false} + ${'commits'} | ${findCommitsFilters} | ${SEARCH_TYPE_ADVANCED} | ${true} `('with sidebar $scope scope:', ({ scope, filter, searchType, isShown }) => { beforeEach(() => { getterSpies.currentScope = jest.fn(() => scope); diff --git a/spec/frontend/search/sidebar/components/commits_filters_spec.js b/spec/frontend/search/sidebar/components/commits_filters_spec.js new file mode 100644 index 00000000000..cb47c6833ef --- /dev/null +++ b/spec/frontend/search/sidebar/components/commits_filters_spec.js @@ -0,0 +1,28 @@ +import { shallowMount } from '@vue/test-utils'; +import CommitsFilters from '~/search/sidebar/components/projects_filters.vue'; +import ArchivedFilter from '~/search/sidebar/components/archived_filter/index.vue'; +import FiltersTemplate from '~/search/sidebar/components/filters_template.vue'; + +describe('GlobalSearch CommitsFilters', () => { + let wrapper; + + const findArchivedFilter = () => wrapper.findComponent(ArchivedFilter); + const findFiltersTemplate = () => wrapper.findComponent(FiltersTemplate); + + const createComponent = () => { + wrapper = shallowMount(CommitsFilters); + }; + + describe('Renders correctly', () => { + beforeEach(() => { + createComponent(); + }); + it('renders ArchivedFilter', () => { + expect(findArchivedFilter().exists()).toBe(true); + }); + + it('renders FiltersTemplate', () => { + expect(findFiltersTemplate().exists()).toBe(true); + }); + }); +}); diff --git a/spec/models/project_authorization_spec.rb b/spec/models/project_authorization_spec.rb index 84c3c8abdb0..9fed05342aa 100644 --- a/spec/models/project_authorization_spec.rb +++ b/spec/models/project_authorization_spec.rb @@ -18,16 +18,6 @@ RSpec.describe ProjectAuthorization, feature_category: :groups_and_projects do it 'sets is_unique' do expect { project_auth.save! }.to change { project_auth.is_unique }.to(true) end - - context 'with feature disabled' do - before do - stub_feature_flags(write_project_authorizations_is_unique: false) - end - - it 'does not set is_unique' do - expect { project_auth.save! }.not_to change { project_auth.is_unique }.from(nil) - end - end end describe 'unique user, project authorizations' do diff --git a/spec/models/project_authorizations/changes_spec.rb b/spec/models/project_authorizations/changes_spec.rb index 84d7e0788cf..5f4dd963fb3 100644 --- a/spec/models/project_authorizations/changes_spec.rb +++ b/spec/models/project_authorizations/changes_spec.rb @@ -110,18 +110,6 @@ RSpec.describe ProjectAuthorizations::Changes, feature_category: :groups_and_pro expect(user.project_authorizations.pluck(:is_unique)).to all(be(true)) end - context 'with feature disabled' do - before do - stub_feature_flags(write_project_authorizations_is_unique: false) - end - - it 'does not write is_unique' do - apply_project_authorization_changes - - expect(user.project_authorizations.pluck(:is_unique)).to all(be(nil)) - end - end - it_behaves_like 'logs the detail', batch_size: 2 it_behaves_like 'publishes AuthorizationsChangedEvent' diff --git a/spec/services/ci/pipeline_creation/cancel_redundant_pipelines_service_spec.rb b/spec/services/ci/pipeline_creation/cancel_redundant_pipelines_service_spec.rb index 82a8e425cd0..fffac0fd64b 100644 --- a/spec/services/ci/pipeline_creation/cancel_redundant_pipelines_service_spec.rb +++ b/spec/services/ci/pipeline_creation/cancel_redundant_pipelines_service_spec.rb @@ -35,20 +35,6 @@ RSpec.describe Ci::PipelineCreation::CancelRedundantPipelinesService, feature_ca expect(build_statuses(pipeline)).to contain_exactly('pending') expect(build_statuses(old_pipeline)).to contain_exactly('pending') end - - context 'with lower_interval_for_canceling_redundant_pipelines disabled' do - before do - stub_feature_flags(lower_interval_for_canceling_redundant_pipelines: false) - end - - it 'cancels pipelines created more than 3 days ago' do - execute - - expect(build_statuses(prev_pipeline)).to contain_exactly('canceled', 'success', 'canceled') - expect(build_statuses(pipeline)).to contain_exactly('pending') - expect(build_statuses(old_pipeline)).to contain_exactly('canceled') - end - end end end |