Commit e2b538d4 authored by Vitaly Slobodin's avatar Vitaly Slobodin

Adjust specs after rebase

parent ac047c40
<script> <script>
import { GlAlert, GlSprintf } from '@gitlab/ui'; import { GlAlert, GlSprintf } from '@gitlab/ui';
import Cookie from 'js-cookie'; import Cookie from 'js-cookie';
import { helpPagePath } from '~/helpers/help_page_helper';
import { formatDate, getDayDifference } from '~/lib/utils/datetime_utility'; import { formatDate, getDayDifference } from '~/lib/utils/datetime_utility';
import { s__, __, sprintf } from '~/locale'; import { s__, __, sprintf } from '~/locale';
...@@ -18,6 +19,10 @@ it will be charged. Otherwise, you will receive an invoice.`), ...@@ -18,6 +19,10 @@ it will be charged. Otherwise, you will receive an invoice.`),
const CONTACT_SUPPORT_URL = 'https://about.gitlab.com/support/#contact-support'; const CONTACT_SUPPORT_URL = 'https://about.gitlab.com/support/#contact-support';
const qrtlyReconciliationHelpPageUrl = helpPagePath('subscriptions/self_managed/index', {
anchor: 'quarterly-subscription-reconciliation',
});
export default { export default {
name: 'QrtlyReconciliationAlert', name: 'QrtlyReconciliationAlert',
components: { components: {
...@@ -26,7 +31,7 @@ export default { ...@@ -26,7 +31,7 @@ export default {
}, },
props: { props: {
date: { date: {
type: Number, type: Date,
required: true, required: true,
}, },
cookieKey: { cookieKey: {
...@@ -51,6 +56,7 @@ export default { ...@@ -51,6 +56,7 @@ export default {
}, },
i18n, i18n,
CONTACT_SUPPORT_URL, CONTACT_SUPPORT_URL,
qrtlyReconciliationHelpPageUrl,
}; };
</script> </script>
...@@ -60,6 +66,7 @@ export default { ...@@ -60,6 +66,7 @@ export default {
variant="info" variant="info"
:title="alertTitle" :title="alertTitle"
:primary-button-text="$options.i18n.learnMore" :primary-button-text="$options.i18n.learnMore"
:primary-button-link="$options.qrtlyReconciliationHelpPageUrl"
:secondary-button-text="$options.i18n.contactSupport" :secondary-button-text="$options.i18n.contactSupport"
:secondary-button-link="$options.CONTACT_SUPPORT_URL" :secondary-button-link="$options.CONTACT_SUPPORT_URL"
@dismiss="handleDismiss" @dismiss="handleDismiss"
......
...@@ -13,7 +13,7 @@ export const initQrtlyReconciliationAlert = (selector = '#js-qrtly-reconciliatio ...@@ -13,7 +13,7 @@ export const initQrtlyReconciliationAlert = (selector = '#js-qrtly-reconciliatio
render(createElement) { render(createElement) {
return createElement(QrtlyReconciliationAlert, { return createElement(QrtlyReconciliationAlert, {
props: { props: {
date: Date.parse(el.dataset.reconciliationDate), date: new Date(el.dataset.reconciliationDate),
cookieKey: el.dataset.cookieKey, cookieKey: el.dataset.cookieKey,
}, },
}); });
......
import { GlAlert } from '@gitlab/ui'; import { GlAlert } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import Cookie from 'js-cookie';
import QrtlyReconciliationAlert from 'ee/admin/components/qrtly_reconciliation_alert.vue'; import QrtlyReconciliationAlert from 'ee/admin/components/qrtly_reconciliation_alert.vue';
jest.mock('js-cookie', () => ({
set: jest.fn(),
}));
describe('Qrtly Reconciliation Alert', () => { describe('Qrtly Reconciliation Alert', () => {
let wrapper; let wrapper;
const reconciliationDate = new Date('2020-01-01'); const reconciliationDate = new Date('2020-07-10');
const createComponent = () => { const createComponent = () => {
return shallowMount(QrtlyReconciliationAlert, { return shallowMount(QrtlyReconciliationAlert, {
propsData: { propsData: {
cookieKey: 'key',
date: reconciliationDate, date: reconciliationDate,
}, },
}); });
...@@ -24,7 +30,28 @@ describe('Qrtly Reconciliation Alert', () => { ...@@ -24,7 +30,28 @@ describe('Qrtly Reconciliation Alert', () => {
describe('Rendering', () => { describe('Rendering', () => {
it('renders alert title with date', () => { it('renders alert title with date', () => {
expect(wrapper.find(GlAlert).attributes('title')).toContain(`occur on ${reconciliationDate}`); expect(wrapper.find(GlAlert).attributes('title')).toContain(`occur on 2020-07-10`);
});
it('has the correct link to the help page', () => {
expect(wrapper.find(GlAlert).attributes('primarybuttonlink')).toBe(
'/help/subscriptions/self_managed/index#quarterly-subscription-reconciliation',
);
});
it('has the correct link to contact support', () => {
expect(wrapper.find(GlAlert).attributes('secondarybuttonlink')).toBe(
'https://about.gitlab.com/support/#contact-support',
);
});
});
describe('methods', () => {
it('sets the cookie on dismis', () => {
wrapper.find(GlAlert).vm.$emit('dismiss');
expect(Cookie.set).toHaveBeenCalledTimes(1);
expect(Cookie.set).toHaveBeenCalledWith('key', true, { expires: 4 });
}); });
}); });
}); });
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