diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-14 12:09:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-14 12:09:21 +0300 |
commit | 1fc72cb8765dab466da8555b70eb744a53a74a80 (patch) | |
tree | c74b37a2056ff89781aee51b2b9ff5c0560a2fb4 /spec/frontend/ci | |
parent | 4fc8a5035217a603a5af54aab09bb7c1bfea7626 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ci')
3 files changed, 60 insertions, 32 deletions
diff --git a/spec/frontend/ci/runner/components/runner_create_form_spec.js b/spec/frontend/ci/runner/components/runner_create_form_spec.js index f11667ee415..c452e32b0e4 100644 --- a/spec/frontend/ci/runner/components/runner_create_form_spec.js +++ b/spec/frontend/ci/runner/components/runner_create_form_spec.js @@ -11,6 +11,7 @@ import { INSTANCE_TYPE, GROUP_TYPE, PROJECT_TYPE, + I18N_CREATE_ERROR, } from '~/ci/runner/constants'; import runnerCreateMutation from '~/ci/runner/graphql/new/runner_create.mutation.graphql'; import { captureException } from '~/ci/runner/sentry_utils'; @@ -188,5 +189,37 @@ describe('RunnerCreateForm', () => { expect(captureException).not.toHaveBeenCalled(); }); }); + + describe('when no runner information is returned', () => { + beforeEach(async () => { + runnerCreateHandler.mockResolvedValue({ + data: { + runnerCreate: { + errors: [], + runner: null, + }, + }, + }); + + findForm().vm.$emit('submit', { preventDefault }); + await waitForPromises(); + }); + + it('emits "error" result', () => { + expect(wrapper.emitted('error')[0]).toEqual([new TypeError(I18N_CREATE_ERROR)]); + }); + + it('does not show a saving state', () => { + expect(findSubmitBtn().props('loading')).toBe(false); + }); + + it('reports error', () => { + expect(captureException).toHaveBeenCalledTimes(1); + expect(captureException).toHaveBeenCalledWith({ + component: 'RunnerCreateForm', + error: new Error(I18N_CREATE_ERROR), + }); + }); + }); }); }); diff --git a/spec/frontend/ci/runner/components/runner_managers_detail_spec.js b/spec/frontend/ci/runner/components/runner_managers_detail_spec.js index b2551e67396..3435292394f 100644 --- a/spec/frontend/ci/runner/components/runner_managers_detail_spec.js +++ b/spec/frontend/ci/runner/components/runner_managers_detail_spec.js @@ -2,16 +2,12 @@ import { GlCollapse, GlSkeletonLoader, GlTableLite } from '@gitlab/ui'; import Vue from 'vue'; import VueApollo from 'vue-apollo'; import { __ } from '~/locale'; -import { - shallowMountExtended, - mountExtended, - extendedWrapper, -} from 'helpers/vue_test_utils_helper'; +import { shallowMountExtended, mountExtended } from 'helpers/vue_test_utils_helper'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; import RunnerManagersDetail from '~/ci/runner/components/runner_managers_detail.vue'; -import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue'; +import RunnerManagersTable from '~/ci/runner/components/runner_managers_table.vue'; import runnerManagersQuery from '~/ci/runner/graphql/show/runner_managers.query.graphql'; import { runnerData, runnerManagersData } from '../mock_data'; @@ -33,8 +29,7 @@ describe('RunnerJobs', () => { const findSkeletonLoader = () => wrapper.findComponent(GlSkeletonLoader); const findCollapse = () => wrapper.findComponent(GlCollapse); - const findRows = () => wrapper.findAll('tbody tr'); - const findCell = ({ field, i }) => extendedWrapper(findRows().at(i)).findByTestId(`td-${field}`); + const findRunnerManagersTable = () => wrapper.findComponent(RunnerManagersTable); const createComponent = ({ props, mountFn = shallowMountExtended } = {}) => { wrapper = mountFn(RunnerManagersDetail, { @@ -162,21 +157,7 @@ describe('RunnerJobs', () => { it('shows rows', () => { expect(findCollapse().attributes('visible')).toBe('true'); - expect(findRows()).toHaveLength(mockRunnerManagers.length); - }); - - it('shows system id', () => { - expect(findCell({ field: 'systemId', i: 0 }).text()).toBe(mockRunnerManagers[0].systemId); - expect(findCell({ field: 'systemId', i: 1 }).text()).toBe(mockRunnerManagers[1].systemId); - }); - - it('shows contacted at', () => { - expect(findCell({ field: 'contactedAt', i: 0 }).findComponent(TimeAgo).props('time')).toBe( - mockRunnerManagers[0].contactedAt, - ); - expect(findCell({ field: 'contactedAt', i: 1 }).findComponent(TimeAgo).props('time')).toBe( - mockRunnerManagers[1].contactedAt, - ); + expect(findRunnerManagersTable().props('items')).toEqual(mockRunnerManagers); }); it('collapses when clicked', async () => { diff --git a/spec/frontend/ci/runner/components/runner_managers_table_spec.js b/spec/frontend/ci/runner/components/runner_managers_table_spec.js index a0ebf3b2578..e72ea60cdbd 100644 --- a/spec/frontend/ci/runner/components/runner_managers_table_spec.js +++ b/spec/frontend/ci/runner/components/runner_managers_table_spec.js @@ -1,20 +1,17 @@ import { GlTableLite } from '@gitlab/ui'; -import Vue from 'vue'; -import VueApollo from 'vue-apollo'; import { s__ } from '~/locale'; import { mountExtended, extendedWrapper } from 'helpers/vue_test_utils_helper'; import RunnerManagersTable from '~/ci/runner/components/runner_managers_table.vue'; import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue'; +import { I18N_STATUS_NEVER_CONTACTED } from '~/ci/runner/constants'; import { runnerManagersData } from '../mock_data'; jest.mock('~/alert'); jest.mock('~/ci/runner/sentry_utils'); -const [runnerManager1, runnerManager2] = runnerManagersData.data.runner.managers.nodes; - -Vue.use(VueApollo); +const mockItems = runnerManagersData.data.runner.managers.nodes; describe('RunnerJobs', () => { let wrapper; @@ -25,9 +22,11 @@ describe('RunnerJobs', () => { const findCellText = (opts) => findCell(opts).text().replace(/\s+/g, ' '); const createComponent = ({ item } = {}) => { + const [mockItem, ...otherItems] = mockItems; + wrapper = mountExtended(RunnerManagersTable, { propsData: { - items: [{ ...runnerManager1, ...item }, runnerManager2], + items: [{ ...mockItem, ...item }, ...otherItems], }, stubs: { GlTableLite, @@ -54,8 +53,8 @@ describe('RunnerJobs', () => { it('shows system id', () => { createComponent(); - expect(findCellText({ field: 'systemId', i: 0 })).toBe(runnerManager1.systemId); - expect(findCellText({ field: 'systemId', i: 1 })).toBe(runnerManager2.systemId); + expect(findCellText({ field: 'systemId', i: 0 })).toBe(mockItems[0].systemId); + expect(findCellText({ field: 'systemId', i: 1 })).toBe(mockItems[1].systemId); }); it('shows version', () => { @@ -74,6 +73,14 @@ describe('RunnerJobs', () => { expect(findCellText({ field: 'version', i: 0 })).toBe('1.0 (123456)'); }); + it('shows revision without version', () => { + createComponent({ + item: { version: null, revision: '123456' }, + }); + + expect(findCellText({ field: 'version', i: 0 })).toBe('(123456)'); + }); + it('shows ip address', () => { createComponent({ item: { ipAddress: '127.0.0.1' }, @@ -117,7 +124,14 @@ describe('RunnerJobs', () => { it('shows contacted at', () => { createComponent(); expect(findCell({ field: 'contactedAt', i: 0 }).findComponent(TimeAgo).props('time')).toBe( - runnerManager1.contactedAt, + mockItems[0].contactedAt, ); }); + + it('shows missing contacted at', () => { + createComponent({ + item: { contactedAt: null }, + }); + expect(findCellText({ field: 'contactedAt', i: 0 })).toBe(I18N_STATUS_NEVER_CONTACTED); + }); }); |