diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-05 21:09:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-05 21:09:06 +0300 |
commit | 184b3d4a2101ec9991b2bed1cd3fa759afb5a6c4 (patch) | |
tree | f9fd322be8ff130e2f0a1ae50d3da5ecc14bff43 /spec | |
parent | 27d47e40e196e46f0f027f0a2e3e4debe293ba39 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
4 files changed, 69 insertions, 28 deletions
diff --git a/spec/frontend/work_items/components/work_item_links/work_item_link_child_spec.js b/spec/frontend/work_items/components/work_item_links/work_item_link_child_spec.js index 803ff950cbe..a624bbe8567 100644 --- a/spec/frontend/work_items/components/work_item_links/work_item_link_child_spec.js +++ b/spec/frontend/work_items/components/work_item_links/work_item_link_child_spec.js @@ -93,8 +93,6 @@ describe('WorkItemLinkChild', () => { expect(findWorkItemLinkChildContents().props()).toEqual({ childItem: workItemObjectiveWithChild, canUpdate: true, - parentWorkItemId: 'gid://gitlab/WorkItem/2', - workItemType: 'Objective', childPath: '/gitlab-org/gitlab-test/-/work_items/12', }); }); diff --git a/spec/frontend/work_items/components/work_item_relationships/work_item_relationships_spec.js b/spec/frontend/work_items/components/work_item_relationships/work_item_relationships_spec.js new file mode 100644 index 00000000000..18d13aa251e --- /dev/null +++ b/spec/frontend/work_items/components/work_item_relationships/work_item_relationships_spec.js @@ -0,0 +1,25 @@ +import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import waitForPromises from 'helpers/wait_for_promises'; +import WorkItemRelationships from '~/work_items/components/work_item_relationships/work_item_relationships.vue'; + +describe('WorkItemRelationships', () => { + let wrapper; + + const createComponent = async () => { + wrapper = shallowMountExtended(WorkItemRelationships, { + propsData: { + workItem: {}, + workItemIid: '1', + workItemFullpath: 'gitlab/path', + }, + }); + + await waitForPromises(); + }; + + it('renders the component', () => { + createComponent(); + + expect(wrapper.find('.work-item-relationships').exists()).toBe(true); + }); +}); diff --git a/spec/frontend/work_items/utils_spec.js b/spec/frontend/work_items/utils_spec.js index aa24b80cf08..8a49140119d 100644 --- a/spec/frontend/work_items/utils_spec.js +++ b/spec/frontend/work_items/utils_spec.js @@ -1,4 +1,4 @@ -import { autocompleteDataSources, markdownPreviewPath } from '~/work_items/utils'; +import { autocompleteDataSources, markdownPreviewPath, workItemPath } from '~/work_items/utils'; describe('autocompleteDataSources', () => { beforeEach(() => { @@ -25,3 +25,14 @@ describe('markdownPreviewPath', () => { ); }); }); + +describe('workItemPath', () => { + it('returns corrrect data sources', () => { + expect(workItemPath('project/group', '2')).toEqual('/project/group/-/work_items/2'); + }); + + it('returns corrrect data sources with relative url root', () => { + gon.relative_url_root = '/foobar'; + expect(workItemPath('project/group', '2')).toEqual('/foobar/project/group/-/work_items/2'); + }); +}); diff --git a/spec/lib/bulk_imports/projects/pipelines/references_pipeline_spec.rb b/spec/lib/bulk_imports/projects/pipelines/references_pipeline_spec.rb index 32becfa7467..8ab74905b8a 100644 --- a/spec/lib/bulk_imports/projects/pipelines/references_pipeline_spec.rb +++ b/spec/lib/bulk_imports/projects/pipelines/references_pipeline_spec.rb @@ -19,7 +19,7 @@ RSpec.describe BulkImports::Projects::Pipelines::ReferencesPipeline, feature_cat let_it_be(:tracker) { create(:bulk_import_tracker, entity: entity) } let_it_be(:context) { BulkImports::Pipeline::Context.new(tracker) } - let(:issue) { create(:issue, project: project, description: 'https://my.gitlab.com/source/full/path/-/issues/1 @old_username') } + let(:issue) { create(:issue, project: project, description: 'https://my.gitlab.com/source/full/path/-/issues/1') } let(:mr) do create( :merge_request, @@ -58,14 +58,37 @@ RSpec.describe BulkImports::Projects::Pipelines::ReferencesPipeline, feature_cat ) end + let(:username_system_note) do + create( + :note, + project: project, + system: true, + noteable: issue, + note: "mentioned in merge request created by @source_username", + note_html: 'empty' + ) + end + subject(:pipeline) { described_class.new(context) } before do project.add_owner(user) + + allow(Gitlab::Cache::Import::Caching) + .to receive(:values_from_hash) + .and_return({ + 'old_username' => 'new_username', + 'older_username' => 'newer_username', + 'source_username' => 'destination_username' + }) end def create_project_data - [issue, mr, issue_note, mr_note, system_note] + [issue, mr, issue_note, mr_note, system_note, username_system_note] + end + + def create_username_project_data + [username_system_note] end describe '#extract' do @@ -75,12 +98,14 @@ RSpec.describe BulkImports::Projects::Pipelines::ReferencesPipeline, feature_cat extracted_data = subject.extract(context) expect(extracted_data).to be_instance_of(BulkImports::Pipeline::ExtractedData) - expect(extracted_data.data).to contain_exactly(issue_note, mr, issue, mr_note) + expect(extracted_data.data).to contain_exactly(issue, mr, issue_note, system_note, username_system_note, mr_note) expect(system_note.note_html).not_to eq(old_note_html) expect(system_note.note_html) .to include("class=\"gfm gfm-merge_request\">!#{mr.iid}</a>") .and include(project.full_path.to_s) .and include("@old_username") + expect(username_system_note.note_html) + .to include("@source_username") end context 'when object body is nil' do @@ -95,22 +120,13 @@ RSpec.describe BulkImports::Projects::Pipelines::ReferencesPipeline, feature_cat end describe '#transform' do - before do - allow(Gitlab::Cache::Import::Caching) - .to receive(:values_from_hash) - .and_return({ - 'old_username' => 'new_username', - 'older_username' => 'newer_username', - 'source_username' => 'destination_username' - }) - end - it 'updates matching urls and usernames with new ones' do transformed_mr = subject.transform(context, mr) transformed_note = subject.transform(context, mr_note) transformed_issue = subject.transform(context, issue) transformed_issue_note = subject.transform(context, issue_note) transformed_system_note = subject.transform(context, system_note) + transformed_username_system_note = subject.transform(context, username_system_note) expected_url = URI('') expected_url.scheme = ::Gitlab.config.gitlab.https ? 'https' : 'http' @@ -118,16 +134,17 @@ RSpec.describe BulkImports::Projects::Pipelines::ReferencesPipeline, feature_cat expected_url.port = ::Gitlab.config.gitlab.port expected_url.path = "/#{project.full_path}/-/merge_requests/#{mr.iid}" - expect(transformed_issue.description).not_to include("@old_username") expect(transformed_issue_note.note).not_to include("@older_username") expect(transformed_mr.description).not_to include("@source_username") expect(transformed_system_note.note).not_to include("@old_username") + expect(transformed_username_system_note.note).not_to include("@source_username") + expect(transformed_issue.description).to eq('http://localhost:80/namespace1/project-1/-/issues/1') expect(transformed_mr.description).to eq("#{expected_url} @destination_username") expect(transformed_note.note).to eq("#{expected_url} @same_username") - expect(transformed_issue.description).to include("@new_username") expect(transformed_issue_note.note).to include("@newer_username and not_a@username") expect(transformed_system_note.note).to eq("mentioned in merge request !#{mr.iid} created by @new_username") + expect(transformed_username_system_note.note).to include("@destination_username") end context 'when object does not have reference or username' do @@ -176,16 +193,6 @@ RSpec.describe BulkImports::Projects::Pipelines::ReferencesPipeline, feature_cat end describe '#load' do - before do - allow(Gitlab::Cache::Import::Caching) - .to receive(:values_from_hash) - .and_return({ - 'old_username' => 'new_username', - 'older_username' => 'newer_username', - 'source_username' => 'destination_username' - }) - end - it 'saves the object when object body changed' do transformed_issue = subject.transform(context, issue) transformed_note = subject.transform(context, mr_note) |