Commit 1beb7ba9 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'dz/327885-fetch-storage-plans' into 'master'

Fetch storage plans for purchase flow

See merge request gitlab-org/gitlab!69084
parents 029c06db 8ee3f516
<script> <script>
import updateState from 'ee/subscriptions/graphql/mutations/update_state.mutation.graphql'; import updateState from 'ee/subscriptions/graphql/mutations/update_state.mutation.graphql';
import BillingAddress from 'ee/vue_shared/purchase_flow/components/checkout/billing_address.vue';
import ConfirmOrder from 'ee/vue_shared/purchase_flow/components/checkout/confirm_order.vue';
import PaymentMethod from 'ee/vue_shared/purchase_flow/components/checkout/payment_method.vue';
import { GENERAL_ERROR_MESSAGE } from 'ee/vue_shared/purchase_flow/constants'; import { GENERAL_ERROR_MESSAGE } from 'ee/vue_shared/purchase_flow/constants';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import AddonPurchaseDetails from './checkout/addon_purchase_details.vue'; import AddonPurchaseDetails from './checkout/addon_purchase_details.vue';
import BillingAddress from './checkout/billing_address.vue';
import ConfirmOrder from './checkout/confirm_order.vue';
import PaymentMethod from './checkout/payment_method.vue';
export default { export default {
components: { AddonPurchaseDetails, BillingAddress, PaymentMethod, ConfirmOrder }, components: { AddonPurchaseDetails, BillingAddress, PaymentMethod, ConfirmOrder },
......
<script> <script>
import { GlAlert, GlFormInput, GlSprintf } from '@gitlab/ui'; import { GlAlert, GlFormInput, GlSprintf } from '@gitlab/ui';
import { CI_MINUTES_PER_PACK } from 'ee/subscriptions/buy_minutes/constants'; import { CI_MINUTES_PER_PACK } from 'ee/subscriptions/buy_addons_shared/constants';
import { STEPS } from 'ee/subscriptions/constants'; import { STEPS } from 'ee/subscriptions/constants';
import updateState from 'ee/subscriptions/graphql/mutations/update_state.mutation.graphql'; import updateState from 'ee/subscriptions/graphql/mutations/update_state.mutation.graphql';
import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql'; import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql';
......
/* eslint-disable @gitlab/require-i18n-strings */ /* eslint-disable @gitlab/require-i18n-strings */
export const planTags = { export const planTags = {
CI_1000_MINUTES_PLAN: 'CI_1000_MINUTES_PLAN', CI_1000_MINUTES_PLAN: 'CI_1000_MINUTES_PLAN',
STORAGE_PLAN: 'STORAGE_PLAN',
}; };
/* eslint-enable @gitlab/require-i18n-strings */ /* eslint-enable @gitlab/require-i18n-strings */
export const CUSTOMER_CLIENT = 'customerClient'; export const CUSTOMER_CLIENT = 'customerClient';
......
...@@ -4,10 +4,10 @@ import { GlEmptyState } from '@gitlab/ui'; ...@@ -4,10 +4,10 @@ import { GlEmptyState } from '@gitlab/ui';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import StepOrderApp from 'ee/vue_shared/purchase_flow/components/step_order_app.vue'; import StepOrderApp from 'ee/vue_shared/purchase_flow/components/step_order_app.vue';
import { ERROR_FETCHING_DATA_HEADER, ERROR_FETCHING_DATA_DESCRIPTION } from '~/ensure_data'; import { ERROR_FETCHING_DATA_HEADER, ERROR_FETCHING_DATA_DESCRIPTION } from '~/ensure_data';
import Checkout from '../../buy_addons_shared/components/checkout.vue';
import OrderSummary from '../../buy_addons_shared/components/order_summary.vue';
import { planTags, CUSTOMER_CLIENT } from '../../buy_addons_shared/constants';
import plansQuery from '../../graphql/queries/plans.customer.query.graphql'; import plansQuery from '../../graphql/queries/plans.customer.query.graphql';
import { planTags, CUSTOMER_CLIENT } from '../constants';
import Checkout from './checkout.vue';
import OrderSummary from './order_summary.vue';
export default { export default {
name: 'BuyCIMinutesApp', name: 'BuyCIMinutesApp',
......
import Vue from 'vue'; import Vue from 'vue';
import ensureData from '~/ensure_data'; import ensureData from '~/ensure_data';
import apolloProvider from '../buy_addons_shared/graphql';
import { writeInitialDataToApolloCache } from '../buy_addons_shared/utils';
import App from './components/app.vue'; import App from './components/app.vue';
import apolloProvider from './graphql';
import { writeInitialDataToApolloCache } from './utils';
export default (el) => { export default (el) => {
if (!el) { if (!el) {
......
<script> <script>
import emptySvg from '@gitlab/svgs/dist/illustrations/security-dashboard-empty-state.svg';
import { GlEmptyState } from '@gitlab/ui';
import * as Sentry from '@sentry/browser';
import StepOrderApp from 'ee/vue_shared/purchase_flow/components/step_order_app.vue'; import StepOrderApp from 'ee/vue_shared/purchase_flow/components/step_order_app.vue';
import { ERROR_FETCHING_DATA_HEADER, ERROR_FETCHING_DATA_DESCRIPTION } from '~/ensure_data';
import Checkout from '../../buy_addons_shared/components/checkout.vue';
import OrderSummary from '../../buy_addons_shared/components/order_summary.vue';
import { planTags, CUSTOMER_CLIENT } from '../../buy_addons_shared/constants';
import plansQuery from '../../graphql/queries/plans.customer.query.graphql';
export default { export default {
name: 'BuyStorageApp',
components: { components: {
Checkout,
GlEmptyState,
OrderSummary,
StepOrderApp, StepOrderApp,
}, },
i18n: {
ERROR_FETCHING_DATA_HEADER,
ERROR_FETCHING_DATA_DESCRIPTION,
},
emptySvg,
data() {
return {
hasError: false,
};
},
apollo: {
plans: {
client: CUSTOMER_CLIENT,
query: plansQuery,
variables: {
tags: [planTags.STORAGE_PLAN],
},
update(data) {
if (!data?.plans?.length) {
this.hasError = true;
return null;
}
return data.plans;
},
error(error) {
this.hasError = true;
Sentry.captureException(error);
},
},
},
}; };
</script> </script>
<template> <template>
<step-order-app> <gl-empty-state
<template #checkout></template> v-if="hasError"
<template #order-summary></template> :title="$options.i18n.ERROR_FETCHING_DATA_HEADER"
:description="$options.i18n.ERROR_FETCHING_DATA_DESCRIPTION"
:svg-path="`data:image/svg+xml;utf8,${encodeURIComponent($options.emptySvg)}`"
/>
<step-order-app v-else-if="!$apollo.loading">
<template #checkout>
<checkout :plan="plans[0]" />
</template>
<template #order-summary>
<order-summary :plan="plans[0]" />
</template>
</step-order-app> </step-order-app>
</template> </template>
import Vue from 'vue'; import Vue from 'vue';
import ensureData from '~/ensure_data';
import apolloProvider from '../buy_addons_shared/graphql';
import { writeInitialDataToApolloCache } from '../buy_addons_shared/utils';
import App from './components/app.vue'; import App from './components/app.vue';
export default (el) => { export default (el) => {
if (!el) {
return null;
}
const extendedApp = ensureData(App, {
parseData: writeInitialDataToApolloCache.bind(null, apolloProvider),
data: el.dataset,
shouldLog: true,
});
return new Vue({ return new Vue({
el, el,
components: { apolloProvider,
App,
},
render(createElement) { render(createElement) {
return createElement(App); return createElement(extendedApp);
}, },
}); });
}; };
...@@ -4,6 +4,7 @@ import VueApollo from 'vue-apollo'; ...@@ -4,6 +4,7 @@ import VueApollo from 'vue-apollo';
import App from 'ee/subscriptions/buy_minutes/components/app.vue'; import App from 'ee/subscriptions/buy_minutes/components/app.vue';
import StepOrderApp from 'ee/vue_shared/purchase_flow/components/step_order_app.vue'; import StepOrderApp from 'ee/vue_shared/purchase_flow/components/step_order_app.vue';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import { planTags } from '../../../../../app/assets/javascripts/subscriptions/buy_addons_shared/constants';
import { createMockApolloProvider } from '../spec_helper'; import { createMockApolloProvider } from '../spec_helper';
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -12,11 +13,10 @@ localVue.use(VueApollo); ...@@ -12,11 +13,10 @@ localVue.use(VueApollo);
describe('App', () => { describe('App', () => {
let wrapper; let wrapper;
function createComponent(options = {}) { function createComponent(apolloProvider) {
const { apolloProvider, propsData } = options;
return shallowMount(App, { return shallowMount(App, {
localVue, localVue,
propsData, propsData: { plan: planTags.CI_1000_MINUTES_PLAN },
apolloProvider, apolloProvider,
}); });
} }
...@@ -28,7 +28,7 @@ describe('App', () => { ...@@ -28,7 +28,7 @@ describe('App', () => {
describe('when data is received', () => { describe('when data is received', () => {
it('should display the StepOrderApp', async () => { it('should display the StepOrderApp', async () => {
const mockApollo = createMockApolloProvider(); const mockApollo = createMockApolloProvider();
wrapper = createComponent({ apolloProvider: mockApollo }); wrapper = createComponent(mockApollo);
await waitForPromises(); await waitForPromises();
expect(wrapper.findComponent(StepOrderApp).exists()).toBe(true); expect(wrapper.findComponent(StepOrderApp).exists()).toBe(true);
...@@ -41,7 +41,7 @@ describe('App', () => { ...@@ -41,7 +41,7 @@ describe('App', () => {
const mockApollo = createMockApolloProvider({ const mockApollo = createMockApolloProvider({
plansQueryMock: jest.fn().mockResolvedValue({ data: null }), plansQueryMock: jest.fn().mockResolvedValue({ data: null }),
}); });
wrapper = createComponent({ apolloProvider: mockApollo }); wrapper = createComponent(mockApollo);
await waitForPromises(); await waitForPromises();
expect(wrapper.findComponent(StepOrderApp).exists()).toBe(false); expect(wrapper.findComponent(StepOrderApp).exists()).toBe(false);
...@@ -52,7 +52,7 @@ describe('App', () => { ...@@ -52,7 +52,7 @@ describe('App', () => {
const mockApollo = createMockApolloProvider({ const mockApollo = createMockApolloProvider({
plansQueryMock: jest.fn().mockResolvedValue({ data: { plans: null } }), plansQueryMock: jest.fn().mockResolvedValue({ data: { plans: null } }),
}); });
wrapper = createComponent({ apolloProvider: mockApollo }); wrapper = createComponent(mockApollo);
await waitForPromises(); await waitForPromises();
expect(wrapper.findComponent(StepOrderApp).exists()).toBe(false); expect(wrapper.findComponent(StepOrderApp).exists()).toBe(false);
...@@ -63,7 +63,7 @@ describe('App', () => { ...@@ -63,7 +63,7 @@ describe('App', () => {
const mockApollo = createMockApolloProvider({ const mockApollo = createMockApolloProvider({
plansQueryMock: jest.fn().mockResolvedValue({ data: { plans: {} } }), plansQueryMock: jest.fn().mockResolvedValue({ data: { plans: {} } }),
}); });
wrapper = createComponent({ apolloProvider: mockApollo }); wrapper = createComponent(mockApollo);
await waitForPromises(); await waitForPromises();
expect(wrapper.findComponent(StepOrderApp).exists()).toBe(false); expect(wrapper.findComponent(StepOrderApp).exists()).toBe(false);
...@@ -76,7 +76,7 @@ describe('App', () => { ...@@ -76,7 +76,7 @@ describe('App', () => {
const mockApollo = createMockApolloProvider({ const mockApollo = createMockApolloProvider({
plansQueryMock: jest.fn().mockRejectedValue(new Error('An error happened!')), plansQueryMock: jest.fn().mockRejectedValue(new Error('An error happened!')),
}); });
wrapper = createComponent({ apolloProvider: mockApollo }); wrapper = createComponent(mockApollo);
await waitForPromises(); await waitForPromises();
expect(wrapper.findComponent(StepOrderApp).exists()).toBe(false); expect(wrapper.findComponent(StepOrderApp).exists()).toBe(false);
......
...@@ -2,8 +2,8 @@ import { GlAlert } from '@gitlab/ui'; ...@@ -2,8 +2,8 @@ import { GlAlert } from '@gitlab/ui';
import { createLocalVue } from '@vue/test-utils'; import { createLocalVue } from '@vue/test-utils';
import { merge } from 'lodash'; import { merge } from 'lodash';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import AddonPurchaseDetails from 'ee/subscriptions/buy_minutes/components/checkout/addon_purchase_details.vue'; import AddonPurchaseDetails from 'ee/subscriptions/buy_addons_shared/components/checkout/addon_purchase_details.vue';
import subscriptionsResolvers from 'ee/subscriptions/buy_minutes/graphql/resolvers'; import subscriptionsResolvers from 'ee/subscriptions/buy_addons_shared/graphql/resolvers';
import { STEPS } from 'ee/subscriptions/constants'; import { STEPS } from 'ee/subscriptions/constants';
import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql'; import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql';
import Step from 'ee/vue_shared/purchase_flow/components/step.vue'; import Step from 'ee/vue_shared/purchase_flow/components/step.vue';
......
import { mount, createLocalVue } from '@vue/test-utils'; import { mount, createLocalVue } from '@vue/test-utils';
import { merge } from 'lodash'; import { merge } from 'lodash';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import BillingAddress from 'ee/subscriptions/buy_minutes/components/checkout/billing_address.vue'; import { resolvers } from 'ee/subscriptions/buy_addons_shared/graphql/resolvers';
import { resolvers } from 'ee/subscriptions/buy_minutes/graphql/resolvers';
import { STEPS } from 'ee/subscriptions/constants'; import { STEPS } from 'ee/subscriptions/constants';
import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql'; import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql';
import BillingAddress from 'ee/vue_shared/purchase_flow/components/checkout/billing_address.vue';
import Step from 'ee/vue_shared/purchase_flow/components/step.vue'; import Step from 'ee/vue_shared/purchase_flow/components/step.vue';
import { stateData as initialStateData } from 'ee_jest/subscriptions/buy_minutes/mock_data'; import { stateData as initialStateData } from 'ee_jest/subscriptions/buy_minutes/mock_data';
import { createMockApolloProvider } from 'ee_jest/vue_shared/purchase_flow/spec_helper'; import { createMockApolloProvider } from 'ee_jest/vue_shared/purchase_flow/spec_helper';
......
...@@ -2,9 +2,9 @@ import { GlButton, GlLoadingIcon } from '@gitlab/ui'; ...@@ -2,9 +2,9 @@ import { GlButton, GlLoadingIcon } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import Api from 'ee/api'; import Api from 'ee/api';
import ConfirmOrder from 'ee/subscriptions/buy_minutes/components/checkout/confirm_order.vue';
import { STEPS } from 'ee/subscriptions/constants'; import { STEPS } from 'ee/subscriptions/constants';
import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql'; import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql';
import ConfirmOrder from 'ee/vue_shared/purchase_flow/components/checkout/confirm_order.vue';
import { GENERAL_ERROR_MESSAGE } from 'ee/vue_shared/purchase_flow/constants'; import { GENERAL_ERROR_MESSAGE } from 'ee/vue_shared/purchase_flow/constants';
import { stateData as initialStateData } from 'ee_jest/subscriptions/buy_minutes/mock_data'; import { stateData as initialStateData } from 'ee_jest/subscriptions/buy_minutes/mock_data';
import { createMockApolloProvider } from 'ee_jest/vue_shared/purchase_flow/spec_helper'; import { createMockApolloProvider } from 'ee_jest/vue_shared/purchase_flow/spec_helper';
......
import { mount, createLocalVue } from '@vue/test-utils'; import { mount, createLocalVue } from '@vue/test-utils';
import { merge } from 'lodash'; import { merge } from 'lodash';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import PaymentMethod from 'ee/subscriptions/buy_minutes/components/checkout/payment_method.vue'; import { resolvers } from 'ee/subscriptions/buy_addons_shared/graphql/resolvers';
import { resolvers } from 'ee/subscriptions/buy_minutes/graphql/resolvers';
import { STEPS } from 'ee/subscriptions/constants'; import { STEPS } from 'ee/subscriptions/constants';
import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql'; import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql';
import PaymentMethod from 'ee/vue_shared/purchase_flow/components/checkout/payment_method.vue';
import Step from 'ee/vue_shared/purchase_flow/components/step.vue'; import Step from 'ee/vue_shared/purchase_flow/components/step.vue';
import { stateData as initialStateData } from 'ee_jest/subscriptions/buy_minutes/mock_data'; import { stateData as initialStateData } from 'ee_jest/subscriptions/buy_minutes/mock_data';
import { createMockApolloProvider } from 'ee_jest/vue_shared/purchase_flow/spec_helper'; import { createMockApolloProvider } from 'ee_jest/vue_shared/purchase_flow/spec_helper';
......
...@@ -3,10 +3,10 @@ import { shallowMount, createLocalVue } from '@vue/test-utils'; ...@@ -3,10 +3,10 @@ import { shallowMount, createLocalVue } from '@vue/test-utils';
import AxiosMockAdapter from 'axios-mock-adapter'; import AxiosMockAdapter from 'axios-mock-adapter';
import { merge } from 'lodash'; import { merge } from 'lodash';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import Zuora from 'ee/subscriptions/buy_minutes/components/checkout/zuora.vue'; import { resolvers } from 'ee/subscriptions/buy_addons_shared/graphql/resolvers';
import { resolvers } from 'ee/subscriptions/buy_minutes/graphql/resolvers';
import { STEPS } from 'ee/subscriptions/constants'; import { STEPS } from 'ee/subscriptions/constants';
import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql'; import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql';
import Zuora from 'ee/vue_shared/purchase_flow/components/checkout/zuora.vue';
import { stateData as initialStateData } from 'ee_jest/subscriptions/buy_minutes/mock_data'; import { stateData as initialStateData } from 'ee_jest/subscriptions/buy_minutes/mock_data';
import { createMockApolloProvider } from 'ee_jest/vue_shared/purchase_flow/spec_helper'; import { createMockApolloProvider } from 'ee_jest/vue_shared/purchase_flow/spec_helper';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
......
import { GlSprintf } from '@gitlab/ui'; import { GlSprintf } from '@gitlab/ui';
import SummaryDetails from 'ee/subscriptions/buy_minutes/components/order_summary/summary_details.vue'; import SummaryDetails from 'ee/subscriptions/buy_addons_shared/components/order_summary/summary_details.vue';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
describe('SummaryDetails', () => { describe('SummaryDetails', () => {
......
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import { merge } from 'lodash'; import { merge } from 'lodash';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import OrderSummary from 'ee/subscriptions/buy_minutes/components/order_summary.vue'; import OrderSummary from 'ee/subscriptions/buy_addons_shared/components/order_summary.vue';
import subscriptionsResolvers from 'ee/subscriptions/buy_minutes/graphql/resolvers'; import subscriptionsResolvers from 'ee/subscriptions/buy_addons_shared/graphql/resolvers';
import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql'; import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql';
import purchaseFlowResolvers from 'ee/vue_shared/purchase_flow/graphql/resolvers'; import purchaseFlowResolvers from 'ee/vue_shared/purchase_flow/graphql/resolvers';
import { import {
......
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 { resolvers } from 'ee/subscriptions/buy_minutes/graphql/resolvers'; import { resolvers } from 'ee/subscriptions/buy_addons_shared/graphql/resolvers';
import { ERROR_FETCHING_COUNTRIES, ERROR_FETCHING_STATES } from 'ee/subscriptions/constants'; import { ERROR_FETCHING_COUNTRIES, ERROR_FETCHING_STATES } from 'ee/subscriptions/constants';
import createFlash from '~/flash'; import createFlash from '~/flash';
...@@ -49,7 +49,7 @@ const countries = [ ...@@ -49,7 +49,7 @@ const countries = [
const states = { California: 'CA' }; const states = { California: 'CA' };
describe('~/subscriptions/buy_minutes/graphql/resolvers', () => { describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
describe('Query', () => { describe('Query', () => {
describe('countries', () => { describe('countries', () => {
describe('on success', () => { describe('on success', () => {
......
import apolloProvider from 'ee/subscriptions/buy_minutes/graphql'; import apolloProvider from 'ee/subscriptions/buy_addons_shared/graphql';
import { writeInitialDataToApolloCache } from 'ee/subscriptions/buy_minutes/utils'; import { writeInitialDataToApolloCache } from 'ee/subscriptions/buy_addons_shared/utils';
import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql'; import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql';
import { mockNamespaces, mockParsedNamespaces } from './mock_data'; import { mockNamespaces, mockParsedNamespaces } from './mock_data';
......
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