diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/frontend/integrations | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) | |
download | gitlab-ce-9dc93a4519d9d5d7be48ff274127136236a3adb3.tar.gz |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/frontend/integrations')
8 files changed, 297 insertions, 32 deletions
diff --git a/spec/frontend/integrations/edit/components/dynamic_field_spec.js b/spec/frontend/integrations/edit/components/dynamic_field_spec.js index aaca9fc4e62..2ebb3333c0f 100644 --- a/spec/frontend/integrations/edit/components/dynamic_field_spec.js +++ b/spec/frontend/integrations/edit/components/dynamic_field_spec.js @@ -192,17 +192,6 @@ describe('DynamicField', () => { expect(findGlFormGroup().find('label').text()).toBe(defaultProps.title); }); - - describe('for password field with some value (hidden by backend)', () => { - it('renders label with new password title', () => { - createComponent({ - type: 'password', - value: 'true', - }); - - expect(findGlFormGroup().find('label').text()).toBe(`Enter new ${defaultProps.title}`); - }); - }); }); describe('validations', () => { diff --git a/spec/frontend/integrations/edit/components/jira_issues_fields_spec.js b/spec/frontend/integrations/edit/components/jira_issues_fields_spec.js index 3938e7c7c22..d08a1904e06 100644 --- a/spec/frontend/integrations/edit/components/jira_issues_fields_spec.js +++ b/spec/frontend/integrations/edit/components/jira_issues_fields_spec.js @@ -1,7 +1,7 @@ import { GlFormCheckbox, GlFormInput } from '@gitlab/ui'; import { mount } from '@vue/test-utils'; - import JiraIssuesFields from '~/integrations/edit/components/jira_issues_fields.vue'; +import JiraUpgradeCta from '~/integrations/edit/components/jira_upgrade_cta.vue'; import eventHub from '~/integrations/edit/event_hub'; describe('JiraIssuesFields', () => { @@ -28,23 +28,46 @@ describe('JiraIssuesFields', () => { } }); - const findEnableCheckbox = () => wrapper.find(GlFormCheckbox); - const findProjectKey = () => wrapper.find(GlFormInput); - const expectedBannerText = 'This is a Premium feature'; + const findEnableCheckbox = () => wrapper.findComponent(GlFormCheckbox); + const findProjectKey = () => wrapper.findComponent(GlFormInput); + const findJiraUpgradeCta = () => wrapper.findComponent(JiraUpgradeCta); const findJiraForVulnerabilities = () => wrapper.find('[data-testid="jira-for-vulnerabilities"]'); const setEnableCheckbox = async (isEnabled = true) => findEnableCheckbox().vm.$emit('input', isEnabled); + describe('jira issues call to action', () => { + it('shows the premium message', () => { + createComponent({ + props: { showJiraIssuesIntegration: false }, + }); + + expect(findJiraUpgradeCta().props()).toMatchObject({ + showPremiumMessage: true, + showUltimateMessage: false, + }); + }); + + it('shows the ultimate message', () => { + createComponent({ + props: { + showJiraIssuesIntegration: true, + showJiraVulnerabilitiesIntegration: false, + }, + }); + + expect(findJiraUpgradeCta().props()).toMatchObject({ + showPremiumMessage: false, + showUltimateMessage: true, + }); + }); + }); + describe('template', () => { describe('upgrade banner for non-Premium user', () => { beforeEach(() => { createComponent({ props: { initialProjectKey: '', showJiraIssuesIntegration: false } }); }); - it('shows upgrade banner', () => { - expect(wrapper.text()).toContain(expectedBannerText); - }); - it('does not show checkbox and input field', () => { expect(findEnableCheckbox().exists()).toBe(false); expect(findProjectKey().exists()).toBe(false); @@ -57,7 +80,7 @@ describe('JiraIssuesFields', () => { }); it('does not show upgrade banner', () => { - expect(wrapper.text()).not.toContain(expectedBannerText); + expect(findJiraUpgradeCta().exists()).toBe(false); }); // As per https://vuejs.org/v2/guide/forms.html#Checkbox-1, @@ -125,6 +148,14 @@ describe('JiraIssuesFields', () => { }, ); + it('passes down the correct show-full-feature property', async () => { + await setEnableCheckbox(true); + expect(findJiraForVulnerabilities().attributes('show-full-feature')).toBe('true'); + wrapper.setProps({ showJiraVulnerabilitiesIntegration: false }); + await wrapper.vm.$nextTick(); + expect(findJiraForVulnerabilities().attributes('show-full-feature')).toBeUndefined(); + }); + it('passes down the correct initial-issue-type-id value when value is empty', async () => { await setEnableCheckbox(true); expect(findJiraForVulnerabilities().attributes('initial-issue-type-id')).toBeUndefined(); diff --git a/spec/frontend/integrations/edit/components/jira_trigger_fields_spec.js b/spec/frontend/integrations/edit/components/jira_trigger_fields_spec.js index c6e7ee44355..5c04add61a1 100644 --- a/spec/frontend/integrations/edit/components/jira_trigger_fields_spec.js +++ b/spec/frontend/integrations/edit/components/jira_trigger_fields_spec.js @@ -30,14 +30,23 @@ describe('JiraTriggerFields', () => { const findCommentSettings = () => wrapper.find('[data-testid="comment-settings"]'); const findCommentDetail = () => wrapper.find('[data-testid="comment-detail"]'); const findCommentSettingsCheckbox = () => findCommentSettings().find(GlFormCheckbox); + const findIssueTransitionEnabled = () => + wrapper.find('[data-testid="issue-transition-enabled"] input[type="checkbox"]'); + const findIssueTransitionMode = () => wrapper.find('[data-testid="issue-transition-mode"]'); + const findIssueTransitionModeRadios = () => + findIssueTransitionMode().findAll('input[type="radio"]'); + const findIssueTransitionIdsField = () => + wrapper.find('input[type="text"][name="service[jira_issue_transition_id]"]'); describe('template', () => { describe('initialTriggerCommit and initialTriggerMergeRequest are false', () => { - it('does not show comment settings', () => { + it('does not show trigger settings', () => { createComponent(); expect(findCommentSettings().isVisible()).toBe(false); expect(findCommentDetail().isVisible()).toBe(false); + expect(findIssueTransitionEnabled().exists()).toBe(false); + expect(findIssueTransitionMode().exists()).toBe(false); }); }); @@ -48,9 +57,11 @@ describe('JiraTriggerFields', () => { }); }); - it('shows comment settings', () => { + it('shows trigger settings', () => { expect(findCommentSettings().isVisible()).toBe(true); expect(findCommentDetail().isVisible()).toBe(false); + expect(findIssueTransitionEnabled().isVisible()).toBe(true); + expect(findIssueTransitionMode().exists()).toBe(false); }); // As per https://vuejs.org/v2/guide/forms.html#Checkbox-1, @@ -73,13 +84,15 @@ describe('JiraTriggerFields', () => { }); describe('initialTriggerMergeRequest is true', () => { - it('shows comment settings', () => { + it('shows trigger settings', () => { createComponent({ initialTriggerMergeRequest: true, }); expect(findCommentSettings().isVisible()).toBe(true); expect(findCommentDetail().isVisible()).toBe(false); + expect(findIssueTransitionEnabled().isVisible()).toBe(true); + expect(findIssueTransitionMode().exists()).toBe(false); }); }); @@ -95,21 +108,94 @@ describe('JiraTriggerFields', () => { }); }); - it('disables checkboxes and radios if inheriting', () => { + describe('initialJiraIssueTransitionAutomatic is false, initialJiraIssueTransitionId is not set', () => { + it('selects automatic transitions when enabling transitions', () => { + createComponent({ + initialTriggerCommit: true, + initialEnableComments: true, + }); + + const checkbox = findIssueTransitionEnabled(); + expect(checkbox.element.checked).toBe(false); + checkbox.trigger('click'); + + return wrapper.vm.$nextTick().then(() => { + const [radio1, radio2] = findIssueTransitionModeRadios().wrappers; + expect(radio1.element.checked).toBe(true); + expect(radio2.element.checked).toBe(false); + }); + }); + }); + + describe('initialJiraIssueTransitionAutomatic is true', () => { + it('uses automatic transitions', () => { + createComponent({ + initialTriggerCommit: true, + initialJiraIssueTransitionAutomatic: true, + }); + + expect(findIssueTransitionEnabled().element.checked).toBe(true); + + const [radio1, radio2] = findIssueTransitionModeRadios().wrappers; + expect(radio1.element.checked).toBe(true); + expect(radio2.element.checked).toBe(false); + + expect(findIssueTransitionIdsField().exists()).toBe(false); + }); + }); + + describe('initialJiraIssueTransitionId is set', () => { + it('uses custom transitions', () => { + createComponent({ + initialTriggerCommit: true, + initialJiraIssueTransitionId: '1, 2, 3', + }); + + expect(findIssueTransitionEnabled().element.checked).toBe(true); + + const [radio1, radio2] = findIssueTransitionModeRadios().wrappers; + expect(radio1.element.checked).toBe(false); + expect(radio2.element.checked).toBe(true); + + const field = findIssueTransitionIdsField(); + expect(field.isVisible()).toBe(true); + expect(field.element).toMatchObject({ + type: 'text', + value: '1, 2, 3', + }); + }); + }); + + describe('initialJiraIssueTransitionAutomatic is true, initialJiraIssueTransitionId is set', () => { + it('uses automatic transitions', () => { + createComponent({ + initialTriggerCommit: true, + initialJiraIssueTransitionAutomatic: true, + initialJiraIssueTransitionId: '1, 2, 3', + }); + + expect(findIssueTransitionEnabled().element.checked).toBe(true); + + const [radio1, radio2] = findIssueTransitionModeRadios().wrappers; + expect(radio1.element.checked).toBe(true); + expect(radio2.element.checked).toBe(false); + + expect(findIssueTransitionIdsField().exists()).toBe(false); + }); + }); + + it('disables input fields if inheriting', () => { createComponent( { initialTriggerCommit: true, initialEnableComments: true, + initialJiraIssueTransitionId: '1, 2, 3', }, true, ); - wrapper.findAll('[type=checkbox]').wrappers.forEach((checkbox) => { - expect(checkbox.attributes('disabled')).toBe('disabled'); - }); - - wrapper.findAll('[type=radio]').wrappers.forEach((radio) => { - expect(radio.attributes('disabled')).toBe('disabled'); + wrapper.findAll('[type=text], [type=checkbox], [type=radio]').wrappers.forEach((input) => { + expect(input.attributes('disabled')).toBe('disabled'); }); }); }); diff --git a/spec/frontend/integrations/edit/components/jira_upgrade_cta_spec.js b/spec/frontend/integrations/edit/components/jira_upgrade_cta_spec.js new file mode 100644 index 00000000000..e49a1619627 --- /dev/null +++ b/spec/frontend/integrations/edit/components/jira_upgrade_cta_spec.js @@ -0,0 +1,30 @@ +import { shallowMount } from '@vue/test-utils'; +import JiraUpgradeCta from '~/integrations/edit/components/jira_upgrade_cta.vue'; + +describe('JiraUpgradeCta', () => { + let wrapper; + + const contentMessage = 'Upgrade your plan to enable this feature of the Jira Integration.'; + + const createComponent = (propsData) => { + wrapper = shallowMount(JiraUpgradeCta, { + propsData, + }); + }; + + afterEach(() => { + wrapper.destroy(); + }); + + it('displays the correct message for premium and lower users', () => { + createComponent({ showPremiumMessage: true }); + expect(wrapper.html()).toContain('This is a Premium feature'); + expect(wrapper.html()).toContain(contentMessage); + }); + + it('displays the correct message for ultimate and lower users', () => { + createComponent({ showUltimateMessage: true }); + expect(wrapper.html()).toContain('This is an Ultimate feature'); + expect(wrapper.html()).toContain(contentMessage); + }); +}); diff --git a/spec/frontend/integrations/edit/components/trigger_fields_spec.js b/spec/frontend/integrations/edit/components/trigger_fields_spec.js index 3e5326812b1..b9d16464e72 100644 --- a/spec/frontend/integrations/edit/components/trigger_fields_spec.js +++ b/spec/frontend/integrations/edit/components/trigger_fields_spec.js @@ -138,11 +138,11 @@ describe('TriggerFields', () => { const expectedResults = [ { name: 'service[push_channel]', - placeholder: 'Slack channels (e.g. general, development)', + placeholder: 'general, development', }, { name: 'service[merge_request_channel]', - placeholder: 'Slack channels (e.g. general, development)', + placeholder: 'general, development', }, ]; 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', + }, +]; |