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>2023-06-08 06:08:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-08 06:08:19 +0300
commitbf293d47937b3332462689c3fecc868706553f3a (patch)
tree47f0f1063aa27e4529c23068537ce45d6adb4cf0 /spec
parent356e3c444dc8fab920d3547461b6ae721c5eb50f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/personal_access_tokens.rb2
-rw-r--r--spec/frontend/diffs/components/app_spec.js109
-rw-r--r--spec/frontend/lib/utils/number_utility_spec.js4
-rw-r--r--spec/frontend/packages_and_registries/harbor_registry/components/details/artifacts_list_row_spec.js2
-rw-r--r--spec/frontend/packages_and_registries/infrastructure_registry/components/details/components/details_title_spec.js2
-rw-r--r--spec/frontend/super_sidebar/components/help_center_spec.js17
-rw-r--r--spec/frontend_integration/diffs/diffs_interopability_spec.js29
-rw-r--r--spec/lib/api/entities/personal_access_token_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/templates/Pages/zola_gitlab_ci_yaml_spec.rb25
-rw-r--r--spec/lib/gitlab/gitaly_client/commit_service_spec.rb13
-rw-r--r--spec/models/concerns/token_authenticatable_spec.rb2
-rw-r--r--spec/models/personal_access_token_spec.rb30
-rw-r--r--spec/requests/api/internal/base_spec.rb3
-rw-r--r--spec/serializers/access_token_entity_base_spec.rb2
-rw-r--r--spec/services/personal_access_tokens/create_service_spec.rb7
15 files changed, 163 insertions, 86 deletions
diff --git a/spec/factories/personal_access_tokens.rb b/spec/factories/personal_access_tokens.rb
index a140011941f..c7361b11633 100644
--- a/spec/factories/personal_access_tokens.rb
+++ b/spec/factories/personal_access_tokens.rb
@@ -5,7 +5,7 @@ FactoryBot.define do
user
sequence(:name) { |n| "PAT #{n}" }
revoked { false }
- expires_at { 5.days.from_now }
+ expires_at { 30.days.from_now }
scopes { ['api'] }
impersonation { false }
diff --git a/spec/frontend/diffs/components/app_spec.js b/spec/frontend/diffs/components/app_spec.js
index 29ade6514be..b69452069c0 100644
--- a/spec/frontend/diffs/components/app_spec.js
+++ b/spec/frontend/diffs/components/app_spec.js
@@ -43,7 +43,7 @@ describe('diffs/components/app', () => {
let wrapper;
let mock;
- function createComponent(props = {}, extendStore = () => {}, provisions = {}) {
+ function createComponent(props = {}, extendStore = () => {}, provisions = {}, baseConfig = {}) {
const provide = {
...provisions,
glFeatures: {
@@ -57,20 +57,24 @@ describe('diffs/components/app', () => {
extendStore(store);
+ store.dispatch('diffs/setBaseConfig', {
+ endpoint: TEST_ENDPOINT,
+ endpointMetadata: `${TEST_HOST}/diff/endpointMetadata`,
+ endpointBatch: `${TEST_HOST}/diff/endpointBatch`,
+ endpointDiffForPath: TEST_ENDPOINT,
+ projectPath: 'namespace/project',
+ dismissEndpoint: '',
+ showSuggestPopover: true,
+ mrReviews: {},
+ ...baseConfig,
+ });
+
wrapper = shallowMount(App, {
propsData: {
- endpoint: TEST_ENDPOINT,
- endpointMetadata: `${TEST_HOST}/diff/endpointMetadata`,
- endpointBatch: `${TEST_HOST}/diff/endpointBatch`,
- endpointDiffForPath: TEST_ENDPOINT,
endpointCoverage: `${TEST_HOST}/diff/endpointCoverage`,
endpointCodequality: '',
- projectPath: 'namespace/project',
currentUser: {},
changesEmptyStateIllustration: '',
- dismissEndpoint: '',
- showSuggestPopover: true,
- fileByFileUserPreference: false,
...props,
},
provide,
@@ -653,13 +657,18 @@ describe('diffs/components/app', () => {
describe('file-by-file', () => {
it('renders a single diff', async () => {
- createComponent({ fileByFileUserPreference: true }, ({ state }) => {
- state.diffs.treeEntries = {
- 123: { type: 'blob', fileHash: '123' },
- 312: { type: 'blob', fileHash: '312' },
- };
- state.diffs.diffFiles.push({ file_hash: '312' });
- });
+ createComponent(
+ undefined,
+ ({ state }) => {
+ state.diffs.treeEntries = {
+ 123: { type: 'blob', fileHash: '123' },
+ 312: { type: 'blob', fileHash: '312' },
+ };
+ state.diffs.diffFiles.push({ file_hash: '312' });
+ },
+ undefined,
+ { viewDiffsFileByFile: true },
+ );
await nextTick();
@@ -671,12 +680,17 @@ describe('diffs/components/app', () => {
const paginator = () => fileByFileNav().findComponent(GlPagination);
it('sets previous button as disabled', async () => {
- createComponent({ fileByFileUserPreference: true }, ({ state }) => {
- state.diffs.treeEntries = {
- 123: { type: 'blob', fileHash: '123' },
- 312: { type: 'blob', fileHash: '312' },
- };
- });
+ createComponent(
+ undefined,
+ ({ state }) => {
+ state.diffs.treeEntries = {
+ 123: { type: 'blob', fileHash: '123' },
+ 312: { type: 'blob', fileHash: '312' },
+ };
+ },
+ undefined,
+ { viewDiffsFileByFile: true },
+ );
await nextTick();
@@ -685,13 +699,18 @@ describe('diffs/components/app', () => {
});
it('sets next button as disabled', async () => {
- createComponent({ fileByFileUserPreference: true }, ({ state }) => {
- state.diffs.treeEntries = {
- 123: { type: 'blob', fileHash: '123' },
- 312: { type: 'blob', fileHash: '312' },
- };
- state.diffs.currentDiffFileId = '312';
- });
+ createComponent(
+ undefined,
+ ({ state }) => {
+ state.diffs.treeEntries = {
+ 123: { type: 'blob', fileHash: '123' },
+ 312: { type: 'blob', fileHash: '312' },
+ };
+ state.diffs.currentDiffFileId = '312';
+ },
+ undefined,
+ { viewDiffsFileByFile: true },
+ );
await nextTick();
@@ -700,10 +719,15 @@ describe('diffs/components/app', () => {
});
it("doesn't display when there's fewer than 2 files", async () => {
- createComponent({ fileByFileUserPreference: true }, ({ state }) => {
- state.diffs.treeEntries = { 123: { type: 'blob', fileHash: '123' } };
- state.diffs.currentDiffFileId = '123';
- });
+ createComponent(
+ undefined,
+ ({ state }) => {
+ state.diffs.treeEntries = { 123: { type: 'blob', fileHash: '123' } };
+ state.diffs.currentDiffFileId = '123';
+ },
+ undefined,
+ { viewDiffsFileByFile: true },
+ );
await nextTick();
@@ -717,13 +741,18 @@ describe('diffs/components/app', () => {
`(
'calls navigateToDiffFileIndex with $index when $link is clicked',
async ({ currentDiffFileId, targetFile }) => {
- createComponent({ fileByFileUserPreference: true }, ({ state }) => {
- state.diffs.treeEntries = {
- 123: { type: 'blob', fileHash: '123', filePaths: { old: '1234', new: '123' } },
- 312: { type: 'blob', fileHash: '312', filePaths: { old: '3124', new: '312' } },
- };
- state.diffs.currentDiffFileId = currentDiffFileId;
- });
+ createComponent(
+ undefined,
+ ({ state }) => {
+ state.diffs.treeEntries = {
+ 123: { type: 'blob', fileHash: '123', filePaths: { old: '1234', new: '123' } },
+ 312: { type: 'blob', fileHash: '312', filePaths: { old: '3124', new: '312' } },
+ };
+ state.diffs.currentDiffFileId = currentDiffFileId;
+ },
+ undefined,
+ { viewDiffsFileByFile: true },
+ );
await nextTick();
diff --git a/spec/frontend/lib/utils/number_utility_spec.js b/spec/frontend/lib/utils/number_utility_spec.js
index d2591cd2328..07e3e2f0422 100644
--- a/spec/frontend/lib/utils/number_utility_spec.js
+++ b/spec/frontend/lib/utils/number_utility_spec.js
@@ -109,8 +109,8 @@ describe('Number Utils', () => {
describe('numberToHumanSize', () => {
it('should return bytes', () => {
- expect(numberToHumanSize(654)).toEqual('654 bytes');
- expect(numberToHumanSize(-654)).toEqual('-654 bytes');
+ expect(numberToHumanSize(654)).toEqual('654 B');
+ expect(numberToHumanSize(-654)).toEqual('-654 B');
});
it('should return KiB', () => {
diff --git a/spec/frontend/packages_and_registries/harbor_registry/components/details/artifacts_list_row_spec.js b/spec/frontend/packages_and_registries/harbor_registry/components/details/artifacts_list_row_spec.js
index 1e9b9b1ce47..d5a87945c16 100644
--- a/spec/frontend/packages_and_registries/harbor_registry/components/details/artifacts_list_row_spec.js
+++ b/spec/frontend/packages_and_registries/harbor_registry/components/details/artifacts_list_row_spec.js
@@ -132,7 +132,7 @@ describe('Harbor artifact list row', () => {
},
});
- expect(findByTestId('size').text()).toBe('0 bytes');
+ expect(findByTestId('size').text()).toBe('0 B');
});
});
});
diff --git a/spec/frontend/packages_and_registries/infrastructure_registry/components/details/components/details_title_spec.js b/spec/frontend/packages_and_registries/infrastructure_registry/components/details/components/details_title_spec.js
index 148e87699f1..7f56d3e216c 100644
--- a/spec/frontend/packages_and_registries/infrastructure_registry/components/details/components/details_title_spec.js
+++ b/spec/frontend/packages_and_registries/infrastructure_registry/components/details/components/details_title_spec.js
@@ -51,7 +51,7 @@ describe('PackageTitle', () => {
it('correctly calculates the size', async () => {
await createComponent();
- expect(packageSize().props('text')).toBe('300 bytes');
+ expect(packageSize().props('text')).toBe('300 B');
});
});
diff --git a/spec/frontend/super_sidebar/components/help_center_spec.js b/spec/frontend/super_sidebar/components/help_center_spec.js
index 4c3e6400daa..23903627f0a 100644
--- a/spec/frontend/super_sidebar/components/help_center_spec.js
+++ b/spec/frontend/super_sidebar/components/help_center_spec.js
@@ -25,6 +25,7 @@ describe('HelpCenter component', () => {
};
const withinComponent = () => within(wrapper.element);
const findButton = (name) => withinComponent().getByRole('button', { name });
+ const findNotificationDot = () => wrapper.findByTestId('notification-dot');
// eslint-disable-next-line no-shadow
const createWrapper = (sidebarData) => {
@@ -203,8 +204,8 @@ describe('HelpCenter component', () => {
createWrapper({ ...sidebarData, display_whats_new: false });
});
- it('is false', () => {
- expect(wrapper.vm.showWhatsNewNotification).toBe(false);
+ it('does not render notification dot', () => {
+ expect(findNotificationDot().exists()).toBe(false);
});
});
@@ -215,8 +216,8 @@ describe('HelpCenter component', () => {
createWrapper({ ...sidebarData, display_whats_new: true });
});
- it('is true', () => {
- expect(wrapper.vm.showWhatsNewNotification).toBe(true);
+ it('renders notification dot', () => {
+ expect(findNotificationDot().exists()).toBe(true);
});
describe('when "What\'s new" drawer got opened', () => {
@@ -224,8 +225,8 @@ describe('HelpCenter component', () => {
findButton("What's new 5").click();
});
- it('is false', () => {
- expect(wrapper.vm.showWhatsNewNotification).toBe(false);
+ it('does not render notification dot', () => {
+ expect(findNotificationDot().exists()).toBe(false);
});
});
@@ -235,8 +236,8 @@ describe('HelpCenter component', () => {
createWrapper({ ...sidebarData, display_whats_new: true });
});
- it('is false', () => {
- expect(wrapper.vm.showWhatsNewNotification).toBe(false);
+ it('does not render notification dot', () => {
+ expect(findNotificationDot().exists()).toBe(false);
});
});
});
diff --git a/spec/frontend_integration/diffs/diffs_interopability_spec.js b/spec/frontend_integration/diffs/diffs_interopability_spec.js
index 5017fb8c49d..c5bd77adf8f 100644
--- a/spec/frontend_integration/diffs/diffs_interopability_spec.js
+++ b/spec/frontend_integration/diffs/diffs_interopability_spec.js
@@ -3,6 +3,7 @@ import setWindowLocation from 'helpers/set_window_location_helper';
import { TEST_HOST } from 'helpers/test_constants';
import { stubPerformanceWebAPI } from 'helpers/performance';
import initDiffsApp from '~/diffs';
+import { initMrStateLazyLoad } from '~/mr_notes/init';
import { createStore } from '~/mr_notes/stores';
import {
getDiffCodePart,
@@ -53,23 +54,35 @@ const startDiffsApp = () => {
endpointBatch: `${TEST_BASE_URL}diffs_batch.json`,
projectPath: TEST_PROJECT_PATH,
helpPagePath: '/help',
- currentUserData: 'null',
+ currentUserData: '{}',
changesEmptyStateIllustration: '',
isFluidLayout: 'false',
dismissEndpoint: '',
showSuggestPopover: 'false',
showWhitespaceDefault: 'true',
- viewDiffsFileByFile: 'false',
+ fileByFileDefault: 'false',
defaultSuggestionCommitMessage: 'Lorem ipsum',
});
- const store = createStore();
-
- const vm = initDiffsApp(store);
+ const notesEl = document.createElement('div');
+ notesEl.id = 'js-vue-mr-discussions';
+ document.body.appendChild(notesEl);
+ Object.assign(notesEl.dataset, {
+ noteableData: '{ "current_user": {} }',
+ notesData: '{}',
+ currentUserData: '{}',
+ });
- store.dispatch('setActiveTab', 'diffs');
+ window.mrTabs = {
+ getCurrentAction: () => 'diffs',
+ eventHub: {
+ $on() {},
+ },
+ };
+ const store = createStore();
+ initMrStateLazyLoad(store);
- return vm;
+ return initDiffsApp(store);
};
describe('diffs third party interoperability', () => {
@@ -117,7 +130,7 @@ describe('diffs third party interoperability', () => {
${'parallel view right side'} | ${'parallel'} | ${'.diff-tr.line_holder'} | ${'.diff-td.line_content.right-side'} | ${EXPECT_PARALLEL_RIGHT_SIDE}
`('$desc', ({ view, rowSelector, codeSelector, expectation }) => {
beforeEach(async () => {
- setWindowLocation(`${TEST_HOST}/${TEST_BASE_URL}/diffs?view=${view}`);
+ setWindowLocation(`${TEST_HOST}${TEST_BASE_URL}diffs?view=${view}`);
vm = startDiffsApp();
diff --git a/spec/lib/api/entities/personal_access_token_spec.rb b/spec/lib/api/entities/personal_access_token_spec.rb
index 7f79cc80573..039b5502231 100644
--- a/spec/lib/api/entities/personal_access_token_spec.rb
+++ b/spec/lib/api/entities/personal_access_token_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe API::Entities::PersonalAccessToken do
describe '#as_json' do
let_it_be(:user) { create(:user) }
- let_it_be(:token) { create(:personal_access_token, user: user, expires_at: nil) }
+ let_it_be(:token) { create(:personal_access_token, user: user) }
let(:entity) { described_class.new(token) }
diff --git a/spec/lib/gitlab/ci/templates/Pages/zola_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/Pages/zola_gitlab_ci_yaml_spec.rb
new file mode 100644
index 00000000000..4f80ae0054b
--- /dev/null
+++ b/spec/lib/gitlab/ci/templates/Pages/zola_gitlab_ci_yaml_spec.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'Pages/Zola.gitlab-ci.yml', feature_category: :pages do
+ subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Pages/Zola') }
+
+ describe 'the created pipeline' do
+ let_it_be(:project) { create(:project, :repository) }
+
+ let(:user) { project.first_owner }
+ let(:service) { Ci::CreatePipelineService.new(project, user, ref: project.default_branch) }
+ let(:pipeline) { service.execute(:push).payload }
+ let(:build_names) { pipeline.builds.pluck(:name) }
+
+ before do
+ stub_ci_pipeline_yaml_file(template.content)
+ allow(Ci::BuildScheduleWorker).to receive(:perform).and_return(true)
+ end
+
+ it 'creates "pages" job' do
+ expect(build_names).to include('pages')
+ end
+ end
+end
diff --git a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
index 05205ab6d6a..52652caa7f6 100644
--- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
@@ -208,6 +208,19 @@ RSpec.describe Gitlab::GitalyClient::CommitService, feature_category: :gitaly do
is_expected.to eq([[], nil])
end
+ context 'when recursive is "true"' do
+ let(:recursive) { true }
+
+ it 'sends a get_tree_entries message without the limit' do
+ expect_any_instance_of(Gitaly::CommitService::Stub)
+ .to receive(:get_tree_entries)
+ .with(gitaly_request_with_params({ pagination_params: nil }), kind_of(Hash))
+ .and_return([])
+
+ is_expected.to eq([[], nil])
+ end
+ end
+
context 'with UTF-8 params strings' do
let(:revision) { "branch\u011F" }
let(:path) { "foo/\u011F.txt" }
diff --git a/spec/models/concerns/token_authenticatable_spec.rb b/spec/models/concerns/token_authenticatable_spec.rb
index 7367577914c..70123eaac26 100644
--- a/spec/models/concerns/token_authenticatable_spec.rb
+++ b/spec/models/concerns/token_authenticatable_spec.rb
@@ -130,7 +130,7 @@ RSpec.describe PersonalAccessToken, 'TokenAuthenticatable' do
let(:token_digest) { Gitlab::CryptoHelper.sha256(token_value) }
let(:user) { create(:user) }
let(:personal_access_token) do
- described_class.new(name: 'test-pat-01', user_id: user.id, scopes: [:api], token_digest: token_digest)
+ described_class.new(name: 'test-pat-01', user_id: user.id, scopes: [:api], token_digest: token_digest, expires_at: 30.days.from_now)
end
before do
diff --git a/spec/models/personal_access_token_spec.rb b/spec/models/personal_access_token_spec.rb
index 5ba9597a519..8e86518912c 100644
--- a/spec/models/personal_access_token_spec.rb
+++ b/spec/models/personal_access_token_spec.rb
@@ -259,6 +259,13 @@ RSpec.describe PersonalAccessToken, feature_category: :system_access do
context 'validates expires_at' do
let(:max_expiration_date) { described_class::MAX_PERSONAL_ACCESS_TOKEN_LIFETIME_IN_DAYS.days.from_now }
+ it "can't be blank" do
+ personal_access_token.expires_at = nil
+
+ expect(personal_access_token).not_to be_valid
+ expect(personal_access_token.errors[:expires_at].first).to eq("can't be blank")
+ end
+
context 'when expires_in is less than MAX_PERSONAL_ACCESS_TOKEN_LIFETIME_IN_DAYS days' do
it 'is valid' do
personal_access_token.expires_at = max_expiration_date - 1.day
@@ -285,11 +292,10 @@ RSpec.describe PersonalAccessToken, feature_category: :system_access do
let_it_be(:not_revoked_nil_token) { create(:personal_access_token, revoked: nil) }
let_it_be(:expired_token) { create(:personal_access_token, :expired) }
let_it_be(:not_expired_token) { create(:personal_access_token) }
- let_it_be(:never_expires_token) { create(:personal_access_token, expires_at: nil) }
- it 'includes non-revoked and non-expired tokens' do
+ it 'includes non-revoked tokens' do
expect(described_class.active)
- .to match_array([not_revoked_false_token, not_revoked_nil_token, not_expired_token, never_expires_token])
+ .to match_array([not_revoked_false_token, not_revoked_nil_token, not_expired_token])
end
end
@@ -414,22 +420,4 @@ RSpec.describe PersonalAccessToken, feature_category: :system_access do
end
end
end
-
- describe '#expires_at=' do
- let(:personal_access_token) { described_class.new }
-
- context 'expires_at set to empty value' do
- [nil, ""].each do |expires_in_value|
- it 'defaults to PersonalAccessToken::MAX_PERSONAL_ACCESS_TOKEN_LIFETIME_IN_DAYS' do
- personal_access_token.expires_at = expires_in_value
-
- freeze_time do
- expect(personal_access_token.expires_at).to eq(
- PersonalAccessToken::MAX_PERSONAL_ACCESS_TOKEN_LIFETIME_IN_DAYS.days.from_now.to_date
- )
- end
- end
- end
- end
- end
end
diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb
index 76172cf482d..619ffd8d41a 100644
--- a/spec/requests/api/internal/base_spec.rb
+++ b/spec/requests/api/internal/base_spec.rb
@@ -225,7 +225,8 @@ RSpec.describe API::Internal::Base, feature_category: :system_access do
params: {
key_id: key.id,
name: 'newtoken',
- scopes: %w(read_api read_repository)
+ scopes: %w(read_api read_repository),
+ expires_at: 365.days.from_now
},
headers: gitlab_shell_internal_api_request_header
diff --git a/spec/serializers/access_token_entity_base_spec.rb b/spec/serializers/access_token_entity_base_spec.rb
index 8a92a53d0c1..f310a3d4a99 100644
--- a/spec/serializers/access_token_entity_base_spec.rb
+++ b/spec/serializers/access_token_entity_base_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe AccessTokenEntityBase do
let_it_be(:user) { create(:user) }
- let_it_be(:token) { create(:personal_access_token, user: user, expires_at: nil) }
+ let_it_be(:token) { create(:personal_access_token, user: user) }
subject(:json) { described_class.new(token).as_json }
diff --git a/spec/services/personal_access_tokens/create_service_spec.rb b/spec/services/personal_access_tokens/create_service_spec.rb
index d80be5cccce..621211bc883 100644
--- a/spec/services/personal_access_tokens/create_service_spec.rb
+++ b/spec/services/personal_access_tokens/create_service_spec.rb
@@ -67,6 +67,13 @@ RSpec.describe PersonalAccessTokens::CreateService, feature_category: :system_ac
end
end
+ context 'with no expires_at set', :freeze_time do
+ let(:params) { { name: 'Test token', impersonation: false, scopes: [:no_valid] } }
+ let(:service) { described_class.new(current_user: user, target_user: user, params: params) }
+
+ it { expect(subject.payload[:personal_access_token].expires_at).to eq PersonalAccessToken::MAX_PERSONAL_ACCESS_TOKEN_LIFETIME_IN_DAYS.days.from_now.to_date }
+ end
+
context 'when invalid scope' do
let(:params) { { name: 'Test token', impersonation: false, scopes: [:no_valid], expires_at: Date.today + 1.month } }