diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 06:10:04 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 06:10:04 +0000 |
commit | 026ef03e77628461c98a1bb5270cc8d6281f8fdf (patch) | |
tree | fd023bfcda637f2edd436b746e1175f894970c35 /spec | |
parent | 514ada7cc9af49117d6cf63966925e21d137933e (diff) | |
download | gitlab-ce-026ef03e77628461c98a1bb5270cc8d6281f8fdf.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/groups_spec.rb | 2 | ||||
-rw-r--r-- | spec/frontend/fixtures/runner.rb | 14 | ||||
-rw-r--r-- | spec/frontend/runner/admin_runners/admin_runners_app_spec.js | 58 | ||||
-rw-r--r-- | spec/frontend/runner/components/cells/runner_actions_cell_spec.js | 4 | ||||
-rw-r--r-- | spec/frontend/runner/components/runner_delete_button_spec.js | 4 | ||||
-rw-r--r-- | spec/frontend/runner/components/runner_list_spec.js | 4 | ||||
-rw-r--r-- | spec/frontend/runner/components/runner_pause_button_spec.js | 4 | ||||
-rw-r--r-- | spec/frontend/runner/components/stat/runner_count_spec.js | 40 | ||||
-rw-r--r-- | spec/frontend/runner/group_runners/group_runners_app_spec.js | 48 | ||||
-rw-r--r-- | spec/frontend/runner/mock_data.js | 10 | ||||
-rw-r--r-- | spec/helpers/groups_helper_spec.rb | 4 | ||||
-rw-r--r-- | spec/helpers/storage_helper_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/terraform/modules/v1/packages_spec.rb | 70 | ||||
-rw-r--r-- | spec/services/work_items/create_service_spec.rb | 14 |
15 files changed, 179 insertions, 101 deletions
diff --git a/spec/features/groups_spec.rb b/spec/features/groups_spec.rb index 58443b66858..ece6167b193 100644 --- a/spec/features/groups_spec.rb +++ b/spec/features/groups_spec.rb @@ -22,7 +22,7 @@ RSpec.describe 'Group' do end describe 'as a non-admin' do - it 'creates a group and persists visibility radio selection', :js, :saas do + it 'creates a group and persists visibility radio selection', :js do stub_application_setting(default_group_visibility: :private) fill_in 'Group name', with: 'test-group' diff --git a/spec/frontend/fixtures/runner.rb b/spec/frontend/fixtures/runner.rb index 24c6a78d881..36281af0219 100644 --- a/spec/frontend/fixtures/runner.rb +++ b/spec/frontend/fixtures/runner.rb @@ -39,19 +39,19 @@ RSpec.describe 'Runner (JavaScript fixtures)' do end describe GraphQL::Query, type: :request do - admin_runners_query = 'list/admin_runners.query.graphql' + all_runners_query = 'list/all_runners.query.graphql' let_it_be(:query) do - get_graphql_query_as_string("#{query_path}#{admin_runners_query}") + get_graphql_query_as_string("#{query_path}#{all_runners_query}") end - it "#{fixtures_path}#{admin_runners_query}.json" do + it "#{fixtures_path}#{all_runners_query}.json" do post_graphql(query, current_user: admin, variables: {}) expect_graphql_errors_to_be_empty end - it "#{fixtures_path}#{admin_runners_query}.paginated.json" do + it "#{fixtures_path}#{all_runners_query}.paginated.json" do post_graphql(query, current_user: admin, variables: { first: 2 }) expect_graphql_errors_to_be_empty @@ -59,13 +59,13 @@ RSpec.describe 'Runner (JavaScript fixtures)' do end describe GraphQL::Query, type: :request do - admin_runners_count_query = 'list/admin_runners_count.query.graphql' + all_runners_count_query = 'list/all_runners_count.query.graphql' let_it_be(:query) do - get_graphql_query_as_string("#{query_path}#{admin_runners_count_query}") + get_graphql_query_as_string("#{query_path}#{all_runners_count_query}") end - it "#{fixtures_path}#{admin_runners_count_query}.json" do + it "#{fixtures_path}#{all_runners_count_query}.json" do post_graphql(query, current_user: admin, variables: {}) expect_graphql_errors_to_be_empty diff --git a/spec/frontend/runner/admin_runners/admin_runners_app_spec.js b/spec/frontend/runner/admin_runners/admin_runners_app_spec.js index 2d3f19fe12a..aa1aa723491 100644 --- a/spec/frontend/runner/admin_runners/admin_runners_app_spec.js +++ b/spec/frontend/runner/admin_runners/admin_runners_app_spec.js @@ -41,14 +41,14 @@ import { STATUS_STALE, RUNNER_PAGE_SIZE, } from '~/runner/constants'; -import adminRunnersQuery from 'ee_else_ce/runner/graphql/list/admin_runners.query.graphql'; -import adminRunnersCountQuery from '~/runner/graphql/list/admin_runners_count.query.graphql'; +import allRunnersQuery from 'ee_else_ce/runner/graphql/list/all_runners.query.graphql'; +import allRunnersCountQuery from '~/runner/graphql/list/all_runners_count.query.graphql'; import { captureException } from '~/runner/sentry_utils'; import { - runnersData, + allRunnersData, runnersCountData, - runnersDataPaginated, + allRunnersDataPaginated, onlineContactTimeoutSecs, staleTimeoutSecs, emptyStateSvgPath, @@ -56,11 +56,11 @@ import { } from '../mock_data'; const mockRegistrationToken = 'MOCK_REGISTRATION_TOKEN'; -const mockRunners = runnersData.data.runners.nodes; +const mockRunners = allRunnersData.data.runners.nodes; const mockRunnersCount = runnersCountData.data.runners.count; -const mockRunnersQuery = jest.fn(); -const mockRunnersCountQuery = jest.fn(); +const mockRunnersHandler = jest.fn(); +const mockRunnersCountHandler = jest.fn(); jest.mock('~/flash'); jest.mock('~/runner/sentry_utils'); @@ -96,8 +96,8 @@ describe('AdminRunnersApp', () => { ({ cacheConfig, localMutations } = createLocalState()); const handlers = [ - [adminRunnersQuery, mockRunnersQuery], - [adminRunnersCountQuery, mockRunnersCountQuery], + [allRunnersQuery, mockRunnersHandler], + [allRunnersCountQuery, mockRunnersCountHandler], ]; wrapper = mountFn(AdminRunnersApp, { @@ -121,13 +121,13 @@ describe('AdminRunnersApp', () => { }; beforeEach(() => { - mockRunnersQuery.mockResolvedValue(runnersData); - mockRunnersCountQuery.mockResolvedValue(runnersCountData); + mockRunnersHandler.mockResolvedValue(allRunnersData); + mockRunnersCountHandler.mockResolvedValue(runnersCountData); }); afterEach(() => { - mockRunnersQuery.mockReset(); - mockRunnersCountQuery.mockReset(); + mockRunnersHandler.mockReset(); + mockRunnersCountHandler.mockReset(); wrapper.destroy(); }); @@ -149,9 +149,9 @@ describe('AdminRunnersApp', () => { it('shows total runner counts', async () => { await createComponent({ mountFn: mountExtended }); - expect(mockRunnersCountQuery).toHaveBeenCalledWith({ status: STATUS_ONLINE }); - expect(mockRunnersCountQuery).toHaveBeenCalledWith({ status: STATUS_OFFLINE }); - expect(mockRunnersCountQuery).toHaveBeenCalledWith({ status: STATUS_STALE }); + expect(mockRunnersCountHandler).toHaveBeenCalledWith({ status: STATUS_ONLINE }); + expect(mockRunnersCountHandler).toHaveBeenCalledWith({ status: STATUS_OFFLINE }); + expect(mockRunnersCountHandler).toHaveBeenCalledWith({ status: STATUS_STALE }); expect(findRunnerStats().text()).toContain( `${s__('Runners|Online runners')} ${mockRunnersCount}`, @@ -197,7 +197,7 @@ describe('AdminRunnersApp', () => { it('requests the runners with no filters', async () => { await createComponent(); - expect(mockRunnersQuery).toHaveBeenLastCalledWith({ + expect(mockRunnersHandler).toHaveBeenLastCalledWith({ status: undefined, type: undefined, sort: DEFAULT_SORT, @@ -234,7 +234,7 @@ describe('AdminRunnersApp', () => { const FILTERED_COUNT_QUERIES = 4; // Smart queries that display a count of runners in tabs beforeEach(async () => { - mockRunnersCountQuery.mockClear(); + mockRunnersCountHandler.mockClear(); await createComponent({ mountFn: mountExtended }); showToast = jest.spyOn(wrapper.vm.$root.$toast, 'show'); @@ -248,11 +248,11 @@ describe('AdminRunnersApp', () => { }); it('When runner is paused or unpaused, some data is refetched', async () => { - expect(mockRunnersCountQuery).toHaveBeenCalledTimes(COUNT_QUERIES); + expect(mockRunnersCountHandler).toHaveBeenCalledTimes(COUNT_QUERIES); findRunnerActionsCell().vm.$emit('toggledPaused'); - expect(mockRunnersCountQuery).toHaveBeenCalledTimes(COUNT_QUERIES + FILTERED_COUNT_QUERIES); + expect(mockRunnersCountHandler).toHaveBeenCalledTimes(COUNT_QUERIES + FILTERED_COUNT_QUERIES); expect(showToast).toHaveBeenCalledTimes(0); }); @@ -289,7 +289,7 @@ describe('AdminRunnersApp', () => { }); it('requests the runners with filter parameters', () => { - expect(mockRunnersQuery).toHaveBeenLastCalledWith({ + expect(mockRunnersHandler).toHaveBeenLastCalledWith({ status: STATUS_ONLINE, type: INSTANCE_TYPE, tagList: ['tag1'], @@ -299,7 +299,7 @@ describe('AdminRunnersApp', () => { }); it('fetches count results for requested status', () => { - expect(mockRunnersCountQuery).toHaveBeenCalledWith({ + expect(mockRunnersCountHandler).toHaveBeenCalledWith({ type: INSTANCE_TYPE, status: STATUS_ONLINE, tagList: ['tag1'], @@ -334,7 +334,7 @@ describe('AdminRunnersApp', () => { }); it('requests the runners with filters', () => { - expect(mockRunnersQuery).toHaveBeenLastCalledWith({ + expect(mockRunnersHandler).toHaveBeenLastCalledWith({ status: STATUS_ONLINE, tagList: ['tag1'], sort: CREATED_ASC, @@ -343,7 +343,7 @@ describe('AdminRunnersApp', () => { }); it('fetches count results for requested status', () => { - expect(mockRunnersCountQuery).toHaveBeenCalledWith({ + expect(mockRunnersCountHandler).toHaveBeenCalledWith({ tagList: ['tag1'], status: STATUS_ONLINE, }); @@ -392,7 +392,7 @@ describe('AdminRunnersApp', () => { describe('when no runners are found', () => { beforeEach(async () => { - mockRunnersQuery.mockResolvedValue({ + mockRunnersHandler.mockResolvedValue({ data: { runners: { nodes: [] }, }, @@ -423,7 +423,7 @@ describe('AdminRunnersApp', () => { describe('when runners query fails', () => { beforeEach(async () => { - mockRunnersQuery.mockRejectedValue(new Error('Error!')); + mockRunnersHandler.mockRejectedValue(new Error('Error!')); await createComponent(); }); @@ -441,7 +441,7 @@ describe('AdminRunnersApp', () => { describe('Pagination', () => { beforeEach(async () => { - mockRunnersQuery.mockResolvedValue(runnersDataPaginated); + mockRunnersHandler.mockResolvedValue(allRunnersDataPaginated); await createComponent({ mountFn: mountExtended }); }); @@ -449,10 +449,10 @@ describe('AdminRunnersApp', () => { it('navigates to the next page', async () => { await findRunnerPaginationNext().trigger('click'); - expect(mockRunnersQuery).toHaveBeenLastCalledWith({ + expect(mockRunnersHandler).toHaveBeenLastCalledWith({ sort: CREATED_DESC, first: RUNNER_PAGE_SIZE, - after: runnersDataPaginated.data.runners.pageInfo.endCursor, + after: allRunnersDataPaginated.data.runners.pageInfo.endCursor, }); }); }); diff --git a/spec/frontend/runner/components/cells/runner_actions_cell_spec.js b/spec/frontend/runner/components/cells/runner_actions_cell_spec.js index 7a949cb6505..ffd6f126627 100644 --- a/spec/frontend/runner/components/cells/runner_actions_cell_spec.js +++ b/spec/frontend/runner/components/cells/runner_actions_cell_spec.js @@ -4,9 +4,9 @@ import RunnerActionsCell from '~/runner/components/cells/runner_actions_cell.vue import RunnerPauseButton from '~/runner/components/runner_pause_button.vue'; import RunnerEditButton from '~/runner/components/runner_edit_button.vue'; import RunnerDeleteButton from '~/runner/components/runner_delete_button.vue'; -import { runnersData } from '../../mock_data'; +import { allRunnersData } from '../../mock_data'; -const mockRunner = runnersData.data.runners.nodes[0]; +const mockRunner = allRunnersData.data.runners.nodes[0]; describe('RunnerActionsCell', () => { let wrapper; diff --git a/spec/frontend/runner/components/runner_delete_button_spec.js b/spec/frontend/runner/components/runner_delete_button_spec.js index b11c749d0a7..52fe803c536 100644 --- a/spec/frontend/runner/components/runner_delete_button_spec.js +++ b/spec/frontend/runner/components/runner_delete_button_spec.js @@ -17,9 +17,9 @@ import { import RunnerDeleteButton from '~/runner/components/runner_delete_button.vue'; import RunnerDeleteModal from '~/runner/components/runner_delete_modal.vue'; -import { runnersData } from '../mock_data'; +import { allRunnersData } from '../mock_data'; -const mockRunner = runnersData.data.runners.nodes[0]; +const mockRunner = allRunnersData.data.runners.nodes[0]; const mockRunnerId = getIdFromGraphQLId(mockRunner.id); Vue.use(VueApollo); diff --git a/spec/frontend/runner/components/runner_list_spec.js b/spec/frontend/runner/components/runner_list_spec.js index 872394430ae..eca4bbc3490 100644 --- a/spec/frontend/runner/components/runner_list_spec.js +++ b/spec/frontend/runner/components/runner_list_spec.js @@ -7,9 +7,9 @@ import { import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import RunnerList from '~/runner/components/runner_list.vue'; import RunnerStatusPopover from '~/runner/components/runner_status_popover.vue'; -import { runnersData, onlineContactTimeoutSecs, staleTimeoutSecs } from '../mock_data'; +import { allRunnersData, onlineContactTimeoutSecs, staleTimeoutSecs } from '../mock_data'; -const mockRunners = runnersData.data.runners.nodes; +const mockRunners = allRunnersData.data.runners.nodes; const mockActiveRunnersCount = mockRunners.length; describe('RunnerList', () => { diff --git a/spec/frontend/runner/components/runner_pause_button_spec.js b/spec/frontend/runner/components/runner_pause_button_spec.js index 79f9183d136..61476007571 100644 --- a/spec/frontend/runner/components/runner_pause_button_spec.js +++ b/spec/frontend/runner/components/runner_pause_button_spec.js @@ -16,9 +16,9 @@ import { } from '~/runner/constants'; import RunnerPauseButton from '~/runner/components/runner_pause_button.vue'; -import { runnersData } from '../mock_data'; +import { allRunnersData } from '../mock_data'; -const mockRunner = runnersData.data.runners.nodes[0]; +const mockRunner = allRunnersData.data.runners.nodes[0]; Vue.use(VueApollo); diff --git a/spec/frontend/runner/components/stat/runner_count_spec.js b/spec/frontend/runner/components/stat/runner_count_spec.js index 85a01235139..89b51b1b4a7 100644 --- a/spec/frontend/runner/components/stat/runner_count_spec.js +++ b/spec/frontend/runner/components/stat/runner_count_spec.js @@ -7,8 +7,8 @@ import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; import { captureException } from '~/runner/sentry_utils'; -import adminRunnersCountQuery from '~/runner/graphql/list/admin_runners_count.query.graphql'; -import getGroupRunnersCountQuery from '~/runner/graphql/list/group_runners_count.query.graphql'; +import allRunnersCountQuery from '~/runner/graphql/list/all_runners_count.query.graphql'; +import groupRunnersCountQuery from '~/runner/graphql/list/group_runners_count.query.graphql'; import { runnersCountData, groupRunnersCountData } from '../../mock_data'; @@ -18,13 +18,13 @@ Vue.use(VueApollo); describe('RunnerCount', () => { let wrapper; - let mockRunnersCountQuery; - let mockGroupRunnersCountQuery; + let mockRunnersCountHandler; + let mockGroupRunnersCountHandler; const createComponent = ({ props = {}, ...options } = {}) => { const handlers = [ - [adminRunnersCountQuery, mockRunnersCountQuery], - [getGroupRunnersCountQuery, mockGroupRunnersCountQuery], + [allRunnersCountQuery, mockRunnersCountHandler], + [groupRunnersCountQuery, mockGroupRunnersCountHandler], ]; wrapper = shallowMount(RunnerCount, { @@ -42,8 +42,8 @@ describe('RunnerCount', () => { }; beforeEach(() => { - mockRunnersCountQuery = jest.fn().mockResolvedValue(runnersCountData); - mockGroupRunnersCountQuery = jest.fn().mockResolvedValue(groupRunnersCountData); + mockRunnersCountHandler = jest.fn().mockResolvedValue(runnersCountData); + mockGroupRunnersCountHandler = jest.fn().mockResolvedValue(groupRunnersCountData); }); describe('in admin scope', () => { @@ -54,21 +54,21 @@ describe('RunnerCount', () => { }); it('fetches data from admin query', () => { - expect(mockRunnersCountQuery).toHaveBeenCalledTimes(1); - expect(mockRunnersCountQuery).toHaveBeenCalledWith({}); + expect(mockRunnersCountHandler).toHaveBeenCalledTimes(1); + expect(mockRunnersCountHandler).toHaveBeenCalledWith({}); }); it('fetches data with filters', async () => { await createComponent({ props: { scope: INSTANCE_TYPE, variables: mockVariables } }); - expect(mockRunnersCountQuery).toHaveBeenCalledTimes(2); - expect(mockRunnersCountQuery).toHaveBeenCalledWith(mockVariables); + expect(mockRunnersCountHandler).toHaveBeenCalledTimes(2); + expect(mockRunnersCountHandler).toHaveBeenCalledWith(mockVariables); expect(wrapper.html()).toBe(`<strong>${runnersCountData.data.runners.count}</strong>`); }); it('does not fetch from the group query', async () => { - expect(mockGroupRunnersCountQuery).not.toHaveBeenCalled(); + expect(mockGroupRunnersCountHandler).not.toHaveBeenCalled(); }); describe('when this query is skipped after data was loaded', () => { @@ -90,8 +90,8 @@ describe('RunnerCount', () => { }); it('does not fetch data', async () => { - expect(mockRunnersCountQuery).not.toHaveBeenCalled(); - expect(mockGroupRunnersCountQuery).not.toHaveBeenCalled(); + expect(mockRunnersCountHandler).not.toHaveBeenCalled(); + expect(mockGroupRunnersCountHandler).not.toHaveBeenCalled(); expect(wrapper.html()).toBe('<strong></strong>'); }); @@ -101,7 +101,7 @@ describe('RunnerCount', () => { const mockError = new Error('error!'); beforeEach(async () => { - mockRunnersCountQuery.mockRejectedValue(mockError); + mockRunnersCountHandler.mockRejectedValue(mockError); await createComponent({ props: { scope: INSTANCE_TYPE } }); }); @@ -122,8 +122,8 @@ describe('RunnerCount', () => { }); it('fetches data from the group query', async () => { - expect(mockGroupRunnersCountQuery).toHaveBeenCalledTimes(1); - expect(mockGroupRunnersCountQuery).toHaveBeenCalledWith({}); + expect(mockGroupRunnersCountHandler).toHaveBeenCalledTimes(1); + expect(mockGroupRunnersCountHandler).toHaveBeenCalledWith({}); expect(wrapper.html()).toBe( `<strong>${groupRunnersCountData.data.group.runners.count}</strong>`, @@ -131,7 +131,7 @@ describe('RunnerCount', () => { }); it('does not fetch from the group query', () => { - expect(mockRunnersCountQuery).not.toHaveBeenCalled(); + expect(mockRunnersCountHandler).not.toHaveBeenCalled(); }); }); @@ -142,7 +142,7 @@ describe('RunnerCount', () => { }); it('data is not shown and error is reported', async () => { - expect(mockRunnersCountQuery).toHaveBeenCalledTimes(2); + expect(mockRunnersCountHandler).toHaveBeenCalledTimes(2); }); }); }); diff --git a/spec/frontend/runner/group_runners/group_runners_app_spec.js b/spec/frontend/runner/group_runners/group_runners_app_spec.js index 4c011d5852d..9c42b0d6865 100644 --- a/spec/frontend/runner/group_runners/group_runners_app_spec.js +++ b/spec/frontend/runner/group_runners/group_runners_app_spec.js @@ -39,8 +39,8 @@ import { RUNNER_PAGE_SIZE, I18N_EDIT, } from '~/runner/constants'; -import getGroupRunnersQuery from '~/runner/graphql/list/group_runners.query.graphql'; -import getGroupRunnersCountQuery from '~/runner/graphql/list/group_runners_count.query.graphql'; +import groupRunnersQuery from '~/runner/graphql/list/group_runners.query.graphql'; +import groupRunnersCountQuery from '~/runner/graphql/list/group_runners_count.query.graphql'; import GroupRunnersApp from '~/runner/group_runners/group_runners_app.vue'; import { captureException } from '~/runner/sentry_utils'; import { @@ -61,8 +61,8 @@ const mockRegistrationToken = 'AABBCC'; const mockGroupRunnersEdges = groupRunnersData.data.group.runners.edges; const mockGroupRunnersCount = mockGroupRunnersEdges.length; -const mockGroupRunnersQuery = jest.fn(); -const mockGroupRunnersCountQuery = jest.fn(); +const mockGroupRunnersHandler = jest.fn(); +const mockGroupRunnersCountHandler = jest.fn(); jest.mock('~/flash'); jest.mock('~/runner/sentry_utils'); @@ -87,8 +87,8 @@ describe('GroupRunnersApp', () => { const createComponent = ({ props = {}, mountFn = shallowMountExtended, ...options } = {}) => { const handlers = [ - [getGroupRunnersQuery, mockGroupRunnersQuery], - [getGroupRunnersCountQuery, mockGroupRunnersCountQuery], + [groupRunnersQuery, mockGroupRunnersHandler], + [groupRunnersCountQuery, mockGroupRunnersCountHandler], ]; wrapper = mountFn(GroupRunnersApp, { @@ -112,13 +112,13 @@ describe('GroupRunnersApp', () => { }; beforeEach(async () => { - mockGroupRunnersQuery.mockResolvedValue(groupRunnersData); - mockGroupRunnersCountQuery.mockResolvedValue(groupRunnersCountData); + mockGroupRunnersHandler.mockResolvedValue(groupRunnersData); + mockGroupRunnersCountHandler.mockResolvedValue(groupRunnersCountData); }); afterEach(() => { - mockGroupRunnersQuery.mockReset(); - mockGroupRunnersCountQuery.mockReset(); + mockGroupRunnersHandler.mockReset(); + mockGroupRunnersCountHandler.mockReset(); wrapper.destroy(); }); @@ -140,15 +140,15 @@ describe('GroupRunnersApp', () => { it('shows total runner counts', async () => { await createComponent({ mountFn: mountExtended }); - expect(mockGroupRunnersCountQuery).toHaveBeenCalledWith({ + expect(mockGroupRunnersCountHandler).toHaveBeenCalledWith({ status: STATUS_ONLINE, groupFullPath: mockGroupFullPath, }); - expect(mockGroupRunnersCountQuery).toHaveBeenCalledWith({ + expect(mockGroupRunnersCountHandler).toHaveBeenCalledWith({ status: STATUS_OFFLINE, groupFullPath: mockGroupFullPath, }); - expect(mockGroupRunnersCountQuery).toHaveBeenCalledWith({ + expect(mockGroupRunnersCountHandler).toHaveBeenCalledWith({ status: STATUS_STALE, groupFullPath: mockGroupFullPath, }); @@ -174,7 +174,7 @@ describe('GroupRunnersApp', () => { it('requests the runners with group path and no other filters', async () => { await createComponent(); - expect(mockGroupRunnersQuery).toHaveBeenLastCalledWith({ + expect(mockGroupRunnersHandler).toHaveBeenLastCalledWith({ groupFullPath: mockGroupFullPath, status: undefined, type: undefined, @@ -231,11 +231,11 @@ describe('GroupRunnersApp', () => { }); it('When runner is paused or unpaused, some data is refetched', async () => { - expect(mockGroupRunnersCountQuery).toHaveBeenCalledTimes(COUNT_QUERIES); + expect(mockGroupRunnersCountHandler).toHaveBeenCalledTimes(COUNT_QUERIES); findRunnerActionsCell().vm.$emit('toggledPaused'); - expect(mockGroupRunnersCountQuery).toHaveBeenCalledTimes( + expect(mockGroupRunnersCountHandler).toHaveBeenCalledTimes( COUNT_QUERIES + FILTERED_COUNT_QUERIES, ); @@ -272,7 +272,7 @@ describe('GroupRunnersApp', () => { }); it('requests the runners with filter parameters', () => { - expect(mockGroupRunnersQuery).toHaveBeenLastCalledWith({ + expect(mockGroupRunnersHandler).toHaveBeenLastCalledWith({ groupFullPath: mockGroupFullPath, status: STATUS_ONLINE, type: INSTANCE_TYPE, @@ -282,7 +282,7 @@ describe('GroupRunnersApp', () => { }); it('fetches count results for requested status', () => { - expect(mockGroupRunnersCountQuery).toHaveBeenCalledWith({ + expect(mockGroupRunnersCountHandler).toHaveBeenCalledWith({ groupFullPath: mockGroupFullPath, type: INSTANCE_TYPE, status: STATUS_ONLINE, @@ -319,7 +319,7 @@ describe('GroupRunnersApp', () => { }); it('requests the runners with filters', () => { - expect(mockGroupRunnersQuery).toHaveBeenLastCalledWith({ + expect(mockGroupRunnersHandler).toHaveBeenLastCalledWith({ groupFullPath: mockGroupFullPath, status: STATUS_ONLINE, tagList: ['tag1'], @@ -329,7 +329,7 @@ describe('GroupRunnersApp', () => { }); it('fetches count results for requested status', () => { - expect(mockGroupRunnersCountQuery).toHaveBeenCalledWith({ + expect(mockGroupRunnersCountHandler).toHaveBeenCalledWith({ groupFullPath: mockGroupFullPath, tagList: ['tag1'], status: STATUS_ONLINE, @@ -344,7 +344,7 @@ describe('GroupRunnersApp', () => { describe('when no runners are found', () => { beforeEach(async () => { - mockGroupRunnersQuery.mockResolvedValue({ + mockGroupRunnersHandler.mockResolvedValue({ data: { group: { id: '1', @@ -362,7 +362,7 @@ describe('GroupRunnersApp', () => { describe('when runners query fails', () => { beforeEach(async () => { - mockGroupRunnersQuery.mockRejectedValue(new Error('Error!')); + mockGroupRunnersHandler.mockRejectedValue(new Error('Error!')); await createComponent(); }); @@ -380,7 +380,7 @@ describe('GroupRunnersApp', () => { describe('Pagination', () => { beforeEach(async () => { - mockGroupRunnersQuery.mockResolvedValue(groupRunnersDataPaginated); + mockGroupRunnersHandler.mockResolvedValue(groupRunnersDataPaginated); await createComponent({ mountFn: mountExtended }); }); @@ -388,7 +388,7 @@ describe('GroupRunnersApp', () => { it('navigates to the next page', async () => { await findRunnerPaginationNext().trigger('click'); - expect(mockGroupRunnersQuery).toHaveBeenLastCalledWith({ + expect(mockGroupRunnersHandler).toHaveBeenLastCalledWith({ groupFullPath: mockGroupFullPath, sort: CREATED_DESC, first: RUNNER_PAGE_SIZE, diff --git a/spec/frontend/runner/mock_data.js b/spec/frontend/runner/mock_data.js index 60a1a34bf95..e5472ace817 100644 --- a/spec/frontend/runner/mock_data.js +++ b/spec/frontend/runner/mock_data.js @@ -10,9 +10,9 @@ import runnerJobsData from 'test_fixtures/graphql/runner/show/runner_jobs.query. import runnerFormData from 'test_fixtures/graphql/runner/edit/runner_form.query.graphql.json'; // List queries -import runnersData from 'test_fixtures/graphql/runner/list/admin_runners.query.graphql.json'; -import runnersDataPaginated from 'test_fixtures/graphql/runner/list/admin_runners.query.graphql.paginated.json'; -import runnersCountData from 'test_fixtures/graphql/runner/list/admin_runners_count.query.graphql.json'; +import allRunnersData from 'test_fixtures/graphql/runner/list/all_runners.query.graphql.json'; +import allRunnersDataPaginated from 'test_fixtures/graphql/runner/list/all_runners.query.graphql.paginated.json'; +import runnersCountData from 'test_fixtures/graphql/runner/list/all_runners_count.query.graphql.json'; import groupRunnersData from 'test_fixtures/graphql/runner/list/group_runners.query.graphql.json'; import groupRunnersDataPaginated from 'test_fixtures/graphql/runner/list/group_runners.query.graphql.paginated.json'; import groupRunnersCountData from 'test_fixtures/graphql/runner/list/group_runners_count.query.graphql.json'; @@ -227,8 +227,8 @@ export const emptyStateSvgPath = 'emptyStateSvgPath.svg'; export const emptyStateFilteredSvgPath = 'emptyStateFilteredSvgPath.svg'; export { - runnersData, - runnersDataPaginated, + allRunnersData, + allRunnersDataPaginated, runnersCountData, groupRunnersData, groupRunnersDataPaginated, diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb index bcbe571db5e..d00cd8f1d6b 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/groups_helper_spec.rb @@ -355,8 +355,8 @@ RSpec.describe GroupsHelper do end end - describe '#show_thanks_for_purchase_banner?' do - subject { helper.show_thanks_for_purchase_banner? } + describe '#show_thanks_for_purchase_alert?' do + subject { helper.show_thanks_for_purchase_alert? } it 'returns true with purchased_quantity present in params' do allow(controller).to receive(:params) { { purchased_quantity: '1' } } diff --git a/spec/helpers/storage_helper_spec.rb b/spec/helpers/storage_helper_spec.rb index cd5701db83b..4b46bf169e0 100644 --- a/spec/helpers/storage_helper_spec.rb +++ b/spec/helpers/storage_helper_spec.rb @@ -51,7 +51,7 @@ RSpec.describe StorageHelper do end end - describe "storage_enforcement_banner", :saas do + describe "storage_enforcement_banner" do let_it_be_with_refind(:current_user) { create(:user) } let_it_be(:free_group) { create(:group) } let_it_be(:paid_group) { create(:group) } diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb index d9f4245500d..eeac0c85a77 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb @@ -84,7 +84,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do end end - it 'respects the defined payload schema', :saas do + it 'respects the defined payload schema' do expect(::Gitlab::HTTP).to receive(:post) do |_url, params| expect(params[:body]).to match_schema('/external_validation') expect(params[:timeout]).to eq(described_class::DEFAULT_VALIDATION_REQUEST_TIMEOUT) diff --git a/spec/requests/api/terraform/modules/v1/packages_spec.rb b/spec/requests/api/terraform/modules/v1/packages_spec.rb index d802282f8dc..dff44a45de4 100644 --- a/spec/requests/api/terraform/modules/v1/packages_spec.rb +++ b/spec/requests/api/terraform/modules/v1/packages_spec.rb @@ -100,7 +100,7 @@ RSpec.describe API::Terraform::Modules::V1::Packages do describe 'GET /api/v4/packages/terraform/modules/v1/:module_namespace/:module_name/:module_system/download' do context 'empty registry' do - let(:url) { api("/packages/terraform/modules/v1/module-2/system/download") } + let(:url) { api("/packages/terraform/modules/v1/#{group.path}/module-2/system/download") } let(:headers) { {} } subject { get(url, headers: headers) } @@ -171,6 +171,74 @@ RSpec.describe API::Terraform::Modules::V1::Packages do end end + describe 'GET /api/v4/packages/terraform/modules/v1/:module_namespace/:module_name/:module_system' do + context 'empty registry' do + let(:url) { api("/packages/terraform/modules/v1/#{group.path}/non-existent/system") } + let(:headers) { { 'Authorization' => "Bearer #{tokens[:personal_access_token]}" } } + + subject { get(url, headers: headers) } + + it 'returns not found when there is no module' do + subject + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + context 'with valid namespace' do + let(:url) { api("/packages/terraform/modules/v1/#{group.path}/#{package.name}") } + + subject { get(url, headers: headers) } + + where(:visibility, :user_role, :member, :token_type, :shared_examples_name, :expected_status) do + :public | :developer | true | :personal_access_token | 'returns terraform module version' | :success + :public | :guest | true | :personal_access_token | 'returns terraform module version' | :success + :public | :developer | true | :invalid | 'rejects terraform module packages access' | :unauthorized + :public | :guest | true | :invalid | 'rejects terraform module packages access' | :unauthorized + :public | :developer | false | :personal_access_token | 'returns terraform module version' | :success + :public | :guest | false | :personal_access_token | 'returns terraform module version' | :success + :public | :developer | false | :invalid | 'rejects terraform module packages access' | :unauthorized + :public | :guest | false | :invalid | 'rejects terraform module packages access' | :unauthorized + :public | :anonymous | false | nil | 'returns terraform module version' | :success + :private | :developer | true | :personal_access_token | 'returns terraform module version' | :success + :private | :guest | true | :personal_access_token | 'rejects terraform module packages access' | :forbidden + :private | :developer | true | :invalid | 'rejects terraform module packages access' | :unauthorized + :private | :guest | true | :invalid | 'rejects terraform module packages access' | :unauthorized + :private | :developer | false | :personal_access_token | 'rejects terraform module packages access' | :forbidden + :private | :guest | false | :personal_access_token | 'rejects terraform module packages access' | :forbidden + :private | :developer | false | :invalid | 'rejects terraform module packages access' | :unauthorized + :private | :guest | false | :invalid | 'rejects terraform module packages access' | :unauthorized + :private | :anonymous | false | nil | 'rejects terraform module packages access' | :unauthorized + :public | :developer | true | :job_token | 'returns terraform module version' | :success + :public | :guest | true | :job_token | 'returns terraform module version' | :success + :public | :guest | true | :invalid | 'rejects terraform module packages access' | :unauthorized + :public | :developer | false | :job_token | 'returns terraform module version' | :success + :public | :guest | false | :job_token | 'returns terraform module version' | :success + :public | :developer | false | :invalid | 'rejects terraform module packages access' | :unauthorized + :public | :guest | false | :invalid | 'rejects terraform module packages access' | :unauthorized + :private | :developer | true | :job_token | 'returns terraform module version' | :success + :private | :guest | true | :job_token | 'rejects terraform module packages access' | :forbidden + :private | :developer | true | :invalid | 'rejects terraform module packages access' | :unauthorized + :private | :guest | true | :invalid | 'rejects terraform module packages access' | :unauthorized + :private | :developer | false | :job_token | 'rejects terraform module packages access' | :forbidden + :private | :guest | false | :job_token | 'rejects terraform module packages access' | :forbidden + :private | :developer | false | :invalid | 'rejects terraform module packages access' | :unauthorized + :private | :guest | false | :invalid | 'rejects terraform module packages access' | :unauthorized + end + + with_them do + let(:headers) { user_role == :anonymous ? {} : { 'Authorization' => "Bearer #{token}" } } + + before do + group.update!(visibility: visibility.to_s) + project.update!(visibility: visibility.to_s) + end + + it_behaves_like params[:shared_examples_name], params[:user_role], params[:expected_status], params[:member] + end + end + end + describe 'GET /api/v4/packages/terraform/modules/v1/:module_namespace/:module_name/:module_system/:module_version' do let(:url) { api("/packages/terraform/modules/v1/#{group.path}/#{package.name}/#{package.version}") } let(:headers) { {} } diff --git a/spec/services/work_items/create_service_spec.rb b/spec/services/work_items/create_service_spec.rb index 1b6af1fef5a..4009c85bacd 100644 --- a/spec/services/work_items/create_service_spec.rb +++ b/spec/services/work_items/create_service_spec.rb @@ -27,16 +27,18 @@ RSpec.describe WorkItems::CreateService do end describe '#execute' do - subject(:service_result) do + let(:service) do described_class.new( project: project, current_user: current_user, params: opts, spam_params: spam_params, widget_params: widget_params - ).execute + ) end + subject(:service_result) { service.execute } + before do stub_spam_services end @@ -73,6 +75,14 @@ RSpec.describe WorkItems::CreateService do it 'returns validation errors' do expect(service_result.errors).to contain_exactly("Title can't be blank") end + + it 'does not execute after-create transaction widgets' do + expect(service).to receive(:create).and_call_original + expect(service).not_to receive(:execute_widgets) + .with(callback: :after_create_in_transaction, widget_params: widget_params) + + service_result + end end context 'checking spam' do |