diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-02 15:09:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-02 15:09:26 +0300 |
commit | c658e2d29296721aa65d569a42b778485042795a (patch) | |
tree | 24a39099120ead3fc31d7f115094dc928c38af29 /spec | |
parent | 3256c55b0f188227e27a4863532feee84e654911 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/ci/builds.rb | 14 | ||||
-rw-r--r-- | spec/frontend/issues/show/components/description_spec.js | 12 | ||||
-rw-r--r-- | spec/frontend/sidebar/components/reviewers/uncollapsed_reviewer_list_spec.js | 21 | ||||
-rw-r--r-- | spec/frontend/sidebar/reviewers_spec.js | 64 | ||||
-rw-r--r-- | spec/frontend/work_items/components/work_item_links/work_item_links_form_spec.js | 46 | ||||
-rw-r--r-- | spec/frontend/work_items/mock_data.js | 1 | ||||
-rw-r--r-- | spec/lib/gitlab/git/branch_spec.rb | 23 | ||||
-rw-r--r-- | spec/lib/gitlab/import_export/decompressed_archive_size_validator_spec.rb | 5 | ||||
-rw-r--r-- | spec/models/group_spec.rb | 7 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 10 | ||||
-rw-r--r-- | spec/serializers/environment_serializer_spec.rb | 31 | ||||
-rw-r--r-- | spec/support/shared_contexts/features/integrations/integrations_shared_context.rb | 2 |
12 files changed, 176 insertions, 60 deletions
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index 97ddbf21b99..0751f4aa670 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -504,6 +504,20 @@ FactoryBot.define do artifacts_expire_at { 1.minute.ago } end + trait :with_artifacts_paths do + options do + { + artifacts: { + name: 'artifacts_file', + untracked: false, + paths: ['out/'], + when: 'always', + expire_in: '7d' + } + } + end + end + trait :with_commit do after(:build) do |build| commit = build(:commit, :without_author) diff --git a/spec/frontend/issues/show/components/description_spec.js b/spec/frontend/issues/show/components/description_spec.js index 8ee57f97754..823121c24d8 100644 --- a/spec/frontend/issues/show/components/description_spec.js +++ b/spec/frontend/issues/show/components/description_spec.js @@ -266,7 +266,7 @@ describe('Description component', () => { }); }); - describe('with work items feature flag is enabled', () => { + describe('with work_items_create_from_markdown feature flag enabled', () => { describe('empty description', () => { beforeEach(() => { createComponent({ @@ -275,7 +275,7 @@ describe('Description component', () => { }, provide: { glFeatures: { - workItems: true, + workItemsCreateFromMarkdown: true, }, }, }); @@ -295,7 +295,7 @@ describe('Description component', () => { }, provide: { glFeatures: { - workItems: true, + workItemsCreateFromMarkdown: true, }, }, }); @@ -344,7 +344,7 @@ describe('Description component', () => { descriptionHtml: descriptionHtmlWithTask, }, provide: { - glFeatures: { workItems: true }, + glFeatures: { workItemsCreateFromMarkdown: true }, }, }); return nextTick(); @@ -406,7 +406,7 @@ describe('Description component', () => { createComponent({ props: { descriptionHtml: descriptionHtmlWithTask }, - provide: { glFeatures: { workItems: true } }, + provide: { glFeatures: { workItemsCreateFromMarkdown: true } }, }); expect(showDetailsModal).toHaveBeenCalledTimes(modalOpened); @@ -422,7 +422,7 @@ describe('Description component', () => { descriptionHtml: descriptionHtmlWithTask, }, provide: { - glFeatures: { workItems: true }, + glFeatures: { workItemsCreateFromMarkdown: true }, }, }); return nextTick(); diff --git a/spec/frontend/sidebar/components/reviewers/uncollapsed_reviewer_list_spec.js b/spec/frontend/sidebar/components/reviewers/uncollapsed_reviewer_list_spec.js index 8ac85d4da81..2c24df2436a 100644 --- a/spec/frontend/sidebar/components/reviewers/uncollapsed_reviewer_list_spec.js +++ b/spec/frontend/sidebar/components/reviewers/uncollapsed_reviewer_list_spec.js @@ -2,7 +2,21 @@ import { shallowMount } from '@vue/test-utils'; import { TEST_HOST } from 'helpers/test_constants'; import ReviewerAvatarLink from '~/sidebar/components/reviewers/reviewer_avatar_link.vue'; import UncollapsedReviewerList from '~/sidebar/components/reviewers/uncollapsed_reviewer_list.vue'; -import userDataMock from '../../user_data_mock'; + +const userDataMock = () => ({ + id: 1, + name: 'Root', + state: 'active', + username: 'root', + webUrl: `${TEST_HOST}/root`, + avatarUrl: `${TEST_HOST}/avatar/root.png`, + mergeRequestInteraction: { + canMerge: true, + canUpdate: true, + reviewed: true, + approved: false, + }, +}); describe('UncollapsedReviewerList component', () => { let wrapper; @@ -69,7 +83,10 @@ describe('UncollapsedReviewerList component', () => { id: 2, name: 'nonrooty-nonrootersen', username: 'hello-world', - approved: true, + mergeRequestInteraction: { + ...user.mergeRequestInteraction, + approved: true, + }, }; beforeEach(() => { diff --git a/spec/frontend/sidebar/reviewers_spec.js b/spec/frontend/sidebar/reviewers_spec.js index 351dfc9a6ed..88bacc9b7f7 100644 --- a/spec/frontend/sidebar/reviewers_spec.js +++ b/spec/frontend/sidebar/reviewers_spec.js @@ -1,9 +1,23 @@ import { GlIcon } from '@gitlab/ui'; import { mount } from '@vue/test-utils'; import { trimText } from 'helpers/text_helper'; -import UsersMockHelper from 'helpers/user_mock_data_helper'; +import { TEST_HOST } from 'helpers/test_constants'; import Reviewer from '~/sidebar/components/reviewers/reviewers.vue'; -import UsersMock from './mock_data'; + +const usersMock = (id = 1) => ({ + id, + name: 'Root', + state: 'active', + username: 'root', + webUrl: `${TEST_HOST}/root`, + avatarUrl: `${TEST_HOST}/avatar/root.png`, + mergeRequestInteraction: { + canMerge: true, + canUpdate: true, + reviewed: true, + approved: false, + }, +}); describe('Reviewer component', () => { const getDefaultProps = () => ({ @@ -42,23 +56,23 @@ describe('Reviewer component', () => { it('displays one reviewer icon when collapsed', () => { createWrapper({ ...getDefaultProps(), - users: [UsersMock.user], + users: [usersMock()], }); const collapsedChildren = findCollapsedChildren(); const reviewer = collapsedChildren.at(0); expect(collapsedChildren.length).toBe(1); - expect(reviewer.find('.avatar').attributes('src')).toBe(UsersMock.user.avatar); - expect(reviewer.find('.avatar').attributes('alt')).toBe(`${UsersMock.user.name}'s avatar`); + expect(reviewer.find('.avatar').attributes('src')).toContain('avatar/root.png'); + expect(reviewer.find('.avatar').attributes('alt')).toBe(`Root's avatar`); - expect(trimText(reviewer.find('.author').text())).toBe(UsersMock.user.name); + expect(trimText(reviewer.find('.author').text())).toBe('Root'); }); }); describe('Two or more reviewers/users', () => { it('displays two reviewer icons when collapsed', () => { - const users = UsersMockHelper.createNumberRandomUsers(2); + const users = [usersMock(), usersMock(2)]; createWrapper({ ...getDefaultProps(), users, @@ -70,21 +84,21 @@ describe('Reviewer component', () => { const first = collapsedChildren.at(0); - expect(first.find('.avatar').attributes('src')).toBe(users[0].avatar_url); + expect(first.find('.avatar').attributes('src')).toBe(users[0].avatarUrl); expect(first.find('.avatar').attributes('alt')).toBe(`${users[0].name}'s avatar`); expect(trimText(first.find('.author').text())).toBe(users[0].name); const second = collapsedChildren.at(1); - expect(second.find('.avatar').attributes('src')).toBe(users[1].avatar_url); + expect(second.find('.avatar').attributes('src')).toBe(users[1].avatarUrl); expect(second.find('.avatar').attributes('alt')).toBe(`${users[1].name}'s avatar`); expect(trimText(second.find('.author').text())).toBe(users[1].name); }); it('displays one reviewer icon and counter when collapsed', () => { - const users = UsersMockHelper.createNumberRandomUsers(3); + const users = [usersMock(), usersMock(2), usersMock(3)]; createWrapper({ ...getDefaultProps(), users, @@ -96,7 +110,7 @@ describe('Reviewer component', () => { const first = collapsedChildren.at(0); - expect(first.find('.avatar').attributes('src')).toBe(users[0].avatar_url); + expect(first.find('.avatar').attributes('src')).toBe(users[0].avatarUrl); expect(first.find('.avatar').attributes('alt')).toBe(`${users[0].name}'s avatar`); expect(trimText(first.find('.author').text())).toBe(users[0].name); @@ -107,7 +121,7 @@ describe('Reviewer component', () => { }); it('Shows two reviewers', () => { - const users = UsersMockHelper.createNumberRandomUsers(2); + const users = [usersMock(), usersMock(2)]; createWrapper({ ...getDefaultProps(), users, @@ -118,10 +132,10 @@ describe('Reviewer component', () => { }); it('shows sorted reviewer where "can merge" users are sorted first', () => { - const users = UsersMockHelper.createNumberRandomUsers(3); - users[0].can_merge = false; - users[1].can_merge = false; - users[2].can_merge = true; + const users = [usersMock(), usersMock(2), usersMock(3)]; + users[0].mergeRequestInteraction.canMerge = false; + users[1].mergeRequestInteraction.canMerge = false; + users[2].mergeRequestInteraction.canMerge = true; createWrapper({ ...getDefaultProps(), @@ -129,14 +143,14 @@ describe('Reviewer component', () => { editable: true, }); - expect(wrapper.vm.sortedReviewers[0].can_merge).toBe(true); + expect(wrapper.vm.sortedReviewers[0].mergeRequestInteraction.canMerge).toBe(true); }); it('passes the sorted reviewers to the uncollapsed-reviewer-list', () => { - const users = UsersMockHelper.createNumberRandomUsers(3); - users[0].can_merge = false; - users[1].can_merge = false; - users[2].can_merge = true; + const users = [usersMock(), usersMock(2), usersMock(3)]; + users[0].mergeRequestInteraction.canMerge = false; + users[1].mergeRequestInteraction.canMerge = false; + users[2].mergeRequestInteraction.canMerge = true; createWrapper({ ...getDefaultProps(), @@ -149,10 +163,10 @@ describe('Reviewer component', () => { }); it('passes the sorted reviewers to the collapsed-reviewer-list', () => { - const users = UsersMockHelper.createNumberRandomUsers(3); - users[0].can_merge = false; - users[1].can_merge = false; - users[2].can_merge = true; + const users = [usersMock(), usersMock(2), usersMock(3)]; + users[0].mergeRequestInteraction.canMerge = false; + users[1].mergeRequestInteraction.canMerge = false; + users[2].mergeRequestInteraction.canMerge = true; createWrapper({ ...getDefaultProps(), diff --git a/spec/frontend/work_items/components/work_item_links/work_item_links_form_spec.js b/spec/frontend/work_items/components/work_item_links/work_item_links_form_spec.js index 93bf7286aa7..56c1d8054fd 100644 --- a/spec/frontend/work_items/components/work_item_links/work_item_links_form_spec.js +++ b/spec/frontend/work_items/components/work_item_links/work_item_links_form_spec.js @@ -1,13 +1,18 @@ import Vue from 'vue'; -import { GlForm, GlFormCombobox } from '@gitlab/ui'; +import { GlForm, GlFormInput, GlFormCombobox } from '@gitlab/ui'; import VueApollo from 'vue-apollo'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; import WorkItemLinksForm from '~/work_items/components/work_item_links/work_item_links_form.vue'; import projectWorkItemsQuery from '~/work_items/graphql/project_work_items.query.graphql'; +import createWorkItemMutation from '~/work_items/graphql/create_work_item.mutation.graphql'; import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; -import { availableWorkItemsResponse, updateWorkItemMutationResponse } from '../../mock_data'; +import { + availableWorkItemsResponse, + createWorkItemMutationResponse, + updateWorkItemMutationResponse, +} from '../../mock_data'; Vue.use(VueApollo); @@ -15,12 +20,14 @@ describe('WorkItemLinksForm', () => { let wrapper; const updateMutationResolver = jest.fn().mockResolvedValue(updateWorkItemMutationResponse); + const createMutationResolver = jest.fn().mockResolvedValue(createWorkItemMutationResponse); const createComponent = async ({ listResponse = availableWorkItemsResponse } = {}) => { wrapper = shallowMountExtended(WorkItemLinksForm, { apolloProvider: createMockApollo([ [projectWorkItemsQuery, jest.fn().mockResolvedValue(listResponse)], [updateWorkItemMutation, updateMutationResolver], + [createWorkItemMutation, createMutationResolver], ]), propsData: { issuableGid: 'gid://gitlab/WorkItem/1' }, provide: { @@ -33,6 +40,7 @@ describe('WorkItemLinksForm', () => { const findForm = () => wrapper.findComponent(GlForm); const findCombobox = () => wrapper.findComponent(GlFormCombobox); + const findInput = () => wrapper.findComponent(GlFormInput); const findAddChildButton = () => wrapper.findByTestId('add-child-button'); beforeEach(async () => { @@ -47,19 +55,41 @@ describe('WorkItemLinksForm', () => { expect(findForm().exists()).toBe(true); }); - it('passes available work items as prop when typing in combobox', async () => { - findCombobox().vm.$emit('input', 'Task'); - await waitForPromises(); + it('creates child task', async () => { + findInput().vm.$emit('input', 'Create task test'); - expect(findCombobox().exists()).toBe(true); - expect(findCombobox().props('tokenList').length).toBe(2); + findForm().vm.$emit('submit', { + preventDefault: jest.fn(), + }); + await waitForPromises(); + expect(createMutationResolver).toHaveBeenCalled(); }); - it('selects and add child', async () => { + // Follow up issue to turn this functionality back on https://gitlab.com/gitlab-org/gitlab/-/issues/368757 + // eslint-disable-next-line jest/no-disabled-tests + it.skip('selects and add child', async () => { findCombobox().vm.$emit('input', availableWorkItemsResponse.data.workspace.workItems.edges[0]); findAddChildButton().vm.$emit('click'); await waitForPromises(); expect(updateMutationResolver).toHaveBeenCalled(); }); + + // eslint-disable-next-line jest/no-disabled-tests + describe.skip('when typing in combobox', () => { + beforeEach(async () => { + findCombobox().vm.$emit('input', 'Task'); + await waitForPromises(); + await jest.runOnlyPendingTimers(); + }); + + it('passes available work items as prop', () => { + expect(findCombobox().exists()).toBe(true); + expect(findCombobox().props('tokenList').length).toBe(2); + }); + + it('passes action to create task', () => { + expect(findCombobox().props('actionList').length).toBe(1); + }); + }); }); diff --git a/spec/frontend/work_items/mock_data.js b/spec/frontend/work_items/mock_data.js index 7232d588add..05ca66d2523 100644 --- a/spec/frontend/work_items/mock_data.js +++ b/spec/frontend/work_items/mock_data.js @@ -219,6 +219,7 @@ export const createWorkItemMutationResponse = { }, widgets: [], }, + errors: [], }, }, }; diff --git a/spec/lib/gitlab/git/branch_spec.rb b/spec/lib/gitlab/git/branch_spec.rb index 97cd4777b4d..feaa1f6595c 100644 --- a/spec/lib/gitlab/git/branch_spec.rb +++ b/spec/lib/gitlab/git/branch_spec.rb @@ -2,8 +2,9 @@ require "spec_helper" -RSpec.describe Gitlab::Git::Branch, :seed_helper do - let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') } +RSpec.describe Gitlab::Git::Branch do + let(:project) { create(:project, :repository) } + let(:repository) { project.repository.raw } subject { repository.branches } @@ -54,14 +55,14 @@ RSpec.describe Gitlab::Git::Branch, :seed_helper do describe '#size' do subject { super().size } - it { is_expected.to eq(SeedRepo::Repo::BRANCHES.size) } + it { is_expected.to eq(TestEnv::BRANCH_SHA.size) } end describe 'first branch' do let(:branch) { repository.branches.first } - it { expect(branch.name).to eq(SeedRepo::Repo::BRANCHES.first) } - it { expect(branch.dereferenced_target.sha).to eq("0b4bc9a49b562e85de7cc9e834518ea6828729b9") } + it { expect(branch.name).to eq(TestEnv::BRANCH_SHA.keys.min) } + it { expect(branch.dereferenced_target.sha).to start_with(TestEnv::BRANCH_SHA[TestEnv::BRANCH_SHA.keys.min]) } end describe 'master branch' do @@ -69,14 +70,10 @@ RSpec.describe Gitlab::Git::Branch, :seed_helper do repository.branches.find { |branch| branch.name == 'master' } end - it { expect(branch.dereferenced_target.sha).to eq(SeedRepo::LastCommit::ID) } + it { expect(branch.dereferenced_target.sha).to start_with(TestEnv::BRANCH_SHA['master']) } end context 'with active, stale and future branches' do - let(:repository) do - Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '', 'group/project') - end - let(:user) { create(:user) } let(:stale_sha) { travel_to(Gitlab::Git::Branch::STALE_BRANCH_THRESHOLD.ago - 5.days) { create_commit } } let(:active_sha) { travel_to(Gitlab::Git::Branch::STALE_BRANCH_THRESHOLD.ago + 5.days) { create_commit } } @@ -88,10 +85,6 @@ RSpec.describe Gitlab::Git::Branch, :seed_helper do repository.create_branch('future-1', future_sha) end - after do - ensure_seeds - end - describe 'examine if the branch is active or stale' do let(:stale_branch) { repository.find_branch('stale-1') } let(:active_branch) { repository.find_branch('active-1') } @@ -117,8 +110,6 @@ RSpec.describe Gitlab::Git::Branch, :seed_helper do end end - it { expect(repository.branches.size).to eq(SeedRepo::Repo::BRANCHES.size) } - def create_commit repository.multi_action( user, diff --git a/spec/lib/gitlab/import_export/decompressed_archive_size_validator_spec.rb b/spec/lib/gitlab/import_export/decompressed_archive_size_validator_spec.rb index dea584e5019..9af72cc0dea 100644 --- a/spec/lib/gitlab/import_export/decompressed_archive_size_validator_spec.rb +++ b/spec/lib/gitlab/import_export/decompressed_archive_size_validator_spec.rb @@ -51,10 +51,11 @@ RSpec.describe Gitlab::ImportExport::DecompressedArchiveSizeValidator do shared_examples 'logs raised exception and terminates validator process group' do let(:std) { double(:std, close: nil, value: nil) } let(:wait_thr) { double } + let(:wait_threads) { [wait_thr, wait_thr] } before do allow(Process).to receive(:getpgid).and_return(2) - allow(Open3).to receive(:popen3).and_return([std, std, std, wait_thr]) + allow(Open3).to receive(:pipeline_r).and_return([std, wait_threads]) allow(wait_thr).to receive(:[]).with(:pid).and_return(1) allow(wait_thr).to receive(:value).and_raise(exception) end @@ -67,7 +68,7 @@ RSpec.describe Gitlab::ImportExport::DecompressedArchiveSizeValidator do import_upload_archive_size: File.size(filepath), message: error_message ) - expect(Process).to receive(:kill).with(-1, 2) + expect(Process).to receive(:kill).with(-1, 2).twice expect(subject.valid?).to eq(false) end end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 4531ca713f0..83ec4a5585d 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -3390,6 +3390,13 @@ RSpec.describe Group do end end + describe '#work_items_create_from_markdown_feature_flag_enabled?' do + it_behaves_like 'checks self and root ancestor feature flag' do + let(:feature_flag) { :work_items_create_from_markdown } + let(:feature_flag_method) { :work_items_create_from_markdown_feature_flag_enabled? } + end + end + describe 'group shares' do let!(:sub_group) { create(:group, parent: group) } let!(:sub_sub_group) { create(:group, parent: sub_group) } diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index fb6fc01ed88..7870326c29a 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -8281,6 +8281,16 @@ RSpec.describe Project, factory_default: :keep do end end + describe '#work_items_create_from_markdown_feature_flag_enabled?' do + let_it_be(:group_project) { create(:project, :in_subgroup) } + + it_behaves_like 'checks parent group feature flag' do + let(:feature_flag_method) { :work_items_create_from_markdown_feature_flag_enabled? } + let(:feature_flag) { :work_items_create_from_markdown } + let(:subject_project) { group_project } + end + end + describe 'serialization' do let(:object) { build(:project) } diff --git a/spec/serializers/environment_serializer_spec.rb b/spec/serializers/environment_serializer_spec.rb index 05644dad151..01d1e47b5bb 100644 --- a/spec/serializers/environment_serializer_spec.rb +++ b/spec/serializers/environment_serializer_spec.rb @@ -101,6 +101,37 @@ RSpec.describe EnvironmentSerializer do expect(subject.third[:latest][:environment_type]).to be_nil end end + + context 'when folders and standalone environments share the same name' do + before do + create(:environment, project: project, name: 'staging/my-review-1') + create(:environment, project: project, name: 'staging/my-review-2') + create(:environment, project: project, name: 'production/my-review-3') + create(:environment, project: project, name: 'staging') + create(:environment, project: project, name: 'testing') + end + + it 'does not group standalone environments with folders that have the same name' do + expect(subject.count).to eq 4 + + expect(subject.first[:name]).to eq 'production' + expect(subject.first[:size]).to eq 1 + expect(subject.first[:latest][:name]).to eq 'production/my-review-3' + expect(subject.first[:latest][:environment_type]).to eq 'production' + expect(subject.second[:name]).to eq 'staging' + expect(subject.second[:size]).to eq 1 + expect(subject.second[:latest][:name]).to eq 'staging' + expect(subject.second[:latest][:environment_type]).to be_nil + expect(subject.third[:name]).to eq 'staging' + expect(subject.third[:size]).to eq 2 + expect(subject.third[:latest][:name]).to eq 'staging/my-review-2' + expect(subject.third[:latest][:environment_type]).to eq 'staging' + expect(subject.fourth[:name]).to eq 'testing' + expect(subject.fourth[:size]).to eq 1 + expect(subject.fourth[:latest][:name]).to eq 'testing' + expect(subject.fourth[:latest][:environment_type]).to be_nil + end + end end context 'when used with pagination' do diff --git a/spec/support/shared_contexts/features/integrations/integrations_shared_context.rb b/spec/support/shared_contexts/features/integrations/integrations_shared_context.rb index 255c4e6f882..ca2fe8a6c54 100644 --- a/spec/support/shared_contexts/features/integrations/integrations_shared_context.rb +++ b/spec/support/shared_contexts/features/integrations/integrations_shared_context.rb @@ -66,7 +66,7 @@ Integration.available_integration_names.each do |integration| hash.merge!(k => 'foo@bar.com') elsif (integration == 'slack' || integration == 'mattermost') && k == :labels_to_be_notified_behavior hash.merge!(k => "match_any") - elsif integration == 'campfire' && k = :room + elsif integration == 'campfire' && k == :room hash.merge!(k => '1234') else hash.merge!(k => "someword") |