Commit bdab03b0 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch 'dz/fix-purchase-summary-date' into 'master'

Show expiration date for non-prorated purchases

See merge request gitlab-org/gitlab!78173
parents 7c36b542 0957a281
...@@ -154,6 +154,7 @@ export default { ...@@ -154,6 +154,7 @@ export default {
:quantity="quantity" :quantity="quantity"
:tax-rate="$options.taxRate" :tax-rate="$options.taxRate"
:subscription-end-date="endDate" :subscription-end-date="endDate"
:has-expiration="purchaseHasExpiration"
> >
<template #price-per-unit="{ price }"> <template #price-per-unit="{ price }">
<slot name="price-per-unit" :price="price"></slot> <slot name="price-per-unit" :price="price"></slot>
...@@ -178,6 +179,7 @@ export default { ...@@ -178,6 +179,7 @@ export default {
:quantity="quantity" :quantity="quantity"
:tax-rate="$options.taxRate" :tax-rate="$options.taxRate"
:subscription-end-date="endDate" :subscription-end-date="endDate"
:has-expiration="purchaseHasExpiration"
> >
<template #price-per-unit="{ price }"> <template #price-per-unit="{ price }">
<slot name="price-per-unit" :price="price"></slot> <slot name="price-per-unit" :price="price"></slot>
......
...@@ -52,6 +52,11 @@ export default { ...@@ -52,6 +52,11 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
hasExpiration: {
type: Boolean,
required: false,
default: false,
},
}, },
data() { data() {
return { return {
...@@ -61,7 +66,8 @@ export default { ...@@ -61,7 +66,8 @@ export default {
computed: { computed: {
endDate() { endDate() {
return ( return (
this.subscriptionEndDate || this.startDate.setFullYear(this.startDate.getFullYear() + 1) this.subscriptionEndDate ||
new Date(this.startDate).setFullYear(this.startDate.getFullYear() + 1)
); );
}, },
hasPositiveQuantity() { hasPositiveQuantity() {
...@@ -107,7 +113,7 @@ export default { ...@@ -107,7 +113,7 @@ export default {
<div class="gl-text-gray-500" data-testid="price-per-unit"> <div class="gl-text-gray-500" data-testid="price-per-unit">
<slot name="price-per-unit" :price="formattedPrice"></slot> <slot name="price-per-unit" :price="formattedPrice"></slot>
</div> </div>
<div v-if="subscriptionEndDate" class="gl-text-gray-500" data-testid="subscription-period"> <div v-if="hasExpiration" class="gl-text-gray-500" data-testid="subscription-period">
{{ {{
sprintf($options.i18n.dates, { sprintf($options.i18n.dates, {
startDate: formatDate(startDate), startDate: formatDate(startDate),
......
...@@ -83,7 +83,18 @@ describe('SummaryDetails', () => { ...@@ -83,7 +83,18 @@ describe('SummaryDetails', () => {
describe('when subscription has expiration', () => { describe('when subscription has expiration', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createComponent({ subscriptionEndDate: '2021-02-06' }); wrapper = createComponent({ hasExpiration: true });
});
it('renders subscription period', () => {
expect(findSubscriptionPeriod().isVisible()).toBe(true);
expect(findSubscriptionPeriod().text()).toBe('Jul 6, 2020 - Jul 6, 2021');
});
});
describe('when subscription has expiration and the end date provided', () => {
beforeEach(() => {
wrapper = createComponent({ subscriptionEndDate: '2021-02-06', hasExpiration: true });
}); });
it('renders subscription period', () => { it('renders subscription period', () => {
......
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