Commit aa7aed3e authored by Angelo Gulina's avatar Angelo Gulina

Update Subscription Sync enums and specs

The frontend can't really tell whether the subscription sync
has been successfull or not, given the async nature of the
process. Therefore we will consider it pending if not failed
parent 8ddd7787
...@@ -114,7 +114,7 @@ export default { ...@@ -114,7 +114,7 @@ export default {
}, },
}, },
methods: { methods: {
didDismissSuccessAlert() { didDismissAlert() {
this.shouldShowNotifications = false; this.shouldShowNotifications = false;
}, },
syncSubscription() { syncSubscription() {
...@@ -123,7 +123,7 @@ export default { ...@@ -123,7 +123,7 @@ export default {
axios axios
.post(this.subscriptionSyncPath) .post(this.subscriptionSyncPath)
.then(() => { .then(() => {
this.subscriptionSyncStatus = subscriptionSyncStatus.SYNC_SUCCESS; this.subscriptionSyncStatus = subscriptionSyncStatus.SYNC_PENDING;
}) })
.catch(() => { .catch(() => {
this.subscriptionSyncStatus = subscriptionSyncStatus.SYNC_FAILURE; this.subscriptionSyncStatus = subscriptionSyncStatus.SYNC_FAILURE;
...@@ -148,7 +148,7 @@ export default { ...@@ -148,7 +148,7 @@ export default {
v-if="shouldShowNotifications" v-if="shouldShowNotifications"
class="mb-4" class="mb-4"
:sync-status="subscriptionSyncStatus" :sync-status="subscriptionSyncStatus"
@success-alert-dismissed="didDismissSuccessAlert" @info-alert-dismissed="didDismissAlert"
/> />
<section class="row gl-mb-5"> <section class="row gl-mb-5">
<div class="col-md-6 gl-mb-5"> <div class="col-md-6 gl-mb-5">
......
...@@ -3,12 +3,12 @@ import { GlAlert, GlLink, GlSprintf } from '@gitlab/ui'; ...@@ -3,12 +3,12 @@ import { GlAlert, GlLink, GlSprintf } from '@gitlab/ui';
import { import {
manualSyncFailureText, manualSyncFailureText,
connectivityIssue, connectivityIssue,
manualSyncSuccessfulTitle, manualSyncPendingTitle,
subscriptionSyncStatus, subscriptionSyncStatus,
manualSyncSuccessfulText, manualSyncPendingText,
} from '../constants'; } from '../constants';
export const SUCCESS_ALERT_DISMISSED_EVENT = 'success-alert-dismissed'; export const INFO_ALERT_DISMISSED_EVENT = 'info-alert-dismissed';
const subscriptionSyncStatusValidator = (value) => const subscriptionSyncStatusValidator = (value) =>
!value || Object.values(subscriptionSyncStatus).includes(value); !value || Object.values(subscriptionSyncStatus).includes(value);
...@@ -16,8 +16,8 @@ const subscriptionSyncStatusValidator = (value) => ...@@ -16,8 +16,8 @@ const subscriptionSyncStatusValidator = (value) =>
export default { export default {
name: 'SubscriptionSyncNotifications', name: 'SubscriptionSyncNotifications',
i18n: { i18n: {
manualSyncSuccessfulText, manualSyncPendingText,
manualSyncSuccessfulTitle, manualSyncPendingTitle,
manualSyncFailureText, manualSyncFailureText,
connectivityIssue, connectivityIssue,
}, },
...@@ -35,16 +35,16 @@ export default { ...@@ -35,16 +35,16 @@ export default {
}, },
}, },
computed: { computed: {
syncDidSuccess() { isSyncPending() {
return this.syncStatus === subscriptionSyncStatus.SYNC_SUCCESS; return this.syncStatus === subscriptionSyncStatus.SYNC_PENDING;
}, },
syncDidFail() { syncDidFail() {
return this.syncStatus === subscriptionSyncStatus.SYNC_FAILURE; return this.syncStatus === subscriptionSyncStatus.SYNC_FAILURE;
}, },
}, },
methods: { methods: {
didDismissSuccessAlert() { didDismissInfoAlert() {
this.$emit(SUCCESS_ALERT_DISMISSED_EVENT); this.$emit(INFO_ALERT_DISMISSED_EVENT);
}, },
}, },
}; };
...@@ -53,12 +53,12 @@ export default { ...@@ -53,12 +53,12 @@ export default {
<template> <template>
<div> <div>
<gl-alert <gl-alert
v-if="syncDidSuccess" v-if="isSyncPending"
variant="info" variant="info"
:title="$options.i18n.manualSyncSuccessfulTitle" :title="$options.i18n.manualSyncPendingTitle"
data-testid="sync-success-alert" data-testid="sync-info-alert"
@dismiss="didDismissSuccessAlert" @dismiss="didDismissInfoAlert"
>{{ $options.i18n.manualSyncSuccessfulText }}</gl-alert >{{ $options.i18n.manualSyncPendingText }}</gl-alert
> >
<gl-alert <gl-alert
v-else-if="syncDidFail" v-else-if="syncDidFail"
......
...@@ -66,10 +66,10 @@ export const subscriptionTable = { ...@@ -66,10 +66,10 @@ export const subscriptionTable = {
type: s__('SuperSonics|Type'), type: s__('SuperSonics|Type'),
}; };
export const connectivityIssue = s__('SuperSonics|There is a connectivity issue.'); export const connectivityIssue = s__('SuperSonics|There is a connectivity issue.');
export const manualSyncSuccessfulText = s__( export const manualSyncPendingText = s__(
'SuperSonics|Your subscription details will sync shortly.', 'SuperSonics|Your subscription details will sync shortly.',
); );
export const manualSyncSuccessfulTitle = s__('SuperSonics|Sync subscription request.'); export const manualSyncPendingTitle = s__('SuperSonics|Sync subscription request.');
export const manualSyncFailureText = s__( export const manualSyncFailureText = s__(
'SuperSonics|You can no longer sync your subscription details with GitLab. Get help for the most common connectivity issues by %{connectivityHelpLinkStart}troubleshooting the activation code%{connectivityHelpLinkEnd}.', 'SuperSonics|You can no longer sync your subscription details with GitLab. Get help for the most common connectivity issues by %{connectivityHelpLinkStart}troubleshooting the activation code%{connectivityHelpLinkEnd}.',
); );
...@@ -84,8 +84,9 @@ export const subscriptionActivationForm = { ...@@ -84,8 +84,9 @@ export const subscriptionActivationForm = {
export const subscriptionSyncStatus = { export const subscriptionSyncStatus = {
SYNC_FAILURE: 'SYNC_FAILURE', SYNC_FAILURE: 'SYNC_FAILURE',
SYNC_SUCCESS: 'SYNC_SUCCESS', SYNC_PENDING: 'SYNC_PENDING',
}; };
export const subscriptionTypes = { export const subscriptionTypes = {
CLOUD: 'cloud', CLOUD: 'cloud',
LICENSE_FILE: 'license_file', LICENSE_FILE: 'license_file',
......
...@@ -12,7 +12,7 @@ import SubscriptionDetailsCard from 'ee/admin/subscriptions/show/components/subs ...@@ -12,7 +12,7 @@ import SubscriptionDetailsCard from 'ee/admin/subscriptions/show/components/subs
import SubscriptionDetailsHistory from 'ee/admin/subscriptions/show/components/subscription_details_history.vue'; import SubscriptionDetailsHistory from 'ee/admin/subscriptions/show/components/subscription_details_history.vue';
import SubscriptionDetailsUserInfo from 'ee/admin/subscriptions/show/components/subscription_details_user_info.vue'; import SubscriptionDetailsUserInfo from 'ee/admin/subscriptions/show/components/subscription_details_user_info.vue';
import SubscriptionSyncNotifications, { import SubscriptionSyncNotifications, {
SUCCESS_ALERT_DISMISSED_EVENT, INFO_ALERT_DISMISSED_EVENT,
} from 'ee/admin/subscriptions/show/components/subscription_sync_notifications.vue'; } from 'ee/admin/subscriptions/show/components/subscription_sync_notifications.vue';
import { import {
licensedToHeaderText, licensedToHeaderText,
...@@ -303,7 +303,7 @@ describe('Subscription Breakdown', () => { ...@@ -303,7 +303,7 @@ describe('Subscription Breakdown', () => {
it('shows a success notification', () => { it('shows a success notification', () => {
expect(findSubscriptionSyncNotifications().props('syncStatus')).toBe( expect(findSubscriptionSyncNotifications().props('syncStatus')).toBe(
subscriptionSyncStatus.SYNC_SUCCESS, subscriptionSyncStatus.SYNC_PENDING,
); );
}); });
...@@ -312,7 +312,7 @@ describe('Subscription Breakdown', () => { ...@@ -312,7 +312,7 @@ describe('Subscription Breakdown', () => {
}); });
it('dismisses the success notification', async () => { it('dismisses the success notification', async () => {
findSubscriptionSyncNotifications().vm.$emit(SUCCESS_ALERT_DISMISSED_EVENT); findSubscriptionSyncNotifications().vm.$emit(INFO_ALERT_DISMISSED_EVENT);
await nextTick(); await nextTick();
expect(findSubscriptionSyncNotifications().exists()).toBe(false); expect(findSubscriptionSyncNotifications().exists()).toBe(false);
......
import { GlAlert, GlLink, GlSprintf } from '@gitlab/ui'; import { GlAlert, GlLink, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import SubscriptionSyncNotifications, { import SubscriptionSyncNotifications, {
SUCCESS_ALERT_DISMISSED_EVENT, INFO_ALERT_DISMISSED_EVENT,
} from 'ee/admin/subscriptions/show/components/subscription_sync_notifications.vue'; } from 'ee/admin/subscriptions/show/components/subscription_sync_notifications.vue';
import { import {
connectivityIssue, connectivityIssue,
manualSyncSuccessfulTitle, manualSyncPendingText,
manualSyncPendingTitle,
subscriptionSyncStatus, subscriptionSyncStatus,
} from 'ee/admin/subscriptions/show/constants'; } from 'ee/admin/subscriptions/show/constants';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
...@@ -17,7 +18,7 @@ describe('Subscription Sync Notifications', () => { ...@@ -17,7 +18,7 @@ describe('Subscription Sync Notifications', () => {
const finAllAlerts = () => wrapper.findAllComponents(GlAlert); const finAllAlerts = () => wrapper.findAllComponents(GlAlert);
const findFailureAlert = () => wrapper.findByTestId('sync-failure-alert'); const findFailureAlert = () => wrapper.findByTestId('sync-failure-alert');
const findSuccessAlert = () => wrapper.findByTestId('sync-success-alert'); const findInfoAlert = () => wrapper.findByTestId('sync-info-alert');
const findLink = () => wrapper.findComponent(GlLink); const findLink = () => wrapper.findComponent(GlLink);
const createComponent = ({ props, stubs } = {}) => { const createComponent = ({ props, stubs } = {}) => {
...@@ -45,21 +46,29 @@ describe('Subscription Sync Notifications', () => { ...@@ -45,21 +46,29 @@ describe('Subscription Sync Notifications', () => {
}); });
}); });
describe('sync success notification', () => { describe('sync info notification', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
props: { syncStatus: subscriptionSyncStatus.SYNC_SUCCESS }, props: { syncStatus: subscriptionSyncStatus.SYNC_PENDING },
}); });
}); });
it('displays an alert with success message', () => { it('displays an info alert', () => {
expect(findSuccessAlert().props('title')).toBe(manualSyncSuccessfulTitle); expect(findInfoAlert().props('variant')).toBe('info');
});
it('displays an alert with a title', () => {
expect(findInfoAlert().props('title')).toBe(manualSyncPendingTitle);
});
it('displays an alert with a message', () => {
expect(findInfoAlert().text()).toBe(manualSyncPendingText);
}); });
it('emits an event when dismissed', () => { it('emits an event when dismissed', () => {
findSuccessAlert().vm.$emit('dismiss'); findInfoAlert().vm.$emit('dismiss');
expect(wrapper.emitted(SUCCESS_ALERT_DISMISSED_EVENT)).toEqual([[]]); expect(wrapper.emitted(INFO_ALERT_DISMISSED_EVENT)).toHaveLength(1);
}); });
}); });
......
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