diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-14 21:09:18 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-14 21:09:18 +0300 |
commit | 844e3ef899c87d9e04cf8b89c8690afb013ba425 (patch) | |
tree | 9f65624c9d227d56444737bcf9070a958f172cc9 /spec/frontend/integrations | |
parent | a3dfd311f4660fc81e929058abd6e136ac884ed3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/integrations')
3 files changed, 129 insertions, 0 deletions
diff --git a/spec/frontend/integrations/index/components/integrations_list_spec.js b/spec/frontend/integrations/index/components/integrations_list_spec.js new file mode 100644 index 00000000000..94fd7fc84ee --- /dev/null +++ b/spec/frontend/integrations/index/components/integrations_list_spec.js @@ -0,0 +1,26 @@ +import { shallowMount } from '@vue/test-utils'; +import { extendedWrapper } from 'helpers/vue_test_utils_helper'; +import IntegrationsList from '~/integrations/index/components/integrations_list.vue'; +import { mockActiveIntegrations, mockInactiveIntegrations } from '../mock_data'; + +describe('IntegrationsList', () => { + let wrapper; + + const findActiveIntegrationsTable = () => wrapper.findByTestId('active-integrations-table'); + const findInactiveIntegrationsTable = () => wrapper.findByTestId('inactive-integrations-table'); + + const createComponent = (propsData = {}) => { + wrapper = extendedWrapper(shallowMount(IntegrationsList, { propsData })); + }; + + afterEach(() => { + wrapper.destroy(); + }); + + it('provides correct `integrations` prop to the IntegrationsTable instance', () => { + createComponent({ integrations: [...mockInactiveIntegrations, ...mockActiveIntegrations] }); + + expect(findActiveIntegrationsTable().props('integrations')).toEqual(mockActiveIntegrations); + expect(findInactiveIntegrationsTable().props('integrations')).toEqual(mockInactiveIntegrations); + }); +}); diff --git a/spec/frontend/integrations/index/components/integrations_table_spec.js b/spec/frontend/integrations/index/components/integrations_table_spec.js new file mode 100644 index 00000000000..bfe0a5987b4 --- /dev/null +++ b/spec/frontend/integrations/index/components/integrations_table_spec.js @@ -0,0 +1,53 @@ +import { GlTable, GlIcon } from '@gitlab/ui'; +import { mount } from '@vue/test-utils'; +import IntegrationsTable from '~/integrations/index/components/integrations_table.vue'; +import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; + +import { mockActiveIntegrations, mockInactiveIntegrations } from '../mock_data'; + +describe('IntegrationsTable', () => { + let wrapper; + + const findTable = () => wrapper.findComponent(GlTable); + + const createComponent = (propsData = {}) => { + wrapper = mount(IntegrationsTable, { + propsData: { + integrations: mockActiveIntegrations, + ...propsData, + }, + }); + }; + + afterEach(() => { + wrapper.destroy(); + }); + + describe.each([true, false])('when `showUpdatedAt` is %p', (showUpdatedAt) => { + beforeEach(() => { + createComponent({ showUpdatedAt }); + }); + + it(`${showUpdatedAt ? 'renders' : 'does not render'} content in "Last updated" column`, () => { + const headers = findTable().findAll('th'); + expect(headers.wrappers.some((header) => header.text() === 'Last updated')).toBe( + showUpdatedAt, + ); + expect(wrapper.findComponent(TimeAgoTooltip).exists()).toBe(showUpdatedAt); + }); + }); + + describe.each` + scenario | integrations | shouldRenderActiveIcon + ${'when integration is active'} | ${[mockActiveIntegrations[0]]} | ${true} + ${'when integration is inactive'} | ${[mockInactiveIntegrations[0]]} | ${false} + `('$scenario', ({ shouldRenderActiveIcon, integrations }) => { + beforeEach(() => { + createComponent({ integrations }); + }); + + it(`${shouldRenderActiveIcon ? 'renders' : 'does not render'} icon in first column`, () => { + expect(findTable().findComponent(GlIcon).exists()).toBe(shouldRenderActiveIcon); + }); + }); +}); diff --git a/spec/frontend/integrations/index/mock_data.js b/spec/frontend/integrations/index/mock_data.js new file mode 100644 index 00000000000..2231687d255 --- /dev/null +++ b/spec/frontend/integrations/index/mock_data.js @@ -0,0 +1,50 @@ +export const mockActiveIntegrations = [ + { + active: true, + title: 'Asana', + description: 'Asana - Teamwork without email', + updated_at: '2021-03-18T00:27:09.634Z', + edit_path: + '/gitlab-qa-sandbox-group/project_with_jenkins_6a55a67c-57c6ed0597c9319a/-/services/asana/edit', + name: 'asana', + }, + { + active: true, + title: 'Jira', + description: 'Jira issue tracker', + updated_at: '2021-01-29T06:41:25.806Z', + edit_path: + '/gitlab-qa-sandbox-group/project_with_jenkins_6a55a67c-57c6ed0597c9319a/-/services/jira/edit', + name: 'jira', + }, +]; + +export const mockInactiveIntegrations = [ + { + active: false, + title: 'Webex Teams', + description: 'Receive event notifications in Webex Teams', + updated_at: null, + edit_path: + '/gitlab-qa-sandbox-group/project_with_jenkins_6a55a67c-57c6ed0597c9319a/-/services/webex_teams/edit', + name: 'webex_teams', + }, + { + active: false, + title: 'YouTrack', + description: 'YouTrack issue tracker', + updated_at: null, + edit_path: + '/gitlab-qa-sandbox-group/project_with_jenkins_6a55a67c-57c6ed0597c9319a/-/services/youtrack/edit', + name: 'youtrack', + }, + { + active: false, + title: 'Atlassian Bamboo CI', + description: 'A continuous integration and build server', + updated_at: null, + edit_path: + '/gitlab-qa-sandbox-group/project_with_jenkins_6a55a67c-57c6ed0597c9319a/-/services/bamboo/edit', + name: 'bamboo', + }, +]; |