Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3f5313a6
Commit
3f5313a6
authored
Jan 18, 2022
by
vvempati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move addon related data to GraphQL
parent
7d0232c5
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
105 additions
and
33 deletions
+105
-33
ee/app/assets/javascripts/subscriptions/buy_addons_shared/components/app.vue
...cripts/subscriptions/buy_addons_shared/components/app.vue
+2
-4
ee/app/assets/javascripts/subscriptions/buy_addons_shared/constants.js
.../javascripts/subscriptions/buy_addons_shared/constants.js
+5
-0
ee/app/assets/javascripts/subscriptions/buy_addons_shared/graphql.js
...ts/javascripts/subscriptions/buy_addons_shared/graphql.js
+11
-4
ee/app/assets/javascripts/subscriptions/buy_addons_shared/graphql/data.js
...vascripts/subscriptions/buy_addons_shared/graphql/data.js
+26
-0
ee/app/assets/javascripts/subscriptions/buy_addons_shared/graphql/resolvers.js
...ipts/subscriptions/buy_addons_shared/graphql/resolvers.js
+12
-1
ee/app/assets/javascripts/subscriptions/buy_addons_shared/graphql/typedefs.graphql
.../subscriptions/buy_addons_shared/graphql/typedefs.graphql
+16
-0
ee/app/assets/javascripts/subscriptions/graphql/queries/plans.customer.query.graphql
...ubscriptions/graphql/queries/plans.customer.query.graphql
+5
-0
ee/spec/frontend/subscriptions/buy_addons_shared/app_spec.js
ee/spec/frontend/subscriptions/buy_addons_shared/app_spec.js
+6
-6
ee/spec/frontend/subscriptions/buy_addons_shared/resolvers_spec.js
...rontend/subscriptions/buy_addons_shared/resolvers_spec.js
+8
-8
ee/spec/frontend/subscriptions/buy_minutes/components/checkout/billing_address_spec.js
...s/buy_minutes/components/checkout/billing_address_spec.js
+2
-2
ee/spec/frontend/subscriptions/spec_helper.js
ee/spec/frontend/subscriptions/spec_helper.js
+8
-4
ee/spec/frontend/vue_shared/purchase_flow/components/checkout/payment_method_spec.js
.../purchase_flow/components/checkout/payment_method_spec.js
+2
-2
ee/spec/frontend/vue_shared/purchase_flow/components/checkout/zuora_spec.js
...ue_shared/purchase_flow/components/checkout/zuora_spec.js
+2
-2
No files found.
ee/app/assets/javascripts/subscriptions/buy_addons_shared/components/app.vue
View file @
3f5313a6
...
@@ -67,10 +67,8 @@ export default {
...
@@ -67,10 +67,8 @@ export default {
return
this
.
isQuantityValid
?
total
:
''
;
return
this
.
isQuantityValid
?
total
:
''
;
},
},
plan
()
{
plan
()
{
return
{
const
[
plan
]
=
this
.
plans
;
...
this
.
plans
[
0
],
return
plan
;
isAddon
:
true
,
};
},
},
totalUnits
()
{
totalUnits
()
{
return
this
.
quantity
*
this
.
config
.
quantityPerPack
;
return
this
.
quantity
*
this
.
config
.
quantityPerPack
;
...
...
ee/app/assets/javascripts/subscriptions/buy_addons_shared/constants.js
View file @
3f5313a6
...
@@ -6,6 +6,11 @@ export const planTags = {
...
@@ -6,6 +6,11 @@ export const planTags = {
STORAGE_PLAN
:
'
STORAGE_PLAN
'
,
STORAGE_PLAN
:
'
STORAGE_PLAN
'
,
};
};
/* eslint-enable @gitlab/require-i18n-strings */
/* eslint-enable @gitlab/require-i18n-strings */
export
const
planCode
=
{
CI_1000_MINUTES_PLAN
:
'
ci_minutes
'
,
STORAGE_PLAN
:
'
storage
'
,
};
export
const
CUSTOMERSDOT_CLIENT
=
'
customersDotClient
'
;
export
const
CUSTOMERSDOT_CLIENT
=
'
customersDotClient
'
;
export
const
GITLAB_CLIENT
=
'
gitlabClient
'
;
export
const
GITLAB_CLIENT
=
'
gitlabClient
'
;
export
const
CUSTOMER_TYPE
=
'
Customer
'
;
export
const
CUSTOMER_TYPE
=
'
Customer
'
;
...
...
ee/app/assets/javascripts/subscriptions/buy_addons_shared/graphql.js
View file @
3f5313a6
...
@@ -4,20 +4,27 @@ import VueApollo from 'vue-apollo';
...
@@ -4,20 +4,27 @@ import VueApollo from 'vue-apollo';
import
purchaseFlowResolvers
from
'
ee/vue_shared/purchase_flow/graphql/resolvers
'
;
import
purchaseFlowResolvers
from
'
ee/vue_shared/purchase_flow/graphql/resolvers
'
;
import
typeDefs
from
'
ee/vue_shared/purchase_flow/graphql/typedefs.graphql
'
;
import
typeDefs
from
'
ee/vue_shared/purchase_flow/graphql/typedefs.graphql
'
;
import
createClient
from
'
~/lib/graphql
'
;
import
createClient
from
'
~/lib/graphql
'
;
import
{
GITLAB_CLIENT
,
CUSTOMERSDOT_CLIENT
}
from
'
./constants
'
;
import
typeDefsCDot
from
'
ee/subscriptions/buy_addons_shared/graphql/typedefs.graphql
'
;
import
{
resolvers
}
from
'
./graphql/resolvers
'
;
import
{
CUSTOMERSDOT_CLIENT
,
GITLAB_CLIENT
}
from
'
ee/subscriptions/buy_addons_shared/constants
'
;
import
{
customersDotResolvers
,
gitLabResolvers
,
}
from
'
ee/subscriptions/buy_addons_shared/graphql/resolvers
'
;
Vue
.
use
(
VueApollo
);
Vue
.
use
(
VueApollo
);
const
gitlabClient
=
createClient
(
merge
({},
r
esolvers
,
purchaseFlowResolvers
),
{
const
gitlabClient
=
createClient
(
merge
({},
gitLabR
esolvers
,
purchaseFlowResolvers
),
{
typeDefs
,
typeDefs
,
});
});
const
customersDotClient
=
createClient
(
const
customersDotClient
=
createClient
(
{},
{
...
customersDotResolvers
,
},
{
{
path
:
'
/-/customers_dot/proxy/graphql
'
,
path
:
'
/-/customers_dot/proxy/graphql
'
,
useGet
:
true
,
useGet
:
true
,
typeDefs
:
typeDefsCDot
,
},
},
);
);
...
...
ee/app/assets/javascripts/subscriptions/buy_addons_shared/graphql/data.js
0 → 100644
View file @
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
,
},
};
ee/app/assets/javascripts/subscriptions/buy_addons_shared/graphql/resolvers.js
View file @
3f5313a6
...
@@ -6,10 +6,11 @@ import { ERROR_FETCHING_COUNTRIES, ERROR_FETCHING_STATES } from 'ee/subscription
...
@@ -6,10 +6,11 @@ import { ERROR_FETCHING_COUNTRIES, ERROR_FETCHING_STATES } from 'ee/subscription
import
{
COUNTRY_TYPE
,
STATE_TYPE
}
from
'
ee/subscriptions/buy_addons_shared/constants
'
;
import
{
COUNTRY_TYPE
,
STATE_TYPE
}
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
'
;
// 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
export
const
r
esolvers
=
{
export
const
gitLabR
esolvers
=
{
Query
:
{
Query
:
{
countries
:
()
=>
{
countries
:
()
=>
{
return
Api
.
fetchCountries
()
return
Api
.
fetchCountries
()
...
@@ -43,3 +44,13 @@ export const resolvers = {
...
@@ -43,3 +44,13 @@ export const resolvers = {
},
},
},
},
};
};
export
const
customersDotResolvers
=
{
Plan
:
{
hasExpiration
:
({
code
})
=>
planData
[
code
]?.
hasExpiration
,
isAddon
:
({
code
})
=>
planData
[
code
]?.
isAddon
,
label
:
({
code
})
=>
planData
[
code
]?.
label
,
productUnit
:
({
code
})
=>
planData
[
code
]?.
productUnit
,
quantityPerPack
:
({
code
})
=>
planData
[
code
]?.
quantityPerPack
,
},
};
ee/app/assets/javascripts/subscriptions/buy_addons_shared/graphql/typedefs.graphql
0 → 100644
View file @
3f5313a6
type
Plan
{
id
:
ID
name
:
String
code
:
String
pricePerYear
:
Int
label
:
String
isAddon
:
Boolean
hasExpiration
:
Boolean
productUnit
:
String
quantityPerPack
:
String
}
enum
PlanTag
{
CI_1000_MINUTES_PLAN
STORAGE_PLAN
}
ee/app/assets/javascripts/subscriptions/graphql/queries/plans.customer.query.graphql
View file @
3f5313a6
...
@@ -4,5 +4,10 @@ query getPlans($tags: [PlanTag!]) {
...
@@ -4,5 +4,10 @@ query getPlans($tags: [PlanTag!]) {
name
name
code
code
pricePerYear
pricePerYear
hasExpiration
@client
isAddon
@client
label
@client
productUnit
@client
quantityPerPack
@client
}
}
}
}
ee/spec/frontend/subscriptions/buy_addons_shared/app_spec.js
View file @
3f5313a6
...
@@ -42,7 +42,7 @@ localVue.use(VueApollo);
...
@@ -42,7 +42,7 @@ localVue.use(VueApollo);
describe
(
'
Buy Addons Shared App
'
,
()
=>
{
describe
(
'
Buy Addons Shared App
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
function
createComponent
(
apolloProvider
,
propsData
)
{
async
function
createComponent
(
apolloProvider
,
propsData
)
{
wrapper
=
shallowMountExtended
(
App
,
{
wrapper
=
shallowMountExtended
(
App
,
{
localVue
,
localVue
,
apolloProvider
,
apolloProvider
,
...
@@ -54,7 +54,7 @@ describe('Buy Addons Shared App', () => {
...
@@ -54,7 +54,7 @@ describe('Buy Addons Shared App', () => {
SummaryDetails
,
SummaryDetails
,
},
},
});
});
return
waitForPromises
();
await
waitForPromises
();
}
}
const
STORAGE_ADDON_PROPS
=
{
const
STORAGE_ADDON_PROPS
=
{
...
@@ -112,10 +112,10 @@ describe('Buy Addons Shared App', () => {
...
@@ -112,10 +112,10 @@ describe('Buy Addons Shared App', () => {
describe
(
'
Storage
'
,
()
=>
{
describe
(
'
Storage
'
,
()
=>
{
describe
(
'
when data is received
'
,
()
=>
{
describe
(
'
when data is received
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
const
plansQueryMock
=
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
mockStoragePlans
}
});
const
plansQueryMock
=
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
mockStoragePlans
}
});
const
mockApollo
=
createMockApolloProvider
({
plansQueryMock
});
const
mockApollo
=
createMockApolloProvider
({
plansQueryMock
});
createComponent
(
mockApollo
,
STORAGE_ADDON_PROPS
);
await
createComponent
(
mockApollo
,
STORAGE_ADDON_PROPS
);
});
});
it
(
'
should display the root element
'
,
()
=>
{
it
(
'
should display the root element
'
,
()
=>
{
...
@@ -235,10 +235,10 @@ describe('Buy Addons Shared App', () => {
...
@@ -235,10 +235,10 @@ describe('Buy Addons Shared App', () => {
describe
(
'
CI Minutes
'
,
()
=>
{
describe
(
'
CI Minutes
'
,
()
=>
{
describe
(
'
when data is received
'
,
()
=>
{
describe
(
'
when data is received
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(
async
()
=>
{
const
plansQueryMock
=
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
mockCiMinutesPlans
}
});
const
plansQueryMock
=
jest
.
fn
().
mockResolvedValue
({
data
:
{
plans
:
mockCiMinutesPlans
}
});
const
mockApollo
=
createMockApolloProvider
({
plansQueryMock
});
const
mockApollo
=
createMockApolloProvider
({
plansQueryMock
});
createComponent
(
mockApollo
,
CI_MINUTES_ADDON_PROPS
);
await
createComponent
(
mockApollo
,
CI_MINUTES_ADDON_PROPS
);
});
});
it
(
'
should display the root element
'
,
()
=>
{
it
(
'
should display the root element
'
,
()
=>
{
...
...
ee/spec/frontend/subscriptions/buy_addons_shared/resolvers_spec.js
View file @
3f5313a6
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
{
r
esolvers
}
from
'
ee/subscriptions/buy_addons_shared/graphql/resolvers
'
;
import
{
gitLabR
esolvers
}
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
'
;
...
@@ -58,7 +58,7 @@ describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
...
@@ -58,7 +58,7 @@ describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
});
});
it
(
'
returns an array of countries with typename
'
,
async
()
=>
{
it
(
'
returns an array of countries with typename
'
,
async
()
=>
{
const
result
=
await
r
esolvers
.
Query
.
countries
();
const
result
=
await
gitLabR
esolvers
.
Query
.
countries
();
expect
(
createFlash
).
not
.
toHaveBeenCalled
();
expect
(
createFlash
).
not
.
toHaveBeenCalled
();
expect
(
result
).
toStrictEqual
([
expect
(
result
).
toStrictEqual
([
...
@@ -74,7 +74,7 @@ describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
...
@@ -74,7 +74,7 @@ describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
});
});
it
(
'
shows a flash message
'
,
async
()
=>
{
it
(
'
shows a flash message
'
,
async
()
=>
{
await
r
esolvers
.
Query
.
countries
();
await
gitLabR
esolvers
.
Query
.
countries
();
expect
(
createFlash
).
toHaveBeenCalledWith
({
message
:
ERROR_FETCHING_COUNTRIES
});
expect
(
createFlash
).
toHaveBeenCalledWith
({
message
:
ERROR_FETCHING_COUNTRIES
});
});
});
...
@@ -88,7 +88,7 @@ describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
...
@@ -88,7 +88,7 @@ describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
});
});
it
(
'
returns an array of states with typename
'
,
async
()
=>
{
it
(
'
returns an array of states with typename
'
,
async
()
=>
{
const
result
=
await
r
esolvers
.
Query
.
states
(
null
,
{
countryId
:
1
});
const
result
=
await
gitLabR
esolvers
.
Query
.
states
(
null
,
{
countryId
:
1
});
expect
(
createFlash
).
not
.
toHaveBeenCalled
();
expect
(
createFlash
).
not
.
toHaveBeenCalled
();
expect
(
result
).
toStrictEqual
([{
id
:
'
CA
'
,
name
:
'
California
'
,
__typename
:
'
State
'
}]);
expect
(
result
).
toStrictEqual
([{
id
:
'
CA
'
,
name
:
'
California
'
,
__typename
:
'
State
'
}]);
...
@@ -101,7 +101,7 @@ describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
...
@@ -101,7 +101,7 @@ describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
});
});
it
(
'
shows a flash message
'
,
async
()
=>
{
it
(
'
shows a flash message
'
,
async
()
=>
{
await
r
esolvers
.
Query
.
states
(
null
,
{
countryId
:
1
});
await
gitLabR
esolvers
.
Query
.
states
(
null
,
{
countryId
:
1
});
expect
(
createFlash
).
toHaveBeenCalledWith
({
message
:
ERROR_FETCHING_STATES
});
expect
(
createFlash
).
toHaveBeenCalledWith
({
message
:
ERROR_FETCHING_STATES
});
});
});
...
@@ -113,7 +113,7 @@ describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
...
@@ -113,7 +113,7 @@ describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
it
(
'
calls the REST api
'
,
async
()
=>
{
it
(
'
calls the REST api
'
,
async
()
=>
{
const
expectedArgs
=
{
groupId
:
1
,
customer
,
subscription
};
const
expectedArgs
=
{
groupId
:
1
,
customer
,
subscription
};
await
r
esolvers
.
Mutation
.
purchaseMinutes
(
null
,
expectedArgs
);
await
gitLabR
esolvers
.
Mutation
.
purchaseMinutes
(
null
,
expectedArgs
);
expect
(
SubscriptionsApi
.
createSubscription
).
toHaveBeenCalledWith
(
1
,
customer
,
subscription
);
expect
(
SubscriptionsApi
.
createSubscription
).
toHaveBeenCalledWith
(
1
,
customer
,
subscription
);
});
});
...
@@ -124,7 +124,7 @@ describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
...
@@ -124,7 +124,7 @@ describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
});
});
it
(
'
returns an error array
'
,
async
()
=>
{
it
(
'
returns an error array
'
,
async
()
=>
{
const
result
=
await
r
esolvers
.
Mutation
.
purchaseMinutes
(
null
,
{
const
result
=
await
gitLabR
esolvers
.
Mutation
.
purchaseMinutes
(
null
,
{
groupId
:
1
,
groupId
:
1
,
customer
,
customer
,
subscription
,
subscription
,
...
@@ -140,7 +140,7 @@ describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
...
@@ -140,7 +140,7 @@ describe('~/subscriptions/buy_addons_shared/graphql/resolvers', () => {
});
});
it
(
'
returns a redirect location
'
,
async
()
=>
{
it
(
'
returns a redirect location
'
,
async
()
=>
{
const
result
=
await
r
esolvers
.
Mutation
.
purchaseMinutes
(
null
,
{
const
result
=
await
gitLabR
esolvers
.
Mutation
.
purchaseMinutes
(
null
,
{
groupId
:
1
,
groupId
:
1
,
customer
,
customer
,
subscription
,
subscription
,
...
...
ee/spec/frontend/subscriptions/buy_minutes/components/checkout/billing_address_spec.js
View file @
3f5313a6
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
{
r
esolvers
}
from
'
ee/subscriptions/buy_addons_shared/graphql/resolvers
'
;
import
{
gitLabR
esolvers
}
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
BillingAddress
from
'
ee/vue_shared/purchase_flow/components/checkout/billing_address.vue
'
;
import
BillingAddress
from
'
ee/vue_shared/purchase_flow/components/checkout/billing_address.vue
'
;
...
@@ -28,7 +28,7 @@ describe('Billing Address', () => {
...
@@ -28,7 +28,7 @@ describe('Billing Address', () => {
const
createComponent
=
(
apolloLocalState
=
{})
=>
{
const
createComponent
=
(
apolloLocalState
=
{})
=>
{
const
apolloProvider
=
createMockApolloProvider
(
STEPS
,
STEPS
[
1
],
{
const
apolloProvider
=
createMockApolloProvider
(
STEPS
,
STEPS
[
1
],
{
...
r
esolvers
,
...
gitLabR
esolvers
,
...
apolloResolvers
,
...
apolloResolvers
,
});
});
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeQuery
({
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeQuery
({
...
...
ee/spec/frontend/subscriptions/spec_helper.js
View file @
3f5313a6
...
@@ -5,6 +5,7 @@ import orderPreviewQuery from 'ee/subscriptions/graphql/queries/order_preview.cu
...
@@ -5,6 +5,7 @@ import orderPreviewQuery from 'ee/subscriptions/graphql/queries/order_preview.cu
import
{
createMockClient
}
from
'
helpers/mock_apollo_helper
'
;
import
{
createMockClient
}
from
'
helpers/mock_apollo_helper
'
;
import
{
CUSTOMERSDOT_CLIENT
}
from
'
ee/subscriptions/buy_addons_shared/constants
'
;
import
{
CUSTOMERSDOT_CLIENT
}
from
'
ee/subscriptions/buy_addons_shared/constants
'
;
import
{
mockDefaultCache
,
mockOrderPreview
}
from
'
ee_jest/subscriptions/mock_data
'
;
import
{
mockDefaultCache
,
mockOrderPreview
}
from
'
ee_jest/subscriptions/mock_data
'
;
import
{
customersDotResolvers
}
from
'
ee/subscriptions/buy_addons_shared/graphql/resolvers
'
;
export
function
createMockApolloProvider
(
mockResponses
=
{},
dataset
=
{})
{
export
function
createMockApolloProvider
(
mockResponses
=
{},
dataset
=
{})
{
const
{
const
{
...
@@ -17,10 +18,13 @@ export function createMockApolloProvider(mockResponses = {}, dataset = {}) {
...
@@ -17,10 +18,13 @@ export function createMockApolloProvider(mockResponses = {}, dataset = {}) {
const
{
quantity
}
=
dataset
;
const
{
quantity
}
=
dataset
;
const
mockDefaultClient
=
createMockClient
();
const
mockDefaultClient
=
createMockClient
();
const
mockCustomersDotClient
=
createMockClient
([
const
mockCustomersDotClient
=
createMockClient
(
[
plansQuery
,
plansQueryMock
],
[
[
orderPreviewQuery
,
orderPreviewQueryMock
],
[
plansQuery
,
plansQueryMock
],
]);
[
orderPreviewQuery
,
orderPreviewQueryMock
],
],
{
...
customersDotResolvers
},
);
const
apolloProvider
=
new
VueApollo
({
const
apolloProvider
=
new
VueApollo
({
defaultClient
:
mockDefaultClient
,
defaultClient
:
mockDefaultClient
,
...
...
ee/spec/frontend/vue_shared/purchase_flow/components/checkout/payment_method_spec.js
View file @
3f5313a6
...
@@ -5,7 +5,7 @@ import {
...
@@ -5,7 +5,7 @@ import {
mockParsedNamespaces
,
mockParsedNamespaces
,
stateData
as
initialStateData
,
stateData
as
initialStateData
,
}
from
'
ee_jest/subscriptions/mock_data
'
;
}
from
'
ee_jest/subscriptions/mock_data
'
;
import
{
r
esolvers
}
from
'
ee/subscriptions/buy_addons_shared/graphql/resolvers
'
;
import
{
gitLabR
esolvers
}
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
PaymentMethod
from
'
ee/vue_shared/purchase_flow/components/checkout/payment_method.vue
'
;
import
PaymentMethod
from
'
ee/vue_shared/purchase_flow/components/checkout/payment_method.vue
'
;
...
@@ -27,7 +27,7 @@ describe('Payment Method', () => {
...
@@ -27,7 +27,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
],
{
...
r
esolvers
,
...
gitLabR
esolvers
,
});
});
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeQuery
({
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeQuery
({
query
:
stateQuery
,
query
:
stateQuery
,
...
...
ee/spec/frontend/vue_shared/purchase_flow/components/checkout/zuora_spec.js
View file @
3f5313a6
...
@@ -4,7 +4,7 @@ import AxiosMockAdapter from 'axios-mock-adapter';
...
@@ -4,7 +4,7 @@ import AxiosMockAdapter from 'axios-mock-adapter';
import
{
merge
}
from
'
lodash
'
;
import
{
merge
}
from
'
lodash
'
;
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
{
r
esolvers
}
from
'
ee/subscriptions/buy_addons_shared/graphql/resolvers
'
;
import
{
gitLabR
esolvers
}
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
Zuora
from
'
ee/vue_shared/purchase_flow/components/checkout/zuora.vue
'
;
import
Zuora
from
'
ee/vue_shared/purchase_flow/components/checkout/zuora.vue
'
;
...
@@ -21,7 +21,7 @@ describe('Zuora', () => {
...
@@ -21,7 +21,7 @@ describe('Zuora', () => {
const
createComponent
=
(
props
=
{},
data
=
{},
apolloLocalState
=
{})
=>
{
const
createComponent
=
(
props
=
{},
data
=
{},
apolloLocalState
=
{})
=>
{
const
apolloProvider
=
createMockApolloProvider
(
STEPS
,
STEPS
[
1
],
{
const
apolloProvider
=
createMockApolloProvider
(
STEPS
,
STEPS
[
1
],
{
...
r
esolvers
,
...
gitLabR
esolvers
,
});
});
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeQuery
({
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeQuery
({
query
:
stateQuery
,
query
:
stateQuery
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment