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>2021-11-25 21:14:13 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-25 21:14:13 +0300
commit1c635e68ea6fb392244f0d9f8c9dd2c7bd1c95e6 (patch)
tree052cfeba83f0db195c3861cd3a0173df30bb8a01 /spec
parentd03aeb1110374d140a42622716597ccfa8e4ba57 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/packages/debian/component_file.rb4
-rw-r--r--spec/frontend/repository/components/__snapshots__/code_owners_spec.js.snap220
-rw-r--r--spec/frontend/repository/components/__snapshots__/last_commit_spec.js.snap4
-rw-r--r--spec/frontend/repository/components/code_owners_spec.js89
-rw-r--r--spec/frontend/repository/mock_data.js15
-rw-r--r--spec/graphql/types/repository/blob_type_spec.rb1
-rw-r--r--spec/services/packages/debian/update_distribution_service_spec.rb4
-rw-r--r--spec/support/shared_examples/models/packages/debian/component_file_shared_example.rb18
-rw-r--r--spec/support/shared_examples/services/packages/debian/generate_distribution_shared_examples.rb20
9 files changed, 350 insertions, 25 deletions
diff --git a/spec/factories/packages/debian/component_file.rb b/spec/factories/packages/debian/component_file.rb
index 9aee91b0973..eeba64ba5d2 100644
--- a/spec/factories/packages/debian/component_file.rb
+++ b/spec/factories/packages/debian/component_file.rb
@@ -27,8 +27,8 @@ FactoryBot.define do
file_type { :packages }
end
- trait(:source) do
- file_type { :source }
+ trait(:sources) do
+ file_type { :sources }
architecture { nil }
end
diff --git a/spec/frontend/repository/components/__snapshots__/code_owners_spec.js.snap b/spec/frontend/repository/components/__snapshots__/code_owners_spec.js.snap
new file mode 100644
index 00000000000..06c01970afc
--- /dev/null
+++ b/spec/frontend/repository/components/__snapshots__/code_owners_spec.js.snap
@@ -0,0 +1,220 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Code owners component matches the snapshot 1`] = `<!---->`;
+
+exports[`Code owners component matches the snapshot 2`] = `
+<div
+ class="well-segment blob-auxiliary-viewer file-owner-content qa-file-owner-content"
+>
+ <gl-icon-stub
+ data-testid="users-icon"
+ name="users"
+ size="16"
+ />
+
+ <strong>
+ Code owners
+ </strong>
+
+ <gl-link-stub
+ href="/help/user/project/code_owners"
+ target="_blank"
+ title="About this feature"
+ >
+ <gl-icon-stub
+ data-testid="help-icon"
+ name="question-o"
+ size="16"
+ />
+ </gl-link-stub>
+
+ :
+
+ <div
+ class="gl-display-inline"
+ data-testid="code-owners"
+ >
+ <!---->
+
+ <!---->
+
+ <gl-link-stub
+ href="path/to/@johnDoe"
+ target="_blank"
+ title="About this feature"
+ >
+
+ John Doe
+
+ </gl-link-stub>
+ </div>
+</div>
+`;
+
+exports[`Code owners component matches the snapshot 3`] = `
+<div
+ class="well-segment blob-auxiliary-viewer file-owner-content qa-file-owner-content"
+>
+ <gl-icon-stub
+ data-testid="users-icon"
+ name="users"
+ size="16"
+ />
+
+ <strong>
+ Code owners
+ </strong>
+
+ <gl-link-stub
+ href="/help/user/project/code_owners"
+ target="_blank"
+ title="About this feature"
+ >
+ <gl-icon-stub
+ data-testid="help-icon"
+ name="question-o"
+ size="16"
+ />
+ </gl-link-stub>
+
+ :
+
+ <div
+ class="gl-display-inline"
+ data-testid="code-owners"
+ >
+ <!---->
+
+ <!---->
+
+ <gl-link-stub
+ href="path/to/@johnDoe"
+ target="_blank"
+ title="About this feature"
+ >
+
+ John Doe
+
+ </gl-link-stub>
+ </div>
+ <div
+ class="gl-display-inline"
+ data-testid="code-owners"
+ >
+ <!---->
+
+ <span
+ data-testid="and-separator"
+ >
+ and
+ </span>
+
+ <gl-link-stub
+ href="path/to/@johnDoe"
+ target="_blank"
+ title="About this feature"
+ >
+
+ John Doe
+
+ </gl-link-stub>
+ </div>
+</div>
+`;
+
+exports[`Code owners component matches the snapshot 4`] = `
+<div
+ class="well-segment blob-auxiliary-viewer file-owner-content qa-file-owner-content"
+>
+ <gl-icon-stub
+ data-testid="users-icon"
+ name="users"
+ size="16"
+ />
+
+ <strong>
+ Code owners
+ </strong>
+
+ <gl-link-stub
+ href="/help/user/project/code_owners"
+ target="_blank"
+ title="About this feature"
+ >
+ <gl-icon-stub
+ data-testid="help-icon"
+ name="question-o"
+ size="16"
+ />
+ </gl-link-stub>
+
+ :
+
+ <div
+ class="gl-display-inline-block"
+ data-testid="code-owners"
+ >
+ <!---->
+
+ <!---->
+
+ <gl-link-stub
+ href="path/to/@johnDoe"
+ target="_blank"
+ title="About this feature"
+ >
+
+ John Doe
+
+ </gl-link-stub>
+ </div>
+ <div
+ class="gl-display-inline-block"
+ data-testid="code-owners"
+ >
+ <span
+ data-testid="comma-separator"
+ >
+ ,
+ </span>
+
+ <!---->
+
+ <gl-link-stub
+ href="path/to/@johnDoe"
+ target="_blank"
+ title="About this feature"
+ >
+
+ John Doe
+
+ </gl-link-stub>
+ </div>
+ <div
+ class="gl-display-inline-block"
+ data-testid="code-owners"
+ >
+ <span
+ data-testid="comma-separator"
+ >
+ ,
+ </span>
+
+ <span
+ data-testid="and-separator"
+ >
+ and
+ </span>
+
+ <gl-link-stub
+ href="path/to/@johnDoe"
+ target="_blank"
+ title="About this feature"
+ >
+
+ John Doe
+
+ </gl-link-stub>
+ </div>
+</div>
+`;
diff --git a/spec/frontend/repository/components/__snapshots__/last_commit_spec.js.snap b/spec/frontend/repository/components/__snapshots__/last_commit_spec.js.snap
index be4f8a688e0..fe2247420ed 100644
--- a/spec/frontend/repository/components/__snapshots__/last_commit_spec.js.snap
+++ b/spec/frontend/repository/components/__snapshots__/last_commit_spec.js.snap
@@ -2,7 +2,7 @@
exports[`Repository last commit component renders commit widget 1`] = `
<div
- class="info-well d-none d-sm-flex project-last-commit commit p-3"
+ class="well-segment commit gl-p-5 gl-w-full"
>
<user-avatar-link-stub
class="avatar-cell"
@@ -108,7 +108,7 @@ exports[`Repository last commit component renders commit widget 1`] = `
exports[`Repository last commit component renders the signature HTML as returned by the backend 1`] = `
<div
- class="info-well d-none d-sm-flex project-last-commit commit p-3"
+ class="well-segment commit gl-p-5 gl-w-full"
>
<user-avatar-link-stub
class="avatar-cell"
diff --git a/spec/frontend/repository/components/code_owners_spec.js b/spec/frontend/repository/components/code_owners_spec.js
new file mode 100644
index 00000000000..44e47ff89a0
--- /dev/null
+++ b/spec/frontend/repository/components/code_owners_spec.js
@@ -0,0 +1,89 @@
+import { GlLink } from '@gitlab/ui';
+import { shallowMount, createLocalVue } from '@vue/test-utils';
+import VueApollo from 'vue-apollo';
+import createMockApollo from 'helpers/mock_apollo_helper';
+import waitForPromises from 'helpers/wait_for_promises';
+import CodeOwners from '~/repository/components/code_owners.vue';
+import codeOwnersInfoQuery from '~/repository/queries/code_owners_info.query.graphql';
+import { extendedWrapper } from 'helpers/vue_test_utils_helper';
+import { codeOwnerMock, codeOwnersDataMock, refMock } from '../mock_data';
+
+let wrapper;
+let mockResolver;
+
+const localVue = createLocalVue();
+
+const createComponent = async (codeOwners = [codeOwnerMock]) => {
+ localVue.use(VueApollo);
+
+ const project = {
+ ...codeOwnersDataMock,
+ repository: {
+ blobs: {
+ nodes: [{ codeOwners }],
+ },
+ },
+ };
+
+ mockResolver = jest.fn().mockResolvedValue({ data: { project } });
+
+ wrapper = extendedWrapper(
+ shallowMount(CodeOwners, {
+ localVue,
+ apolloProvider: createMockApollo([[codeOwnersInfoQuery, mockResolver]]),
+ propsData: { projectPath: 'some/project', filePath: 'some/file' },
+ mixins: [{ data: () => ({ ref: refMock }) }],
+ }),
+ );
+
+ wrapper.setData({ isFetching: false });
+
+ await waitForPromises();
+};
+
+describe('Code owners component', () => {
+ const findHelpIcon = () => wrapper.findByTestId('help-icon');
+ const findUsersIcon = () => wrapper.findByTestId('users-icon');
+ const findCodeOwners = () => wrapper.findAllByTestId('code-owners');
+ const findCommaSeparators = () => wrapper.findAllByTestId('comma-separator');
+ const findAndSeparator = () => wrapper.findAllByTestId('and-separator');
+ const findLink = () => wrapper.findComponent(GlLink);
+
+ beforeEach(() => createComponent());
+
+ afterEach(() => wrapper.destroy());
+
+ describe('help link', () => {
+ it('renders a GlLink component', () => {
+ expect(findLink().exists()).toBe(true);
+ expect(findLink().attributes('href')).toBe('/help/user/project/code_owners');
+ expect(findLink().attributes('target')).toBe('_blank');
+ expect(findLink().attributes('title')).toBe('About this feature');
+ });
+
+ it('renders a Help icon', () => {
+ expect(findHelpIcon().exists()).toBe(true);
+ expect(findHelpIcon().props('name')).toBe('question-o');
+ });
+ });
+
+ it('renders a Users icon', () => {
+ expect(findUsersIcon().exists()).toBe(true);
+ expect(findUsersIcon().props('name')).toBe('users');
+ });
+
+ it.each`
+ codeOwners | commaSeparators | hasAndSeparator
+ ${[]} | ${0} | ${false}
+ ${[codeOwnerMock]} | ${0} | ${false}
+ ${[codeOwnerMock, codeOwnerMock]} | ${0} | ${true}
+ ${[codeOwnerMock, codeOwnerMock, codeOwnerMock]} | ${2} | ${true}
+ `('matches the snapshot', async ({ codeOwners, commaSeparators, hasAndSeparator }) => {
+ await createComponent(codeOwners);
+
+ expect(findCommaSeparators().length).toBe(commaSeparators);
+ expect(findAndSeparator().exists()).toBe(hasAndSeparator);
+ expect(findCodeOwners().length).toBe(codeOwners.length);
+ expect(wrapper.element).toMatchSnapshot();
+ });
+});
diff --git a/spec/frontend/repository/mock_data.js b/spec/frontend/repository/mock_data.js
index adf5991ac3c..b0defac1eb5 100644
--- a/spec/frontend/repository/mock_data.js
+++ b/spec/frontend/repository/mock_data.js
@@ -55,3 +55,18 @@ export const projectMock = {
export const propsMock = { path: 'some_file.js', projectPath: 'some/path' };
export const refMock = 'default-ref';
+
+export const codeOwnerMock = { name: 'John Doe', webPath: 'path/to/@johnDoe' };
+
+export const codeOwnersDataMock = {
+ id: '1234',
+ repository: {
+ blobs: {
+ nodes: [
+ {
+ codeOwners: [],
+ },
+ ],
+ },
+ },
+};
diff --git a/spec/graphql/types/repository/blob_type_spec.rb b/spec/graphql/types/repository/blob_type_spec.rb
index 7f37237f355..e0def84fcac 100644
--- a/spec/graphql/types/repository/blob_type_spec.rb
+++ b/spec/graphql/types/repository/blob_type_spec.rb
@@ -24,6 +24,7 @@ RSpec.describe Types::Repository::BlobType do
:raw_path,
:replace_path,
:pipeline_editor_path,
+ :code_owners,
:simple_viewer,
:rich_viewer,
:plain_data,
diff --git a/spec/services/packages/debian/update_distribution_service_spec.rb b/spec/services/packages/debian/update_distribution_service_spec.rb
index 2aa34a62111..3dff2754cec 100644
--- a/spec/services/packages/debian/update_distribution_service_spec.rb
+++ b/spec/services/packages/debian/update_distribution_service_spec.rb
@@ -61,9 +61,9 @@ RSpec.describe Packages::Debian::UpdateDistributionService do
let_it_be(:architecture0) { create("debian_#{container_type}_architecture", distribution: distribution, name: 'all') }
let_it_be(:architecture1) { create("debian_#{container_type}_architecture", distribution: distribution, name: 'architecture1') }
let_it_be(:architecture2) { create("debian_#{container_type}_architecture", distribution: distribution, name: 'architecture2') }
- let_it_be(:component_file1) { create("debian_#{container_type}_component_file", :source, component: component1) }
+ let_it_be(:component_file1) { create("debian_#{container_type}_component_file", :sources, component: component1) }
let_it_be(:component_file2) { create("debian_#{container_type}_component_file", component: component1, architecture: architecture1) }
- let_it_be(:component_file3) { create("debian_#{container_type}_component_file", :source, component: component2) }
+ let_it_be(:component_file3) { create("debian_#{container_type}_component_file", :sources, component: component2) }
let_it_be(:component_file4) { create("debian_#{container_type}_component_file", component: component2, architecture: architecture2) }
let(:original_params) do
diff --git a/spec/support/shared_examples/models/packages/debian/component_file_shared_example.rb b/spec/support/shared_examples/models/packages/debian/component_file_shared_example.rb
index f08ee820463..23026167b19 100644
--- a/spec/support/shared_examples/models/packages/debian/component_file_shared_example.rb
+++ b/spec/support/shared_examples/models/packages/debian/component_file_shared_example.rb
@@ -23,7 +23,7 @@ RSpec.shared_examples 'Debian Component File' do |container_type, can_freeze|
let_it_be(:component_file_other_file_md5, freeze: can_freeze) { create("debian_#{container_type}_component_file", component: component1_1, architecture: architecture1_1, file_md5: 'other_md5') }
let_it_be(:component_file_other_file_sha256, freeze: can_freeze) { create("debian_#{container_type}_component_file", component: component1_1, architecture: architecture1_1, file_sha256: 'other_sha256') }
let_it_be(:component_file_other_container, freeze: can_freeze) { create("debian_#{container_type}_component_file", component: component2_1, architecture: architecture2_1) }
- let_it_be_with_refind(:component_file_with_file_type_source) { create("debian_#{container_type}_component_file", :source, component: component1_1) }
+ let_it_be_with_refind(:component_file_with_file_type_sources) { create("debian_#{container_type}_component_file", :sources, component: component1_1) }
let_it_be(:component_file_with_file_type_di_packages, freeze: can_freeze) { create("debian_#{container_type}_component_file", :di_packages, component: component1_1, architecture: architecture1_1) }
subject { component_file_with_architecture }
@@ -43,8 +43,8 @@ RSpec.shared_examples 'Debian Component File' do |container_type, can_freeze|
it { is_expected.to belong_to(:architecture).class_name("Packages::Debian::#{container_type.capitalize}Architecture").inverse_of(:files) }
end
- context 'with :source file_type' do
- subject { component_file_with_file_type_source }
+ context 'with :sources file_type' do
+ subject { component_file_with_file_type_sources }
it { is_expected.to belong_to(:architecture).class_name("Packages::Debian::#{container_type.capitalize}Architecture").inverse_of(:files).optional }
end
@@ -66,8 +66,8 @@ RSpec.shared_examples 'Debian Component File' do |container_type, can_freeze|
it { is_expected.to validate_presence_of(:architecture) }
end
- context 'with :source file_type' do
- subject { component_file_with_file_type_source }
+ context 'with :sources file_type' do
+ subject { component_file_with_file_type_sources }
it { is_expected.to validate_absence_of(:architecture) }
end
@@ -135,10 +135,10 @@ RSpec.shared_examples 'Debian Component File' do |container_type, can_freeze|
end
describe '.with_file_type' do
- subject { described_class.with_file_type(:source) }
+ subject { described_class.with_file_type(:sources) }
it do
- expect(subject.to_a).to contain_exactly(component_file_with_file_type_source)
+ expect(subject.to_a).to contain_exactly(component_file_with_file_type_sources)
end
end
@@ -214,9 +214,9 @@ RSpec.shared_examples 'Debian Component File' do |container_type, can_freeze|
end
context 'with a Source file_type' do
- subject { component_file_with_file_type_source.relative_path }
+ subject { component_file_with_file_type_sources.relative_path }
- it { is_expected.to eq("#{component1_1.name}/source/Source") }
+ it { is_expected.to eq("#{component1_1.name}/source/Sources") }
end
context 'with a DI Packages file_type' do
diff --git a/spec/support/shared_examples/services/packages/debian/generate_distribution_shared_examples.rb b/spec/support/shared_examples/services/packages/debian/generate_distribution_shared_examples.rb
index c979fdc2bb0..7fd20fc3909 100644
--- a/spec/support/shared_examples/services/packages/debian/generate_distribution_shared_examples.rb
+++ b/spec/support/shared_examples/services/packages/debian/generate_distribution_shared_examples.rb
@@ -126,7 +126,7 @@ RSpec.shared_examples 'Generate Debian Distribution and component files' do
SHA256: #{package_files[4].file_sha256}
EOF
- expected_main_source_content = <<~EOF
+ expected_main_sources_content = <<~EOF
Package: #{package.name}
Binary: sample-dev, libsample0, sample-udeb
Version: #{package.version}
@@ -158,7 +158,7 @@ RSpec.shared_examples 'Generate Debian Distribution and component files' do
check_component_file(current_time.round, 'main', :di_packages, 'amd64', expected_main_amd64_di_content)
check_component_file(current_time.round, 'main', :di_packages, 'arm64', nil)
- check_component_file(current_time.round, 'main', :source, nil, expected_main_source_content)
+ check_component_file(current_time.round, 'main', :sources, nil, expected_main_sources_content)
check_component_file(current_time.round, 'contrib', :packages, 'all', nil)
check_component_file(current_time.round, 'contrib', :packages, 'amd64', nil)
@@ -168,7 +168,7 @@ RSpec.shared_examples 'Generate Debian Distribution and component files' do
check_component_file(current_time.round, 'contrib', :di_packages, 'amd64', nil)
check_component_file(current_time.round, 'contrib', :di_packages, 'arm64', nil)
- check_component_file(current_time.round, 'contrib', :source, nil, nil)
+ check_component_file(current_time.round, 'contrib', :sources, nil, nil)
main_amd64_size = expected_main_amd64_content.length
main_amd64_md5sum = Digest::MD5.hexdigest(expected_main_amd64_content)
@@ -182,9 +182,9 @@ RSpec.shared_examples 'Generate Debian Distribution and component files' do
main_amd64_di_md5sum = Digest::MD5.hexdigest(expected_main_amd64_di_content)
main_amd64_di_sha256 = Digest::SHA256.hexdigest(expected_main_amd64_di_content)
- main_source_size = expected_main_source_content.length
- main_source_md5sum = Digest::MD5.hexdigest(expected_main_source_content)
- main_source_sha256 = Digest::SHA256.hexdigest(expected_main_source_content)
+ main_sources_size = expected_main_sources_content.length
+ main_sources_md5sum = Digest::MD5.hexdigest(expected_main_sources_content)
+ main_sources_sha256 = Digest::SHA256.hexdigest(expected_main_sources_content)
expected_release_content = <<~EOF
Codename: unstable
@@ -199,14 +199,14 @@ RSpec.shared_examples 'Generate Debian Distribution and component files' do
d41d8cd98f00b204e9800998ecf8427e 0 contrib/debian-installer/binary-amd64/Packages
d41d8cd98f00b204e9800998ecf8427e 0 contrib/binary-arm64/Packages
d41d8cd98f00b204e9800998ecf8427e 0 contrib/debian-installer/binary-arm64/Packages
- d41d8cd98f00b204e9800998ecf8427e 0 contrib/source/Source
+ d41d8cd98f00b204e9800998ecf8427e 0 contrib/source/Sources
d41d8cd98f00b204e9800998ecf8427e 0 main/binary-all/Packages
d41d8cd98f00b204e9800998ecf8427e 0 main/debian-installer/binary-all/Packages
#{main_amd64_md5sum} #{main_amd64_size} main/binary-amd64/Packages
#{main_amd64_di_md5sum} #{main_amd64_di_size} main/debian-installer/binary-amd64/Packages
d41d8cd98f00b204e9800998ecf8427e 0 main/binary-arm64/Packages
d41d8cd98f00b204e9800998ecf8427e 0 main/debian-installer/binary-arm64/Packages
- #{main_source_md5sum} #{main_source_size} main/source/Source
+ #{main_sources_md5sum} #{main_sources_size} main/source/Sources
SHA256:
#{contrib_all_sha256} #{contrib_all_size} contrib/binary-all/Packages
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 contrib/debian-installer/binary-all/Packages
@@ -214,14 +214,14 @@ RSpec.shared_examples 'Generate Debian Distribution and component files' do
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 contrib/debian-installer/binary-amd64/Packages
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 contrib/binary-arm64/Packages
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 contrib/debian-installer/binary-arm64/Packages
- e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 contrib/source/Source
+ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 contrib/source/Sources
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 main/binary-all/Packages
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 main/debian-installer/binary-all/Packages
#{main_amd64_sha256} #{main_amd64_size} main/binary-amd64/Packages
#{main_amd64_di_sha256} #{main_amd64_di_size} main/debian-installer/binary-amd64/Packages
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 main/binary-arm64/Packages
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 main/debian-installer/binary-arm64/Packages
- #{main_source_sha256} #{main_source_size} main/source/Source
+ #{main_sources_sha256} #{main_sources_size} main/source/Sources
EOF
check_release_files(expected_release_content)