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-20 00:08:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-20 00:08:49 +0300
commit1cd61065a0d86b492be5086906429ac5956e3672 (patch)
treebab228469be487451d64eec4a55820501007c8b4 /spec
parentd1be3e6f776e1c77976537548c1daa9af2fb2650 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/ci/pipeline_editor/components/ui/pipeline_editor_empty_state_spec.js63
-rw-r--r--spec/helpers/ci/pipeline_editor_helper_spec.rb2
-rw-r--r--spec/lib/gitlab/import_export/project/relation_saver_spec.rb20
-rw-r--r--spec/services/projects/import_export/relation_export_service_spec.rb3
-rw-r--r--spec/support/shared_examples/workers/project_export_shared_examples.rb6
-rw-r--r--spec/workers/projects/import_export/create_relation_exports_worker_spec.rb2
-rw-r--r--spec/workers/projects/import_export/relation_export_worker_spec.rb11
7 files changed, 56 insertions, 51 deletions
diff --git a/spec/frontend/ci/pipeline_editor/components/ui/pipeline_editor_empty_state_spec.js b/spec/frontend/ci/pipeline_editor/components/ui/pipeline_editor_empty_state_spec.js
index e636a89c6d9..4bb6a60a141 100644
--- a/spec/frontend/ci/pipeline_editor/components/ui/pipeline_editor_empty_state_spec.js
+++ b/spec/frontend/ci/pipeline_editor/components/ui/pipeline_editor_empty_state_spec.js
@@ -1,27 +1,27 @@
-import { GlButton, GlSprintf } from '@gitlab/ui';
+import { GlButton, GlSprintf, GlEmptyState } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import PipelineEditorFileNav from '~/ci/pipeline_editor/components/file_nav/pipeline_editor_file_nav.vue';
import PipelineEditorEmptyState from '~/ci/pipeline_editor/components/ui/pipeline_editor_empty_state.vue';
+const emptyStateIllustrationPath = 'illustrations/empty-state/empty-pipeline-md.svg';
+
describe('Pipeline editor empty state', () => {
let wrapper;
const defaultProvide = {
- emptyStateIllustrationPath: 'my/svg/path',
+ emptyStateIllustrationPath,
usesExternalConfig: false,
};
const createComponent = ({ provide } = {}) => {
wrapper = shallowMount(PipelineEditorEmptyState, {
provide: { ...defaultProvide, ...provide },
+ stubs: { GlSprintf },
});
};
const findFileNav = () => wrapper.findComponent(PipelineEditorFileNav);
- const findSvgImage = () => wrapper.find('img');
- const findTitle = () => wrapper.find('h1');
- const findExternalCiInstructions = () => wrapper.find('p');
- const findConfirmButton = () => wrapper.findComponent(GlButton);
- const findDescription = () => wrapper.findComponent(GlSprintf);
+ const findEmptyState = () => wrapper.findComponent(GlEmptyState);
+ const findConfirmButton = () => findEmptyState().findComponent(GlButton);
describe('when project uses an external CI config', () => {
beforeEach(() => {
@@ -30,22 +30,13 @@ describe('Pipeline editor empty state', () => {
});
});
- it('renders an svg image', () => {
- expect(findSvgImage().exists()).toBe(true);
- });
-
- it('renders the correct title and instructions', () => {
- expect(findTitle().exists()).toBe(true);
- expect(findExternalCiInstructions().exists()).toBe(true);
-
- expect(findExternalCiInstructions().html()).toContain(
- wrapper.vm.$options.i18n.externalCiInstructions,
- );
- expect(findTitle().text()).toBe(wrapper.vm.$options.i18n.externalCiNote);
- });
-
- it('does not render the CTA button', () => {
- expect(findConfirmButton().exists()).toBe(false);
+ it('renders an empty state', () => {
+ expect(findEmptyState().props()).toMatchObject({
+ description: wrapper.vm.$options.i18n.externalCiInstructions,
+ primaryButtonText: null,
+ svgPath: emptyStateIllustrationPath,
+ title: "This project's pipeline configuration is located outside this repository",
+ });
});
});
@@ -54,27 +45,23 @@ describe('Pipeline editor empty state', () => {
createComponent();
});
- it('renders an svg image', () => {
- expect(findSvgImage().exists()).toBe(true);
+ it('renders the file nav', () => {
+ expect(findFileNav().exists()).toBe(true);
});
- it('renders a title', () => {
- expect(findTitle().exists()).toBe(true);
- expect(findTitle().text()).toBe(wrapper.vm.$options.i18n.title);
+ it('renders an empty state', () => {
+ expect(findEmptyState().exists()).toBe(true);
});
- it('renders a description', () => {
- expect(findDescription().exists()).toBe(true);
- expect(findDescription().html()).toContain(wrapper.vm.$options.i18n.body);
+ it('renders correct title and illustration', () => {
+ expect(findEmptyState().props('svgPath')).toBe(emptyStateIllustrationPath);
+ expect(findEmptyState().props('title')).toBe('Optimize your workflow with CI/CD Pipelines');
});
- it('renders the file nav', () => {
- expect(findFileNav().exists()).toBe(true);
- });
-
- it('renders a CTA button', () => {
- expect(findConfirmButton().exists()).toBe(true);
- expect(findConfirmButton().text()).toBe(wrapper.vm.$options.i18n.btnText);
+ it('renders the correct instructions', () => {
+ expect(findEmptyState().text()).toContain(
+ 'Create a new .gitlab-ci.yml file at the root of the repository to get started.',
+ );
});
it('emits an event when clicking on the CTA', async () => {
diff --git a/spec/helpers/ci/pipeline_editor_helper_spec.rb b/spec/helpers/ci/pipeline_editor_helper_spec.rb
index 7a80aff27c1..22ba253c60b 100644
--- a/spec/helpers/ci/pipeline_editor_helper_spec.rb
+++ b/spec/helpers/ci/pipeline_editor_helper_spec.rb
@@ -57,7 +57,7 @@ RSpec.describe Ci::PipelineEditorHelper, feature_category: :pipeline_composition
allow(helper)
.to receive(:image_path)
- .with('illustrations/empty-state/empty-dag-md.svg')
+ .with('illustrations/empty-state/empty-pipeline-md.svg')
.and_return('illustrations/empty.svg')
allow(helper)
diff --git a/spec/lib/gitlab/import_export/project/relation_saver_spec.rb b/spec/lib/gitlab/import_export/project/relation_saver_spec.rb
index 5032dd864bb..9d1977582a6 100644
--- a/spec/lib/gitlab/import_export/project/relation_saver_spec.rb
+++ b/spec/lib/gitlab/import_export/project/relation_saver_spec.rb
@@ -5,10 +5,14 @@ require 'spec_helper'
RSpec.describe Gitlab::ImportExport::Project::RelationSaver do
include ImportExport::CommonUtil
- subject(:relation_saver) { described_class.new(project: project, shared: shared, relation: relation) }
+ subject(:relation_saver) do
+ described_class.new(project: project, shared: shared, relation: relation, user: user, params: params)
+ end
let_it_be(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
+ let_it_be(:user) { create(:user) }
let_it_be(:project) { setup_project }
+ let(:params) { { description: 'An overridden description' } }
let(:relation) { Projects::ImportExport::RelationExport::ROOT_RELATION }
let(:shared) do
@@ -22,6 +26,16 @@ RSpec.describe Gitlab::ImportExport::Project::RelationSaver do
end
describe '#save' do
+ it 'uses the ImportExport presenter' do
+ expect(project).to receive(:present).with(
+ presenter_class: Projects::ImportExport::ProjectExportPresenter,
+ current_user: user,
+ override_description: params[:description]
+ )
+
+ relation_saver.save # rubocop:disable Rails/SaveBang -- Call RelationSaver's #save, not ActiveRecord
+ end
+
context 'when relation is the root node' do
let(:relation) { Projects::ImportExport::RelationExport::ROOT_RELATION }
@@ -29,14 +43,14 @@ RSpec.describe Gitlab::ImportExport::Project::RelationSaver do
relation_saver.save # rubocop:disable Rails/SaveBang
json = read_json(File.join(shared.export_path, 'tree', 'project.json'))
- expect(json).to include({ 'description' => 'Project description' })
+ expect(json).to include({ 'description' => params[:description] })
end
it 'serializes only allowed attributes' do
relation_saver.save # rubocop:disable Rails/SaveBang
json = read_json(File.join(shared.export_path, 'tree', 'project.json'))
- expect(json).to include({ 'description' => 'Project description' })
+ expect(json).to include({ 'description' => params[:description] })
expect(json.keys).not_to include('name')
end
diff --git a/spec/services/projects/import_export/relation_export_service_spec.rb b/spec/services/projects/import_export/relation_export_service_spec.rb
index 4b44a37b299..d8810126bf3 100644
--- a/spec/services/projects/import_export/relation_export_service_spec.rb
+++ b/spec/services/projects/import_export/relation_export_service_spec.rb
@@ -5,9 +5,10 @@ require 'spec_helper'
RSpec.describe Projects::ImportExport::RelationExportService, feature_category: :importers do
using RSpec::Parameterized::TableSyntax
- subject(:service) { described_class.new(relation_export, 'jid') }
+ subject(:service) { described_class.new(relation_export, user, 'jid') }
let_it_be(:project_export_job) { create(:project_export_job) }
+ let_it_be(:user) { create(:user) }
let_it_be(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let_it_be(:archive_path) { "#{Dir.tmpdir}/project_archive_spec" }
diff --git a/spec/support/shared_examples/workers/project_export_shared_examples.rb b/spec/support/shared_examples/workers/project_export_shared_examples.rb
index 175ef9bd012..4210f39bef5 100644
--- a/spec/support/shared_examples/workers/project_export_shared_examples.rb
+++ b/spec/support/shared_examples/workers/project_export_shared_examples.rb
@@ -13,11 +13,13 @@ RSpec.shared_examples 'export worker' do
context 'when it succeeds' do
it 'calls the ExportService' do
- expect_next_instance_of(::Projects::ImportExport::ExportService) do |service|
+ params = { 'description' => 'An overridden description' }
+
+ expect_next_instance_of(::Projects::ImportExport::ExportService, project, user, params.symbolize_keys!) do |service|
expect(service).to receive(:execute)
end
- subject.perform(user.id, project.id, { 'klass' => 'Gitlab::ImportExport::AfterExportStrategies::DownloadNotificationStrategy' })
+ subject.perform(user.id, project.id, { 'klass' => 'Gitlab::ImportExport::AfterExportStrategies::DownloadNotificationStrategy' }, params)
end
context 'export job' do
diff --git a/spec/workers/projects/import_export/create_relation_exports_worker_spec.rb b/spec/workers/projects/import_export/create_relation_exports_worker_spec.rb
index 2ff91150fda..f3696c69f31 100644
--- a/spec/workers/projects/import_export/create_relation_exports_worker_spec.rb
+++ b/spec/workers/projects/import_export/create_relation_exports_worker_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe Projects::ImportExport::CreateRelationExportsWorker, feature_category: :importers do
- let_it_be(:user) { build_stubbed(:user) }
+ let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let(:after_export_strategy) { {} }
diff --git a/spec/workers/projects/import_export/relation_export_worker_spec.rb b/spec/workers/projects/import_export/relation_export_worker_spec.rb
index 16ee73040b1..a5ddb85f4e3 100644
--- a/spec/workers/projects/import_export/relation_export_worker_spec.rb
+++ b/spec/workers/projects/import_export/relation_export_worker_spec.rb
@@ -4,7 +4,8 @@ require 'spec_helper'
RSpec.describe Projects::ImportExport::RelationExportWorker, type: :worker, feature_category: :importers do
let(:project_relation_export) { create(:project_relation_export) }
- let(:job_args) { [project_relation_export.id] }
+ let(:user) { create(:user) }
+ let(:job_args) { [project_relation_export.id, user.id] }
it_behaves_like 'an idempotent worker'
@@ -17,7 +18,7 @@ RSpec.describe Projects::ImportExport::RelationExportWorker, type: :worker, feat
expect(service).to receive(:execute)
end
- worker.perform(project_relation_export.id)
+ worker.perform(*job_args)
end
end
@@ -29,7 +30,7 @@ RSpec.describe Projects::ImportExport::RelationExportWorker, type: :worker, feat
expect(service).to receive(:execute)
end
- worker.perform(project_relation_export.id)
+ worker.perform(*job_args)
expect(project_relation_export.reload.queued?).to eq(true)
end
@@ -41,13 +42,13 @@ RSpec.describe Projects::ImportExport::RelationExportWorker, type: :worker, feat
it 'does not export the relation' do
expect(Projects::ImportExport::RelationExportService).not_to receive(:new)
- worker.perform(project_relation_export.id)
+ worker.perform(*job_args)
end
end
end
describe '.sidekiq_retries_exhausted' do
- let(:job) { { 'args' => [project_relation_export.id], 'error_message' => 'Error message' } }
+ let(:job) { { 'args' => job_args, 'error_message' => 'Error message' } }
it 'sets relation export status to `failed`' do
described_class.sidekiq_retries_exhausted_block.call(job)