diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-15 21:09:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-15 21:09:01 +0300 |
commit | 74804f8c31491045b62a4b9fed9f819531462ea2 (patch) | |
tree | 87c58fb3a34d871e37ed0320a124c5b64f815334 /spec/frontend/integrations | |
parent | 10130901f1128c91596c4cbfe14b1e5c9f15032f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/integrations')
-rw-r--r-- | spec/frontend/integrations/edit/components/jira_issues_fields_spec.js | 49 | ||||
-rw-r--r-- | spec/frontend/integrations/edit/components/jira_upgrade_cta_spec.js | 30 |
2 files changed, 70 insertions, 9 deletions
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_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); + }); +}); |