diff options
Diffstat (limited to 'spec/frontend/pipeline_schedules/components')
9 files changed, 0 insertions, 494 deletions
diff --git a/spec/frontend/pipeline_schedules/components/pipeline_schedules_form_spec.js b/spec/frontend/pipeline_schedules/components/pipeline_schedules_form_spec.js deleted file mode 100644 index 4b5a9611251..00000000000 --- a/spec/frontend/pipeline_schedules/components/pipeline_schedules_form_spec.js +++ /dev/null @@ -1,25 +0,0 @@ -import { shallowMount } from '@vue/test-utils'; -import { GlForm } from '@gitlab/ui'; -import PipelineSchedulesForm from '~/pipeline_schedules/components/pipeline_schedules_form.vue'; - -describe('Pipeline schedules form', () => { - let wrapper; - - const createComponent = () => { - wrapper = shallowMount(PipelineSchedulesForm); - }; - - const findForm = () => wrapper.findComponent(GlForm); - - beforeEach(() => { - createComponent(); - }); - - afterEach(() => { - wrapper.destroy(); - }); - - it('displays form', () => { - expect(findForm().exists()).toBe(true); - }); -}); diff --git a/spec/frontend/pipeline_schedules/components/pipeline_schedules_spec.js b/spec/frontend/pipeline_schedules/components/pipeline_schedules_spec.js deleted file mode 100644 index cce8f480928..00000000000 --- a/spec/frontend/pipeline_schedules/components/pipeline_schedules_spec.js +++ /dev/null @@ -1,161 +0,0 @@ -import { GlAlert, GlLoadingIcon, GlModal } from '@gitlab/ui'; -import { shallowMount } from '@vue/test-utils'; -import Vue, { nextTick } from 'vue'; -import VueApollo from 'vue-apollo'; -import createMockApollo from 'helpers/mock_apollo_helper'; -import waitForPromises from 'helpers/wait_for_promises'; -import PipelineSchedules from '~/pipeline_schedules/components/pipeline_schedules.vue'; -import PipelineSchedulesTable from '~/pipeline_schedules/components/table/pipeline_schedules_table.vue'; -import deletePipelineScheduleMutation from '~/pipeline_schedules/graphql/mutations/delete_pipeline_schedule.mutation.graphql'; -import getPipelineSchedulesQuery from '~/pipeline_schedules/graphql/queries/get_pipeline_schedules.query.graphql'; -import { - mockGetPipelineSchedulesGraphQLResponse, - mockPipelineScheduleNodes, - deleteMutationResponse, -} from '../mock_data'; - -Vue.use(VueApollo); - -describe('Pipeline schedules app', () => { - let wrapper; - - const successHandler = jest.fn().mockResolvedValue(mockGetPipelineSchedulesGraphQLResponse); - const failedHandler = jest.fn().mockRejectedValue(new Error('GraphQL error')); - - const deleteMutationHandlerSuccess = jest.fn().mockResolvedValue(deleteMutationResponse); - const deleteMutationHandlerFailed = jest.fn().mockRejectedValue(new Error('GraphQL error')); - - const createMockApolloProvider = ( - requestHandlers = [[getPipelineSchedulesQuery, successHandler]], - ) => { - return createMockApollo(requestHandlers); - }; - - const createComponent = (requestHandlers) => { - wrapper = shallowMount(PipelineSchedules, { - provide: { - fullPath: 'gitlab-org/gitlab', - }, - apolloProvider: createMockApolloProvider(requestHandlers), - }); - }; - - const findTable = () => wrapper.findComponent(PipelineSchedulesTable); - const findAlert = () => wrapper.findComponent(GlAlert); - const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon); - const findModal = () => wrapper.findComponent(GlModal); - - afterEach(() => { - wrapper.destroy(); - }); - - it('displays table', async () => { - createComponent(); - - await waitForPromises(); - - expect(findTable().exists()).toBe(true); - expect(findAlert().exists()).toBe(false); - }); - - it('fetches query and passes an array of pipeline schedules', async () => { - createComponent(); - - expect(successHandler).toHaveBeenCalled(); - - await waitForPromises(); - - expect(findTable().props('schedules')).toEqual(mockPipelineScheduleNodes); - }); - - it('handles loading state', async () => { - createComponent(); - - expect(findLoadingIcon().exists()).toBe(true); - - await waitForPromises(); - - expect(findLoadingIcon().exists()).toBe(false); - }); - - it('shows query error alert', async () => { - createComponent([[getPipelineSchedulesQuery, failedHandler]]); - - await waitForPromises(); - - expect(findAlert().text()).toBe('There was a problem fetching pipeline schedules.'); - }); - - it('shows delete mutation error alert', async () => { - createComponent([ - [getPipelineSchedulesQuery, successHandler], - [deletePipelineScheduleMutation, deleteMutationHandlerFailed], - ]); - - await waitForPromises(); - - findModal().vm.$emit('primary'); - - await waitForPromises(); - - expect(findAlert().text()).toBe('There was a problem deleting the pipeline schedule.'); - }); - - it('deletes pipeline schedule and refetches query', async () => { - createComponent([ - [getPipelineSchedulesQuery, successHandler], - [deletePipelineScheduleMutation, deleteMutationHandlerSuccess], - ]); - - jest.spyOn(wrapper.vm.$apollo.queries.schedules, 'refetch'); - - await waitForPromises(); - - const scheduleId = mockPipelineScheduleNodes[0].id; - - findTable().vm.$emit('showDeleteModal', scheduleId); - - expect(wrapper.vm.$apollo.queries.schedules.refetch).not.toHaveBeenCalled(); - - findModal().vm.$emit('primary'); - - await waitForPromises(); - - expect(deleteMutationHandlerSuccess).toHaveBeenCalledWith({ - id: scheduleId, - }); - expect(wrapper.vm.$apollo.queries.schedules.refetch).toHaveBeenCalled(); - }); - - it('modal should be visible after event', async () => { - createComponent(); - - await waitForPromises(); - - expect(findModal().props('visible')).toBe(false); - - findTable().vm.$emit('showDeleteModal', mockPipelineScheduleNodes[0].id); - - await nextTick(); - - expect(findModal().props('visible')).toBe(true); - }); - - it('modal should be hidden', async () => { - createComponent(); - - await waitForPromises(); - - findTable().vm.$emit('showDeleteModal', mockPipelineScheduleNodes[0].id); - - await nextTick(); - - expect(findModal().props('visible')).toBe(true); - - findModal().vm.$emit('hide'); - - await nextTick(); - - expect(findModal().props('visible')).toBe(false); - }); -}); diff --git a/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_actions_spec.js b/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_actions_spec.js deleted file mode 100644 index ecc1bdeb679..00000000000 --- a/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_actions_spec.js +++ /dev/null @@ -1,49 +0,0 @@ -import { GlButton } from '@gitlab/ui'; -import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; -import PipelineScheduleActions from '~/pipeline_schedules/components/table/cells/pipeline_schedule_actions.vue'; -import { mockPipelineScheduleNodes, mockPipelineScheduleAsGuestNodes } from '../../../mock_data'; - -describe('Pipeline schedule actions', () => { - let wrapper; - - const defaultProps = { - schedule: mockPipelineScheduleNodes[0], - }; - - const createComponent = (props = defaultProps) => { - wrapper = shallowMountExtended(PipelineScheduleActions, { - propsData: { - ...props, - }, - }); - }; - - const findAllButtons = () => wrapper.findAllComponents(GlButton); - const findDeleteBtn = () => wrapper.findByTestId('delete-pipeline-schedule-btn'); - - afterEach(() => { - wrapper.destroy(); - }); - - it('displays action buttons', () => { - createComponent(); - - expect(findAllButtons()).toHaveLength(3); - }); - - it('does not display action buttons', () => { - createComponent({ schedule: mockPipelineScheduleAsGuestNodes[0] }); - - expect(findAllButtons()).toHaveLength(0); - }); - - it('delete button emits showDeleteModal event and schedule id', () => { - createComponent(); - - findDeleteBtn().vm.$emit('click'); - - expect(wrapper.emitted()).toEqual({ - showDeleteModal: [[mockPipelineScheduleNodes[0].id]], - }); - }); -}); diff --git a/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_last_pipeline_spec.js b/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_last_pipeline_spec.js deleted file mode 100644 index 5a47b24232f..00000000000 --- a/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_last_pipeline_spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; -import CiBadge from '~/vue_shared/components/ci_badge_link.vue'; -import PipelineScheduleLastPipeline from '~/pipeline_schedules/components/table/cells/pipeline_schedule_last_pipeline.vue'; -import { mockPipelineScheduleNodes } from '../../../mock_data'; - -describe('Pipeline schedule last pipeline', () => { - let wrapper; - - const defaultProps = { - schedule: mockPipelineScheduleNodes[2], - }; - - const createComponent = (props = defaultProps) => { - wrapper = shallowMountExtended(PipelineScheduleLastPipeline, { - propsData: { - ...props, - }, - }); - }; - - const findCIBadge = () => wrapper.findComponent(CiBadge); - const findStatusText = () => wrapper.findByTestId('pipeline-schedule-status-text'); - - afterEach(() => { - wrapper.destroy(); - }); - - it('displays pipeline status', () => { - createComponent(); - - expect(findCIBadge().exists()).toBe(true); - expect(findCIBadge().props('status')).toBe(defaultProps.schedule.lastPipeline.detailedStatus); - expect(findStatusText().exists()).toBe(false); - }); - - it('displays "none" status text', () => { - createComponent({ schedule: mockPipelineScheduleNodes[0] }); - - expect(findStatusText().text()).toBe('None'); - expect(findCIBadge().exists()).toBe(false); - }); -}); diff --git a/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_next_run_spec.js b/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_next_run_spec.js deleted file mode 100644 index b1bdc1e91a0..00000000000 --- a/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_next_run_spec.js +++ /dev/null @@ -1,43 +0,0 @@ -import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; -import PipelineScheduleNextRun from '~/pipeline_schedules/components/table/cells/pipeline_schedule_next_run.vue'; -import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; -import { mockPipelineScheduleNodes } from '../../../mock_data'; - -describe('Pipeline schedule next run', () => { - let wrapper; - - const defaultProps = { - schedule: mockPipelineScheduleNodes[0], - }; - - const createComponent = (props = defaultProps) => { - wrapper = shallowMountExtended(PipelineScheduleNextRun, { - propsData: { - ...props, - }, - }); - }; - - const findTimeAgo = () => wrapper.findComponent(TimeAgoTooltip); - const findInactive = () => wrapper.findByTestId('pipeline-schedule-inactive'); - - afterEach(() => { - wrapper.destroy(); - }); - - it('displays time ago', () => { - createComponent(); - - expect(findTimeAgo().exists()).toBe(true); - expect(findInactive().exists()).toBe(false); - expect(findTimeAgo().props('time')).toBe(defaultProps.schedule.realNextRun); - }); - - it('displays inactive state', () => { - const inactiveSchedule = mockPipelineScheduleNodes[1]; - createComponent({ schedule: inactiveSchedule }); - - expect(findInactive().text()).toBe('Inactive'); - expect(findTimeAgo().exists()).toBe(false); - }); -}); diff --git a/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_owner_spec.js b/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_owner_spec.js deleted file mode 100644 index 3ab04958f5e..00000000000 --- a/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_owner_spec.js +++ /dev/null @@ -1,40 +0,0 @@ -import { GlAvatar, GlAvatarLink } from '@gitlab/ui'; -import { shallowMount } from '@vue/test-utils'; -import PipelineScheduleOwner from '~/pipeline_schedules/components/table/cells/pipeline_schedule_owner.vue'; -import { mockPipelineScheduleNodes } from '../../../mock_data'; - -describe('Pipeline schedule owner', () => { - let wrapper; - - const defaultProps = { - schedule: mockPipelineScheduleNodes[0], - }; - - const createComponent = (props = defaultProps) => { - wrapper = shallowMount(PipelineScheduleOwner, { - propsData: { - ...props, - }, - }); - }; - - const findAvatar = () => wrapper.findComponent(GlAvatar); - const findAvatarLink = () => wrapper.findComponent(GlAvatarLink); - - beforeEach(() => { - createComponent(); - }); - - afterEach(() => { - wrapper.destroy(); - }); - - it('displays avatar', () => { - expect(findAvatar().exists()).toBe(true); - expect(findAvatar().props('src')).toBe(defaultProps.schedule.owner.avatarUrl); - }); - - it('avatar links to user', () => { - expect(findAvatarLink().attributes('href')).toBe(defaultProps.schedule.owner.webPath); - }); -}); diff --git a/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_target_spec.js b/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_target_spec.js deleted file mode 100644 index 6817e58790b..00000000000 --- a/spec/frontend/pipeline_schedules/components/table/cells/pipeline_schedule_target_spec.js +++ /dev/null @@ -1,41 +0,0 @@ -import { GlIcon, GlLink } from '@gitlab/ui'; -import { shallowMount } from '@vue/test-utils'; -import PipelineScheduleTarget from '~/pipeline_schedules/components/table/cells/pipeline_schedule_target.vue'; -import { mockPipelineScheduleNodes } from '../../../mock_data'; - -describe('Pipeline schedule target', () => { - let wrapper; - - const defaultProps = { - schedule: mockPipelineScheduleNodes[0], - }; - - const createComponent = (props = defaultProps) => { - wrapper = shallowMount(PipelineScheduleTarget, { - propsData: { - ...props, - }, - }); - }; - - const findIcon = () => wrapper.findComponent(GlIcon); - const findLink = () => wrapper.findComponent(GlLink); - - beforeEach(() => { - createComponent(); - }); - - afterEach(() => { - wrapper.destroy(); - }); - - it('displays icon', () => { - expect(findIcon().exists()).toBe(true); - expect(findIcon().props('name')).toBe('fork'); - }); - - it('displays ref link', () => { - expect(findLink().attributes('href')).toBe(defaultProps.schedule.refPath); - expect(findLink().text()).toBe(defaultProps.schedule.refForDisplay); - }); -}); diff --git a/spec/frontend/pipeline_schedules/components/table/pipeline_schedules_table_spec.js b/spec/frontend/pipeline_schedules/components/table/pipeline_schedules_table_spec.js deleted file mode 100644 index 914897946ee..00000000000 --- a/spec/frontend/pipeline_schedules/components/table/pipeline_schedules_table_spec.js +++ /dev/null @@ -1,39 +0,0 @@ -import { GlTableLite } from '@gitlab/ui'; -import { mountExtended } from 'helpers/vue_test_utils_helper'; -import PipelineSchedulesTable from '~/pipeline_schedules/components/table/pipeline_schedules_table.vue'; -import { mockPipelineScheduleNodes } from '../../mock_data'; - -describe('Pipeline schedules table', () => { - let wrapper; - - const defaultProps = { - schedules: mockPipelineScheduleNodes, - }; - - const createComponent = (props = defaultProps) => { - wrapper = mountExtended(PipelineSchedulesTable, { - propsData: { - ...props, - }, - }); - }; - - const findTable = () => wrapper.findComponent(GlTableLite); - const findScheduleDescription = () => wrapper.findByTestId('pipeline-schedule-description'); - - beforeEach(() => { - createComponent(); - }); - - afterEach(() => { - wrapper.destroy(); - }); - - it('displays table', () => { - expect(findTable().exists()).toBe(true); - }); - - it('displays schedule description', () => { - expect(findScheduleDescription().text()).toBe('pipeline schedule'); - }); -}); diff --git a/spec/frontend/pipeline_schedules/components/take_ownership_modal_spec.js b/spec/frontend/pipeline_schedules/components/take_ownership_modal_spec.js deleted file mode 100644 index d787611fe8f..00000000000 --- a/spec/frontend/pipeline_schedules/components/take_ownership_modal_spec.js +++ /dev/null @@ -1,54 +0,0 @@ -import { GlModal } from '@gitlab/ui'; -import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; -import TakeOwnershipModal from '~/pipeline_schedules/components/take_ownership_modal.vue'; - -describe('Take ownership modal', () => { - let wrapper; - const url = `/root/job-log-tester/-/pipeline_schedules/3/take_ownership`; - - const createComponent = (props = {}) => { - wrapper = shallowMountExtended(TakeOwnershipModal, { - propsData: { - ownershipUrl: url, - ...props, - }, - }); - }; - - const findModal = () => wrapper.findComponent(GlModal); - - beforeEach(() => { - createComponent(); - }); - - afterEach(() => { - wrapper.destroy(); - }); - - it('has a primary action set to a url and a post data-method', () => { - const actionPrimary = findModal().props('actionPrimary'); - - expect(actionPrimary.attributes).toEqual( - expect.objectContaining([ - { - category: 'primary', - variant: 'confirm', - href: url, - 'data-method': 'post', - }, - ]), - ); - }); - - it('shows a take ownership message', () => { - expect(findModal().text()).toBe( - 'Only the owner of a pipeline schedule can make changes to it. Do you want to take ownership of this schedule?', - ); - }); - - it('emits the cancel event when clicking on cancel', async () => { - findModal().vm.$emit('cancel'); - - expect(findModal().emitted('cancel')).toHaveLength(1); - }); -}); |