Commit 42adac30 authored by Angelo Gulina's avatar Angelo Gulina

Update logic for better readability

Make tests more resilient
parent 0cf021ab
<script> <script>
import { GlButton, GlModalDirective } from '@gitlab/ui'; import { GlButton, GlModalDirective } from '@gitlab/ui';
import { pick, some } from 'lodash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { import {
enterActivationCode, enterActivationCode,
...@@ -70,7 +69,7 @@ export default { ...@@ -70,7 +69,7 @@ export default {
}, },
computed: { computed: {
canManageSubscription() { canManageSubscription() {
return this.customersPortalUrl; return this.customersPortalUrl && this.hasSubscription;
}, },
canSyncSubscription() { canSyncSubscription() {
return this.subscriptionSyncPath && this.isCloudType; return this.subscriptionSyncPath && this.isCloudType;
...@@ -94,15 +93,11 @@ export default { ...@@ -94,15 +93,11 @@ export default {
return this.subscription.type === subscriptionType.LEGACY; return this.subscription.type === subscriptionType.LEGACY;
}, },
shouldShowFooter() { shouldShowFooter() {
return some( return (
pick(this, [ this.canRemoveLicense ||
'hasSubscription', this.canManageSubscription ||
'canDeleteSubscription', this.canSyncSubscription ||
'canManageSubscription', this.canUploadLicense
'canSyncSubscription',
'canUploadSubscription',
]),
Boolean,
); );
}, },
subscriptionHistory() { subscriptionHistory() {
......
...@@ -159,7 +159,13 @@ describe('Subscription Breakdown', () => { ...@@ -159,7 +159,13 @@ describe('Subscription Breakdown', () => {
`( `(
'with url is $url and type is $type the sync button is shown: $shouldShow', 'with url is $url and type is $type the sync button is shown: $shouldShow',
({ url, type, shouldShow }) => { ({ url, type, shouldShow }) => {
const provide = { subscriptionSyncPath: url }; const provide = {
connectivityHelpURL: '',
customersPortalUrl: '',
licenseUploadPath: '',
licenseRemovePath: '',
subscriptionSyncPath: url,
};
const props = { subscription: { ...license.ULTIMATE, type } }; const props = { subscription: { ...license.ULTIMATE, type } };
const stubs = { GlCard, SubscriptionDetailsCard }; const stubs = { GlCard, SubscriptionDetailsCard };
createComponent({ props, provide, stubs }); createComponent({ props, provide, stubs });
...@@ -179,7 +185,13 @@ describe('Subscription Breakdown', () => { ...@@ -179,7 +185,13 @@ describe('Subscription Breakdown', () => {
`( `(
'with url is $url and type is $type the upload button is shown: $shouldShow', 'with url is $url and type is $type the upload button is shown: $shouldShow',
({ url, type, shouldShow }) => { ({ url, type, shouldShow }) => {
const provide = { licenseUploadPath: url }; const provide = {
connectivityHelpURL: '',
customersPortalUrl: '',
licenseRemovePath: '',
subscriptionSyncPath: '',
licenseUploadPath: url,
};
const props = { subscription: { ...license.ULTIMATE, type } }; const props = { subscription: { ...license.ULTIMATE, type } };
const stubs = { GlCard, SubscriptionDetailsCard }; const stubs = { GlCard, SubscriptionDetailsCard };
createComponent({ props, provide, stubs }); createComponent({ props, provide, stubs });
...@@ -194,7 +206,13 @@ describe('Subscription Breakdown', () => { ...@@ -194,7 +206,13 @@ describe('Subscription Breakdown', () => {
${''} | ${false} ${''} | ${false}
${undefined} | ${false} ${undefined} | ${false}
`('with url is $url the manage button is shown: $shouldShow', ({ url, shouldShow }) => { `('with url is $url the manage button is shown: $shouldShow', ({ url, shouldShow }) => {
const provide = { customersPortalUrl: url }; const provide = {
connectivityHelpURL: '',
licenseUploadPath: '',
licenseRemovePath: '',
subscriptionSyncPath: '',
customersPortalUrl: url,
};
const stubs = { GlCard, SubscriptionDetailsCard }; const stubs = { GlCard, SubscriptionDetailsCard };
createComponent({ provide, stubs }); createComponent({ provide, stubs });
...@@ -212,7 +230,13 @@ describe('Subscription Breakdown', () => { ...@@ -212,7 +230,13 @@ describe('Subscription Breakdown', () => {
`( `(
'with url is $url and type is $type the remove button is shown: $shouldShow', 'with url is $url and type is $type the remove button is shown: $shouldShow',
({ url, type, shouldShow }) => { ({ url, type, shouldShow }) => {
const provide = { licenseRemovePath: url }; const provide = {
connectivityHelpURL: '',
customersPortalUrl: '',
licenseUploadPath: '',
subscriptionSyncPath: '',
licenseRemovePath: url,
};
const props = { subscription: { ...license.ULTIMATE, type } }; const props = { subscription: { ...license.ULTIMATE, type } };
const stubs = { GlCard, SubscriptionDetailsCard }; const stubs = { GlCard, SubscriptionDetailsCard };
createComponent({ props, provide, stubs }); createComponent({ props, provide, stubs });
......
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