Commit 82748bbb authored by Tom Quirk's avatar Tom Quirk

Consolidate Jira integration CTA specs

Per reviewer feedback, paramaterize CTA specs
for better readability.
parent 703c5542
...@@ -44,66 +44,66 @@ describe('JiraIssuesFields', () => { ...@@ -44,66 +44,66 @@ describe('JiraIssuesFields', () => {
findEnableCheckbox().vm.$emit('input', isEnabled); findEnableCheckbox().vm.$emit('input', isEnabled);
describe('template', () => { describe('template', () => {
describe('when `showJiraIssuesIntegration` is false', () => { describe.each`
beforeEach(() => { showJiraIssuesIntegration | showJiraVulnerabilitiesIntegration
createComponent({ ${false} | ${false}
props: { showJiraIssuesIntegration: false }, ${false} | ${true}
}); ${true} | ${false}
}); ${true} | ${true}
`(
it('shows the premium CTA', () => { 'when `showJiraIssuesIntegration` is $jiraIssues and `showJiraVulnerabilitiesIntegration` is $jiraVulnerabilities',
const premiumUpgradeCTA = findPremiumUpgradeCTA(); ({ showJiraIssuesIntegration, showJiraVulnerabilitiesIntegration }) => {
beforeEach(() => {
expect(premiumUpgradeCTA.exists()).toBe(true); createComponent({
expect(premiumUpgradeCTA.props('upgradePlanPath')).toBe(defaultProps.upgradePlanPath); props: {
}); showJiraIssuesIntegration,
showJiraVulnerabilitiesIntegration,
it('does not show checkbox and input field', () => { },
expect(findEnableCheckbox().exists()).toBe(false); });
expect(findProjectKey().exists()).toBe(false);
});
});
describe('when `showJiraIssuesIntegration` is true and `showJiraVulnerabilitiesIntegration` is false', () => {
beforeEach(() => {
createComponent({
props: { showJiraIssuesIntegration: true, showJiraVulnerabilitiesIntegration: false },
}); });
});
it('renders "Enable Jira Issues" checkbox', () => {
expect(findEnableCheckbox().exists()).toBe(true);
expect(findEnableCheckboxDisabled()).toBeUndefined();
});
it.each` if (showJiraIssuesIntegration) {
scenario | enableJiraIssues it('renders checkbox and input field', () => {
${'when "Enable Jira Issues" is checked, shows ultimate upgrade CTA'} | ${true} expect(findEnableCheckbox().exists()).toBe(true);
${'when "Enable Jira Issues" is unchecked, does not show ultimate upgrade CTA'} | ${false} expect(findEnableCheckboxDisabled()).toBeUndefined();
`('$scenario', async ({ enableJiraIssues }) => { expect(findProjectKey().exists()).toBe(true);
createComponent({ });
props: { showJiraIssuesIntegration: true, showJiraVulnerabilitiesIntegration: false },
}); it('does not render the Premium CTA', () => {
expect(findPremiumUpgradeCTA().exists()).toBe(false);
if (enableJiraIssues) { });
await setEnableCheckbox();
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 checkbox and input field', () => {
expect(findEnableCheckbox().exists()).toBe(false);
expect(findProjectKey().exists()).toBe(false);
});
it('renders the Premium CTA', () => {
const premiumUpgradeCTA = findPremiumUpgradeCTA();
expect(premiumUpgradeCTA.exists()).toBe(true);
expect(premiumUpgradeCTA.props('upgradePlanPath')).toBe(defaultProps.upgradePlanPath);
});
} }
expect(findPremiumUpgradeCTA().exists()).toBe(false); it('does not render the Ultimate CTA', () => {
expect(findUltimateUpgradeCTA().exists()).toBe(enableJiraIssues); expect(findUltimateUpgradeCTA().exists()).toBe(false);
});
});
describe('when `showJiraIssuesIntegration` is true and `showJiraVulnerabilitiesIntegration` is true', () => {
it('does not show any upgrade CTA', () => {
createComponent({
props: { showJiraIssuesIntegration: true, showJiraVulnerabilitiesIntegration: true },
}); });
},
expect(findPremiumUpgradeCTA().exists()).toBe(false); );
expect(findUltimateUpgradeCTA().exists()).toBe(false);
});
});
describe('Enable Jira issues checkbox', () => { describe('Enable Jira issues checkbox', () => {
beforeEach(() => { beforeEach(() => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment