diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/frontend/integrations | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/frontend/integrations')
3 files changed, 38 insertions, 43 deletions
diff --git a/spec/frontend/integrations/edit/components/integration_form_spec.js b/spec/frontend/integrations/edit/components/integration_form_spec.js index ca481e009cf..a2bdece821f 100644 --- a/spec/frontend/integrations/edit/components/integration_form_spec.js +++ b/spec/frontend/integrations/edit/components/integration_form_spec.js @@ -1,4 +1,4 @@ -import { GlForm } from '@gitlab/ui'; +import { GlBadge, GlForm } from '@gitlab/ui'; import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import * as Sentry from '@sentry/browser'; @@ -18,11 +18,18 @@ import { integrationLevels, I18N_SUCCESSFUL_CONNECTION_MESSAGE, I18N_DEFAULT_ERROR_MESSAGE, + billingPlans, + billingPlanNames, } from '~/integrations/constants'; import { createStore } from '~/integrations/edit/store'; import httpStatus from '~/lib/utils/http_status'; import { refreshCurrentPage } from '~/lib/utils/url_utility'; -import { mockIntegrationProps, mockField, mockSectionConnection } from '../mock_data'; +import { + mockIntegrationProps, + mockField, + mockSectionConnection, + mockSectionJiraIssues, +} from '../mock_data'; jest.mock('@sentry/browser'); jest.mock('~/lib/utils/url_utility'); @@ -72,6 +79,7 @@ describe('IntegrationForm', () => { const findInstanceOrGroupSaveButton = () => wrapper.findByTestId('save-button-instance-group'); const findTestButton = () => wrapper.findByTestId('test-button'); const findTriggerFields = () => wrapper.findComponent(TriggerFields); + const findGlBadge = () => wrapper.findComponent(GlBadge); const findGlForm = () => wrapper.findComponent(GlForm); const findRedirectToField = () => wrapper.findByTestId('redirect-to-field'); const findDynamicField = () => wrapper.findComponent(DynamicField); @@ -327,9 +335,21 @@ describe('IntegrationForm', () => { expect(connectionSection.find('h4').text()).toBe(mockSectionConnection.title); expect(connectionSection.find('p').text()).toBe(mockSectionConnection.description); + expect(findGlBadge().exists()).toBe(false); expect(findConnectionSectionComponent().exists()).toBe(true); }); + it('renders GlBadge when `plan` is present', () => { + createComponent({ + customStateProps: { + sections: [mockSectionConnection, mockSectionJiraIssues], + }, + }); + + expect(findGlBadge().exists()).toBe(true); + expect(findGlBadge().text()).toMatchInterpolatedText(billingPlanNames[billingPlans.PREMIUM]); + }); + it('passes only fields with section type', () => { const sectionFields = [ { name: 'username', type: 'text', section: mockSectionConnection.type }, 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 94e370a485f..b4c5d4f9957 100644 --- a/spec/frontend/integrations/edit/components/jira_issues_fields_spec.js +++ b/spec/frontend/integrations/edit/components/jira_issues_fields_spec.js @@ -10,7 +10,6 @@ describe('JiraIssuesFields', () => { let wrapper; const defaultProps = { - showJiraIssuesIntegration: true, showJiraVulnerabilitiesIntegration: true, upgradePlanPath: 'https://gitlab.com', }; @@ -42,8 +41,6 @@ describe('JiraIssuesFields', () => { findEnableCheckbox().find('[type=checkbox]').attributes('disabled'); const findProjectKey = () => wrapper.findComponent(GlFormInput); const findProjectKeyFormGroup = () => wrapper.findByTestId('project-key-form-group'); - const findPremiumUpgradeCTA = () => wrapper.findByTestId('premium-upgrade-cta'); - const findUltimateUpgradeCTA = () => wrapper.findByTestId('ultimate-upgrade-cta'); const findJiraForVulnerabilities = () => wrapper.findByTestId('jira-for-vulnerabilities'); const setEnableCheckbox = async (isEnabled = true) => findEnableCheckbox().vm.$emit('input', isEnabled); @@ -55,19 +52,16 @@ describe('JiraIssuesFields', () => { describe('template', () => { describe.each` - showJiraIssuesIntegration | showJiraVulnerabilitiesIntegration - ${false} | ${false} - ${false} | ${true} - ${true} | ${false} - ${true} | ${true} + showJiraIssuesIntegration + ${false} + ${true} `( - 'when `showJiraIssuesIntegration` is $jiraIssues and `showJiraVulnerabilitiesIntegration` is $jiraVulnerabilities', - ({ showJiraIssuesIntegration, showJiraVulnerabilitiesIntegration }) => { + 'when showJiraIssuesIntegration = $showJiraIssuesIntegration', + ({ showJiraIssuesIntegration }) => { beforeEach(() => { createComponent({ props: { showJiraIssuesIntegration, - showJiraVulnerabilitiesIntegration, }, }); }); @@ -77,39 +71,12 @@ describe('JiraIssuesFields', () => { expect(findEnableCheckbox().exists()).toBe(true); expect(findEnableCheckboxDisabled()).toBeUndefined(); }); - - it('does not render the Premium CTA', () => { - expect(findPremiumUpgradeCTA().exists()).toBe(false); - }); - - if (!showJiraVulnerabilitiesIntegration) { - it.each` - scenario | enableJiraIssues - ${'when "Enable Jira issues" is checked, renders Ultimate upgrade CTA'} | ${true} - ${'when "Enable Jira issues" is unchecked, does not render Ultimate upgrade CTA'} | ${false} - `('$scenario', async ({ enableJiraIssues }) => { - if (enableJiraIssues) { - await setEnableCheckbox(); - } - expect(findUltimateUpgradeCTA().exists()).toBe(enableJiraIssues); - }); - } } else { - it('does not render enable checkbox', () => { - expect(findEnableCheckbox().exists()).toBe(false); - }); - - it('renders the Premium CTA', () => { - const premiumUpgradeCTA = findPremiumUpgradeCTA(); - - expect(premiumUpgradeCTA.exists()).toBe(true); - expect(premiumUpgradeCTA.props('upgradePlanPath')).toBe(defaultProps.upgradePlanPath); + it('renders enable checkbox as disabled', () => { + expect(findEnableCheckbox().exists()).toBe(true); + expect(findEnableCheckboxDisabled()).toBe('disabled'); }); } - - it('does not render the Ultimate CTA', () => { - expect(findUltimateUpgradeCTA().exists()).toBe(false); - }); }, ); diff --git a/spec/frontend/integrations/edit/mock_data.js b/spec/frontend/integrations/edit/mock_data.js index 36850a0a33a..ac0c7d244e3 100644 --- a/spec/frontend/integrations/edit/mock_data.js +++ b/spec/frontend/integrations/edit/mock_data.js @@ -37,3 +37,11 @@ export const mockSectionConnection = { title: 'Connection details', description: 'Learn more on how to configure this integration.', }; + +export const mockSectionJiraIssues = { + type: 'jira_issues', + title: 'Issues', + description: + 'Work on Jira issues without leaving GitLab. Add a Jira menu to access a read-only list of your Jira issues. Learn more.', + plan: 'premium', +}; |