diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-16 15:08:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-16 15:08:40 +0300 |
commit | d43cb0f90723230c4aa617cb17a0cb6fb099f47e (patch) | |
tree | a8116eeba909c07909ccc030e8d40ab40d198aa3 /spec | |
parent | c8278708638ed998a8ecfeac26e7d9561b6125f8 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/import/bulk_imports_controller_spec.rb | 33 | ||||
-rw-r--r-- | spec/frontend/import_entities/import_groups/components/import_table_spec.js | 24 |
2 files changed, 54 insertions, 3 deletions
diff --git a/spec/controllers/import/bulk_imports_controller_spec.rb b/spec/controllers/import/bulk_imports_controller_spec.rb index a7089005abf..7177c8c10a6 100644 --- a/spec/controllers/import/bulk_imports_controller_spec.rb +++ b/spec/controllers/import/bulk_imports_controller_spec.rb @@ -48,15 +48,25 @@ RSpec.describe Import::BulkImportsController do expect(session[:bulk_import_gitlab_access_token]).to eq(token) expect(controller).to redirect_to(status_import_bulk_imports_url) end + + it 'passes namespace_id to status' do + namespace_id = 5 + token = 'token' + url = 'https://gitlab.example' + + post :configure, params: { bulk_import_gitlab_access_token: token, bulk_import_gitlab_url: url, namespace_id: namespace_id } + + expect(controller).to redirect_to(status_import_bulk_imports_url(namespace_id: namespace_id)) + end end describe 'GET status' do - def get_status(params_override = {}) + def get_status(params_override = {}, format = :json) params = { page: 1, per_page: 20, filter: '' }.merge(params_override) get :status, params: params, - format: :json, + format: format, session: { bulk_import_gitlab_url: 'https://gitlab.example.com', bulk_import_gitlab_access_token: 'demo-pat' @@ -169,6 +179,25 @@ RSpec.describe Import::BulkImportsController do end end end + + context 'when namespace_id is provided' do + let_it_be(:group) { create(:group) } + + it 'renders 404 if user does not have access to namespace' do + get_status({ namespace_id: group.id }, :html) + + expect(response).to have_gitlab_http_status(:not_found) + end + + it 'passes namespace to template' do + group.add_owner(user) + + get_status({ namespace_id: group.id }, :html) + + expect(response).to have_gitlab_http_status(:ok) + expect(assigns(:namespace)).to eq(group) + end + end end context 'when connection error occurs' do diff --git a/spec/frontend/import_entities/import_groups/components/import_table_spec.js b/spec/frontend/import_entities/import_groups/components/import_table_spec.js index 24881237b85..cdc508a0033 100644 --- a/spec/frontend/import_entities/import_groups/components/import_table_spec.js +++ b/spec/frontend/import_entities/import_groups/components/import_table_spec.js @@ -56,7 +56,7 @@ describe('import table', () => { const selectRow = (idx) => wrapper.findAll('tbody td input[type=checkbox]').at(idx).setChecked(true); - const createComponent = ({ bulkImportSourceGroups, importGroups }) => { + const createComponent = ({ bulkImportSourceGroups, importGroups, defaultTargetNamespace }) => { apolloProvider = createMockApollo([], { Query: { availableNamespaces: () => availableNamespacesFixture, @@ -73,6 +73,7 @@ describe('import table', () => { jobsPath: '/fake_job_path', sourceUrl: SOURCE_URL, historyPath: '/fake_history_path', + defaultTargetNamespace, }, apolloProvider, }); @@ -165,6 +166,27 @@ describe('import table', () => { expect(targetNamespaceDropdownButton.text()).toBe('No parent'); }); + it('respects default namespace if provided', async () => { + const targetNamespace = availableNamespacesFixture[1]; + + createComponent({ + bulkImportSourceGroups: () => ({ + nodes: FAKE_GROUPS, + pageInfo: FAKE_PAGE_INFO, + versionValidation: FAKE_VERSION_VALIDATION, + }), + defaultTargetNamespace: targetNamespace.id, + }); + + await waitForPromises(); + + const firstRow = wrapper.find('tbody tr'); + const targetNamespaceDropdownButton = findTargetNamespaceDropdown(firstRow).find( + '[aria-haspopup]', + ); + expect(targetNamespaceDropdownButton.text()).toBe(targetNamespace.fullPath); + }); + it('does not render status string when result list is empty', async () => { createComponent({ bulkImportSourceGroups: jest.fn().mockResolvedValue({ |