Commit 3e6dc6db authored by vvempati's avatar vvempati

Co-locate constants for simplicity, make typedefs for data non-nullable

- Move constant used in only one file to the same file
- Make typedefs for addon data fields non nullable
- Remove unnecessary spread operator
parent 3f5313a6
import {
CI_MINUTES_PER_PACK,
I18N_CI_MINUTES_PRODUCT_LABEL,
I18N_CI_MINUTES_PRODUCT_UNIT,
I18N_STORAGE_PRODUCT_LABEL,
I18N_STORAGE_PRODUCT_UNIT,
planCode,
STORAGE_PER_PACK,
} from 'ee/subscriptions/buy_addons_shared/constants';
export const planData = {
[planCode.CI_1000_MINUTES_PLAN]: {
hasExpiration: false,
isAddon: true,
label: I18N_CI_MINUTES_PRODUCT_LABEL,
productUnit: I18N_CI_MINUTES_PRODUCT_UNIT,
quantityPerPack: CI_MINUTES_PER_PACK,
},
[planCode.STORAGE_PLAN]: {
hasExpiration: true,
isAddon: true,
label: I18N_STORAGE_PRODUCT_LABEL,
productUnit: I18N_STORAGE_PRODUCT_UNIT,
quantityPerPack: STORAGE_PER_PACK,
},
};
...@@ -3,10 +3,36 @@ import { merge } from 'lodash'; ...@@ -3,10 +3,36 @@ import { merge } from 'lodash';
import Api from 'ee/api'; import Api from 'ee/api';
import * as SubscriptionsApi from 'ee/api/subscriptions_api'; import * as SubscriptionsApi from 'ee/api/subscriptions_api';
import { ERROR_FETCHING_COUNTRIES, ERROR_FETCHING_STATES } from 'ee/subscriptions/constants'; import { ERROR_FETCHING_COUNTRIES, ERROR_FETCHING_STATES } from 'ee/subscriptions/constants';
import { COUNTRY_TYPE, STATE_TYPE } from 'ee/subscriptions/buy_addons_shared/constants'; import {
COUNTRY_TYPE,
STATE_TYPE,
CI_MINUTES_PER_PACK,
I18N_CI_MINUTES_PRODUCT_LABEL,
I18N_CI_MINUTES_PRODUCT_UNIT,
I18N_STORAGE_PRODUCT_LABEL,
I18N_STORAGE_PRODUCT_UNIT,
planCode,
STORAGE_PER_PACK,
} from 'ee/subscriptions/buy_addons_shared/constants';
import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql'; import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { planData } from 'ee/subscriptions/buy_addons_shared/graphql/data';
const planData = {
[planCode.CI_1000_MINUTES_PLAN]: {
hasExpiration: false,
isAddon: true,
label: I18N_CI_MINUTES_PRODUCT_LABEL,
productUnit: I18N_CI_MINUTES_PRODUCT_UNIT,
quantityPerPack: CI_MINUTES_PER_PACK,
},
[planCode.STORAGE_PLAN]: {
hasExpiration: true,
isAddon: true,
label: I18N_STORAGE_PRODUCT_LABEL,
productUnit: I18N_STORAGE_PRODUCT_UNIT,
quantityPerPack: STORAGE_PER_PACK,
},
};
// NOTE: These resolvers are temporary and will be removed in the future. // NOTE: These resolvers are temporary and will be removed in the future.
// See https://gitlab.com/gitlab-org/gitlab/-/issues/321643 // See https://gitlab.com/gitlab-org/gitlab/-/issues/321643
......
type Plan { type Plan {
id: ID id: Int!
name: String name: String!
code: String code: String!
pricePerYear: Int pricePerYear: Int!
label: String label: String!
isAddon: Boolean isAddon: Boolean!
hasExpiration: Boolean hasExpiration: Boolean!
productUnit: String productUnit: String!
quantityPerPack: String quantityPerPack: String!
} }
enum PlanTag { enum PlanTag {
......
...@@ -23,7 +23,7 @@ export function createMockApolloProvider(mockResponses = {}, dataset = {}) { ...@@ -23,7 +23,7 @@ export function createMockApolloProvider(mockResponses = {}, dataset = {}) {
[plansQuery, plansQueryMock], [plansQuery, plansQueryMock],
[orderPreviewQuery, orderPreviewQueryMock], [orderPreviewQuery, orderPreviewQueryMock],
], ],
{ ...customersDotResolvers }, customersDotResolvers,
); );
const apolloProvider = new VueApollo({ const apolloProvider = new VueApollo({
......
...@@ -26,9 +26,7 @@ describe('Payment Method', () => { ...@@ -26,9 +26,7 @@ describe('Payment Method', () => {
const isStepValid = () => wrapper.findComponent(Step).props('isValid'); const isStepValid = () => wrapper.findComponent(Step).props('isValid');
const createComponent = (apolloLocalState = {}) => { const createComponent = (apolloLocalState = {}) => {
const apolloProvider = createMockApolloProvider(STEPS, STEPS[2], { const apolloProvider = createMockApolloProvider(STEPS, STEPS[2], gitLabResolvers);
...gitLabResolvers,
});
apolloProvider.clients.defaultClient.cache.writeQuery({ apolloProvider.clients.defaultClient.cache.writeQuery({
query: stateQuery, query: stateQuery,
data: merge({}, initialStateData, apolloLocalState), data: merge({}, initialStateData, apolloLocalState),
......
...@@ -20,9 +20,7 @@ describe('Zuora', () => { ...@@ -20,9 +20,7 @@ describe('Zuora', () => {
let wrapper; let wrapper;
const createComponent = (props = {}, data = {}, apolloLocalState = {}) => { const createComponent = (props = {}, data = {}, apolloLocalState = {}) => {
const apolloProvider = createMockApolloProvider(STEPS, STEPS[1], { const apolloProvider = createMockApolloProvider(STEPS, STEPS[1], gitLabResolvers);
...gitLabResolvers,
});
apolloProvider.clients.defaultClient.cache.writeQuery({ apolloProvider.clients.defaultClient.cache.writeQuery({
query: stateQuery, query: stateQuery,
data: merge({}, initialStateData, apolloLocalState), data: merge({}, initialStateData, apolloLocalState),
......
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