Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2024-01-22 15:08:07 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-22 15:08:07 +0300
commite5c31c104e19a08546b17b34b7f1563cce3f89e6 (patch)
tree4f05401dc288370583328a94c1bbf1f1de9ace64 /spec
parent56865fdf95db03cc0ccd01a88d9457ba0a050153 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/db/schema_spec.rb1
-rw-r--r--spec/features/registrations/oauth_registration_spec.rb2
-rw-r--r--spec/frontend/organizations/groups_and_projects/components/app_spec.js67
-rw-r--r--spec/frontend/organizations/shared/components/projects_view_spec.js144
-rw-r--r--spec/frontend/organizations/shared/utils_spec.js41
-rw-r--r--spec/lib/gitlab/database/sharding_key_spec.rb3
-rw-r--r--spec/lib/gitlab/internal_events_spec.rb2
-rw-r--r--spec/models/application_setting_spec.rb2
-rw-r--r--spec/support/helpers/login_helpers.rb2
9 files changed, 257 insertions, 7 deletions
diff --git a/spec/db/schema_spec.rb b/spec/db/schema_spec.rb
index 74267874eeb..c391f4a215e 100644
--- a/spec/db/schema_spec.rb
+++ b/spec/db/schema_spec.rb
@@ -100,6 +100,7 @@ RSpec.describe 'Database schema', feature_category: :database do
p_batched_git_ref_updates_deletions: %w[project_id partition_id],
p_catalog_resource_sync_events: %w[catalog_resource_id project_id partition_id],
p_ci_finished_build_ch_sync_events: %w[build_id],
+ p_ci_pipeline_variables: %w[partition_id],
product_analytics_events_experimental: %w[event_id txn_id user_id],
project_build_artifacts_size_refreshes: %w[last_job_artifact_id],
project_data_transfers: %w[project_id namespace_id],
diff --git a/spec/features/registrations/oauth_registration_spec.rb b/spec/features/registrations/oauth_registration_spec.rb
index eb21d285bd0..369df614083 100644
--- a/spec/features/registrations/oauth_registration_spec.rb
+++ b/spec/features/registrations/oauth_registration_spec.rb
@@ -107,7 +107,7 @@ RSpec.describe 'OAuth Registration', :js, :allow_forgery_protection, feature_cat
it 'redirects to the group page with all the projects/groups invitations accepted' do
visit invite_path(group_invite.raw_invite_token, extra_params)
- click_link_or_button "oauth-login-#{provider}"
+ click_link_or_button Gitlab::Auth::OAuth::Provider.label_for(provider)
expect(page).to have_content('You have been granted Owner access to group Owned.')
expect(page).to have_current_path(group_path(group), ignore_query: true)
diff --git a/spec/frontend/organizations/groups_and_projects/components/app_spec.js b/spec/frontend/organizations/groups_and_projects/components/app_spec.js
index 7215750c3c7..a9638369a01 100644
--- a/spec/frontend/organizations/groups_and_projects/components/app_spec.js
+++ b/spec/frontend/organizations/groups_and_projects/components/app_spec.js
@@ -33,6 +33,7 @@ describe('GroupsAndProjectsApp', () => {
const findFilteredSearchBar = () => wrapper.findComponent(FilteredSearchBar);
const findListbox = () => wrapper.findComponent(GlCollapsibleListbox);
const findSort = () => wrapper.findComponent(GlSorting);
+ const findProjectsView = () => wrapper.findComponent(ProjectsView);
describe.each`
display | expectedComponent | expectedDisplayListboxSelectedProp
@@ -160,4 +161,70 @@ describe('GroupsAndProjectsApp', () => {
]);
});
});
+
+ describe('when page is changed', () => {
+ const mockEndCursor = 'mockEndCursor';
+ const mockStartCursor = 'mockStartCursor';
+
+ describe('when going to next page', () => {
+ beforeEach(() => {
+ createComponent({ routeQuery: { display: RESOURCE_TYPE_PROJECTS } });
+ findProjectsView().vm.$emit('page-change', {
+ endCursor: mockEndCursor,
+ startCursor: null,
+ hasPreviousPage: true,
+ });
+ });
+
+ it('sets `end_cursor` query string', () => {
+ expect(routerMock.push).toHaveBeenCalledWith({
+ query: { display: RESOURCE_TYPE_PROJECTS, end_cursor: mockEndCursor },
+ });
+ });
+ });
+
+ describe('when going to previous page', () => {
+ it('sets `start_cursor` query string', () => {
+ createComponent({
+ routeQuery: {
+ display: RESOURCE_TYPE_PROJECTS,
+ start_cursor: mockStartCursor,
+ end_cursor: mockEndCursor,
+ },
+ });
+
+ findProjectsView().vm.$emit('page-change', {
+ endCursor: null,
+ startCursor: mockStartCursor,
+ hasPreviousPage: true,
+ });
+
+ expect(routerMock.push).toHaveBeenCalledWith({
+ query: { display: RESOURCE_TYPE_PROJECTS, start_cursor: mockStartCursor },
+ });
+ });
+
+ describe('when going to the first page', () => {
+ it('removes `start_cursor` and `end_cursor` query string', () => {
+ createComponent({
+ routeQuery: {
+ display: RESOURCE_TYPE_PROJECTS,
+ start_cursor: mockStartCursor,
+ end_cursor: mockEndCursor,
+ },
+ });
+
+ findProjectsView().vm.$emit('page-change', {
+ endCursor: null,
+ startCursor: mockStartCursor,
+ hasPreviousPage: false,
+ });
+
+ expect(routerMock.push).toHaveBeenCalledWith({
+ query: { display: RESOURCE_TYPE_PROJECTS },
+ });
+ });
+ });
+ });
+ });
});
diff --git a/spec/frontend/organizations/shared/components/projects_view_spec.js b/spec/frontend/organizations/shared/components/projects_view_spec.js
index c406ba2cd47..12fe8ed353d 100644
--- a/spec/frontend/organizations/shared/components/projects_view_spec.js
+++ b/spec/frontend/organizations/shared/components/projects_view_spec.js
@@ -1,15 +1,21 @@
import VueApollo from 'vue-apollo';
import Vue from 'vue';
-import { GlLoadingIcon, GlEmptyState } from '@gitlab/ui';
+import { GlLoadingIcon, GlEmptyState, GlKeysetPagination } from '@gitlab/ui';
import ProjectsView from '~/organizations/shared/components/projects_view.vue';
import projectsQuery from '~/organizations/shared/graphql/queries/projects.query.graphql';
import { formatProjects } from '~/organizations/shared/utils';
import ProjectsList from '~/vue_shared/components/projects_list/projects_list.vue';
import { createAlert } from '~/alert';
+import { DEFAULT_PER_PAGE } from '~/api';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises';
-import { organizationProjects as nodes, pageInfo, pageInfoEmpty } from '~/organizations/mock_data';
+import {
+ organizationProjects as nodes,
+ pageInfo,
+ pageInfoEmpty,
+ pageInfoOnePage,
+} from '~/organizations/mock_data';
jest.mock('~/alert');
@@ -56,6 +62,7 @@ describe('ProjectsView', () => {
});
};
+ const findPagination = () => wrapper.findComponent(GlKeysetPagination);
const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
const findEmptyState = () => wrapper.findComponent(GlEmptyState);
const findProjectsList = () => wrapper.findComponent(ProjectsList);
@@ -134,6 +141,139 @@ describe('ProjectsView', () => {
});
});
});
+
+ describe('when there is one page of projects', () => {
+ beforeEach(async () => {
+ createComponent({
+ handler: jest.fn().mockResolvedValue({
+ data: {
+ organization: {
+ id: defaultProvide.organizationGid,
+ projects: {
+ nodes,
+ pageInfo: pageInfoOnePage,
+ },
+ },
+ },
+ }),
+ });
+ await waitForPromises();
+ });
+
+ it('does not render pagination', () => {
+ expect(findPagination().exists()).toBe(false);
+ });
+ });
+
+ describe('when there is a next page of projects', () => {
+ const mockEndCursor = 'mockEndCursor';
+ const handler = jest.fn().mockResolvedValue({
+ data: {
+ organization: {
+ id: defaultProvide.organizationGid,
+ projects: {
+ nodes,
+ pageInfo: {
+ ...pageInfo,
+ hasNextPage: true,
+ hasPreviousPage: false,
+ },
+ },
+ },
+ },
+ });
+
+ beforeEach(async () => {
+ createComponent({ handler });
+ await waitForPromises();
+ });
+
+ it('renders pagination', () => {
+ expect(findPagination().exists()).toBe(true);
+ });
+
+ describe('when next button is clicked', () => {
+ beforeEach(async () => {
+ findPagination().vm.$emit('next', mockEndCursor);
+ await waitForPromises();
+ });
+
+ it('calls query with correct variables', () => {
+ expect(handler).toHaveBeenCalledWith({
+ after: mockEndCursor,
+ before: null,
+ first: DEFAULT_PER_PAGE,
+ id: defaultProvide.organizationGid,
+ last: null,
+ });
+ });
+
+ it('emits `page-change` event', () => {
+ expect(wrapper.emitted('page-change')[1]).toEqual([
+ {
+ endCursor: mockEndCursor,
+ startCursor: null,
+ hasPreviousPage: false,
+ },
+ ]);
+ });
+ });
+ });
+
+ describe('when there is a previous page of projects', () => {
+ const mockStartCursor = 'mockStartCursor';
+ const handler = jest.fn().mockResolvedValue({
+ data: {
+ organization: {
+ id: defaultProvide.organizationGid,
+ projects: {
+ nodes,
+ pageInfo: {
+ ...pageInfo,
+ hasNextPage: false,
+ hasPreviousPage: true,
+ },
+ },
+ },
+ },
+ });
+
+ beforeEach(async () => {
+ createComponent({ handler });
+ await waitForPromises();
+ });
+
+ it('renders pagination', () => {
+ expect(findPagination().exists()).toBe(true);
+ });
+
+ describe('when next button is clicked', () => {
+ beforeEach(async () => {
+ findPagination().vm.$emit('prev', mockStartCursor);
+ await waitForPromises();
+ });
+
+ it('calls query with correct variables', () => {
+ expect(handler).toHaveBeenCalledWith({
+ after: null,
+ before: mockStartCursor,
+ first: null,
+ id: defaultProvide.organizationGid,
+ last: DEFAULT_PER_PAGE,
+ });
+ });
+
+ it('emits `page-change` event', () => {
+ expect(wrapper.emitted('page-change')[1]).toEqual([
+ {
+ endCursor: null,
+ startCursor: mockStartCursor,
+ hasPreviousPage: true,
+ },
+ ]);
+ });
+ });
+ });
});
describe('when API call is not successful', () => {
diff --git a/spec/frontend/organizations/shared/utils_spec.js b/spec/frontend/organizations/shared/utils_spec.js
index d8d5279b670..29d7090c576 100644
--- a/spec/frontend/organizations/shared/utils_spec.js
+++ b/spec/frontend/organizations/shared/utils_spec.js
@@ -1,4 +1,4 @@
-import { formatProjects, formatGroups } from '~/organizations/shared/utils';
+import { formatProjects, formatGroups, onPageChange } from '~/organizations/shared/utils';
import { ACTION_EDIT, ACTION_DELETE } from '~/vue_shared/components/list_actions/constants';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { organizationProjects, organizationGroups } from '~/organizations/mock_data';
@@ -35,3 +35,42 @@ describe('formatGroups', () => {
expect(formattedGroups.length).toBe(organizationGroups.nodes.length);
});
});
+
+describe('onPageChange', () => {
+ const mockRouteQuery = { start_cursor: 'mockStartCursor', end_cursor: 'mockEndCursor' };
+
+ describe('when `startCursor` is defined and `hasPreviousPage` is `true`', () => {
+ it('sets start cursor query param', () => {
+ expect(
+ onPageChange({
+ startCursor: 'newMockStartCursor',
+ hasPreviousPage: true,
+ routeQuery: mockRouteQuery,
+ }),
+ ).toEqual({ start_cursor: 'newMockStartCursor' });
+ });
+ });
+
+ describe('when `startCursor` is defined and `hasPreviousPage` is `false`', () => {
+ it('does not set any query params', () => {
+ expect(
+ onPageChange({
+ startCursor: 'newMockStartCursor',
+ hasPreviousPage: false,
+ routeQuery: mockRouteQuery,
+ }),
+ ).toEqual({});
+ });
+ });
+
+ describe('when `endCursor` is defined', () => {
+ it('sets end cursor query param', () => {
+ expect(
+ onPageChange({
+ endCursor: 'newMockEndCursor',
+ routeQuery: mockRouteQuery,
+ }),
+ ).toEqual({ end_cursor: 'newMockEndCursor' });
+ });
+ });
+});
diff --git a/spec/lib/gitlab/database/sharding_key_spec.rb b/spec/lib/gitlab/database/sharding_key_spec.rb
index dfd78bfacba..fb9dd3468a3 100644
--- a/spec/lib/gitlab/database/sharding_key_spec.rb
+++ b/spec/lib/gitlab/database/sharding_key_spec.rb
@@ -8,7 +8,8 @@ RSpec.describe 'new tables missing sharding_key', feature_category: :cell do
let(:allowed_to_be_missing_sharding_key) do
[
'abuse_report_assignees', # https://gitlab.com/gitlab-org/gitlab/-/issues/432365
- 'sbom_occurrences_vulnerabilities' # https://gitlab.com/gitlab-org/gitlab/-/issues/432900
+ 'sbom_occurrences_vulnerabilities', # https://gitlab.com/gitlab-org/gitlab/-/issues/432900
+ 'p_ci_pipeline_variables' # https://gitlab.com/gitlab-org/gitlab/-/issues/436360
]
end
diff --git a/spec/lib/gitlab/internal_events_spec.rb b/spec/lib/gitlab/internal_events_spec.rb
index 4e475cf9a1d..a1bd265d349 100644
--- a/spec/lib/gitlab/internal_events_spec.rb
+++ b/spec/lib/gitlab/internal_events_spec.rb
@@ -309,7 +309,7 @@ RSpec.describe Gitlab::InternalEvents, :snowplow, feature_category: :product_ana
allow(GitlabSDK::Client)
.to receive(:new)
- .with(app_id: app_id, host: url)
+ .with(app_id: app_id, host: url, buffer_size: described_class::SNOWPLOW_EMITTER_BUFFER_SIZE)
.and_return(sdk_client)
end
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index b4003469ebb..18060d29ad5 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -124,6 +124,8 @@ RSpec.describe ApplicationSetting, feature_category: :shared, type: :model do
it { is_expected.to validate_inclusion_of(:allow_project_creation_for_guest_and_below).in_array([true, false]) }
+ it { is_expected.to validate_inclusion_of(:enable_member_promotion_management).in_array([true, false]) }
+
it { is_expected.to validate_inclusion_of(:deny_all_requests_except_allowed).in_array([true, false]) }
it 'ensures max_pages_size is an integer greater than 0 (or equal to 0 to indicate unlimited/maximum)' do
diff --git a/spec/support/helpers/login_helpers.rb b/spec/support/helpers/login_helpers.rb
index 83849df73dc..cc45cb1292d 100644
--- a/spec/support/helpers/login_helpers.rb
+++ b/spec/support/helpers/login_helpers.rb
@@ -132,7 +132,7 @@ module LoginHelpers
visit new_user_registration_path
expect(page).to have_content('Create an account using').or(have_content('Register with'))
- click_link_or_button "oauth-login-#{provider}"
+ click_link_or_button Gitlab::Auth::OAuth::Provider.label_for(provider)
end
def fake_successful_webauthn_authentication