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
75f1f22a
Commit
75f1f22a
authored
Oct 08, 2021
by
Angelo Gulina
Committed by
Nicolò Maria Mezzopera
Oct 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use account id as part of the namespace to init Zuora iframe
parent
27b2b7df
Changes
30
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
247 additions
and
78 deletions
+247
-78
ee/app/assets/javascripts/subscriptions/buy_addons_shared/components/order_summary.vue
...scriptions/buy_addons_shared/components/order_summary.vue
+6
-7
ee/app/assets/javascripts/subscriptions/buy_addons_shared/constants.js
.../javascripts/subscriptions/buy_addons_shared/constants.js
+1
-1
ee/app/assets/javascripts/subscriptions/buy_addons_shared/graphql.js
...ts/javascripts/subscriptions/buy_addons_shared/graphql.js
+3
-3
ee/app/assets/javascripts/subscriptions/buy_addons_shared/graphql/resolvers.js
...ipts/subscriptions/buy_addons_shared/graphql/resolvers.js
+0
-2
ee/app/assets/javascripts/subscriptions/buy_addons_shared/utils.js
...sets/javascripts/subscriptions/buy_addons_shared/utils.js
+4
-3
ee/app/assets/javascripts/subscriptions/buy_minutes/components/app.vue
.../javascripts/subscriptions/buy_minutes/components/app.vue
+2
-3
ee/app/assets/javascripts/subscriptions/buy_minutes/index.js
ee/app/assets/javascripts/subscriptions/buy_minutes/index.js
+1
-0
ee/app/assets/javascripts/subscriptions/buy_storage/components/app.vue
.../javascripts/subscriptions/buy_storage/components/app.vue
+2
-2
ee/app/assets/javascripts/subscriptions/graphql/queries/state.query.graphql
...scripts/subscriptions/graphql/queries/state.query.graphql
+3
-2
ee/app/assets/javascripts/vue_shared/purchase_flow/components/checkout/payment_method.vue
...ared/purchase_flow/components/checkout/payment_method.vue
+14
-3
ee/app/assets/javascripts/vue_shared/purchase_flow/components/checkout/zuora.vue
...ts/vue_shared/purchase_flow/components/checkout/zuora.vue
+15
-3
ee/app/helpers/subscriptions_helper.rb
ee/app/helpers/subscriptions_helper.rb
+1
-0
ee/spec/frontend/subscriptions/buy_addons_shared/components/order_summary_spec.js
...ptions/buy_addons_shared/components/order_summary_spec.js
+13
-16
ee/spec/frontend/subscriptions/buy_addons_shared/resolvers_spec.js
...rontend/subscriptions/buy_addons_shared/resolvers_spec.js
+0
-0
ee/spec/frontend/subscriptions/buy_addons_shared/utils_spec.js
...ec/frontend/subscriptions/buy_addons_shared/utils_spec.js
+3
-3
ee/spec/frontend/subscriptions/buy_minutes/components/checkout/billing_address_spec.js
...s/buy_minutes/components/checkout/billing_address_spec.js
+1
-1
ee/spec/frontend/subscriptions/buy_minutes/components/checkout/confirm_order_spec.js
...ons/buy_minutes/components/checkout/confirm_order_spec.js
+4
-5
ee/spec/frontend/subscriptions/buy_minutes/mock_data.js
ee/spec/frontend/subscriptions/buy_minutes/mock_data.js
+13
-9
ee/spec/frontend/subscriptions/buy_minutes/spec_helper.js
ee/spec/frontend/subscriptions/buy_minutes/spec_helper.js
+3
-2
ee/spec/frontend/subscriptions/new/components/checkout/billing_address_spec.js
...criptions/new/components/checkout/billing_address_spec.js
+1
-1
ee/spec/frontend/subscriptions/new/components/checkout/confirm_order_spec.js
...bscriptions/new/components/checkout/confirm_order_spec.js
+2
-2
ee/spec/frontend/subscriptions/new/components/checkout/payment_method_spec.js
...scriptions/new/components/checkout/payment_method_spec.js
+1
-1
ee/spec/frontend/subscriptions/new/components/checkout/subscription_details_spec.js
...ions/new/components/checkout/subscription_details_spec.js
+1
-1
ee/spec/frontend/subscriptions/new/components/checkout/zuora_spec.js
...ntend/subscriptions/new/components/checkout/zuora_spec.js
+1
-1
ee/spec/frontend/subscriptions/new/components/checkout_spec.js
...ec/frontend/subscriptions/new/components/checkout_spec.js
+1
-1
ee/spec/frontend/vue_shared/purchase_flow/components/checkout/payment_method_spec.js
.../purchase_flow/components/checkout/payment_method_spec.js
+120
-0
ee/spec/frontend/vue_shared/purchase_flow/components/checkout/zuora_spec.js
...ue_shared/purchase_flow/components/checkout/zuora_spec.js
+24
-2
ee/spec/frontend/vue_shared/purchase_flow/components/step_spec.js
...frontend/vue_shared/purchase_flow/components/step_spec.js
+2
-2
ee/spec/helpers/subscriptions_helper_spec.rb
ee/spec/helpers/subscriptions_helper_spec.rb
+2
-2
spec/frontend/__helpers__/flush_promises.js
spec/frontend/__helpers__/flush_promises.js
+3
-0
No files found.
ee/app/assets/javascripts/subscriptions/buy_addons_shared/components/order_summary.vue
View file @
75f1f22a
<
script
>
<
script
>
import
{
GlIcon
,
GlCollapse
,
GlCollapseToggleDirective
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
,
GlCollapse
,
GlCollapseToggleDirective
}
from
'
@gitlab/ui
'
;
import
find
from
'
lodash/find
'
;
import
stateQuery
from
'
ee/subscriptions/graphql/queries/state.query.graphql
'
;
import
stateQuery
from
'
ee/subscriptions/graphql/queries/state.query.graphql
'
;
import
{
TAX_RATE
}
from
'
ee/subscriptions/new/constants
'
;
import
{
TAX_RATE
}
from
'
ee/subscriptions/new/constants
'
;
import
formattingMixins
from
'
ee/subscriptions/new/formatting_mixins
'
;
import
formattingMixins
from
'
ee/subscriptions/new/formatting_mixins
'
;
...
@@ -35,25 +36,23 @@ export default {
...
@@ -35,25 +36,23 @@ export default {
query
:
stateQuery
,
query
:
stateQuery
,
manual
:
true
,
manual
:
true
,
result
({
data
})
{
result
({
data
})
{
this
.
namespaces
=
data
.
namespaces
;
const
id
=
Number
(
data
.
selectedNamespaceId
);
this
.
selectedNamespace
=
find
(
data
.
eligibleNamespaces
,
{
id
});
this
.
subscription
=
data
.
subscription
;
this
.
subscription
=
data
.
subscription
;
},
},
},
},
},
},
data
()
{
data
()
{
return
{
return
{
subscription
:
{},
namespaces
:
[],
isBottomSummaryVisible
:
false
,
isBottomSummaryVisible
:
false
,
selectedNamespace
:
{},
subscription
:
{},
};
};
},
},
computed
:
{
computed
:
{
selectedPlanPrice
()
{
selectedPlanPrice
()
{
return
this
.
plan
.
pricePerYear
;
return
this
.
plan
.
pricePerYear
;
},
},
selectedGroup
()
{
return
this
.
namespaces
.
find
((
group
)
=>
group
.
id
===
Number
(
this
.
subscription
.
namespaceId
));
},
totalExVat
()
{
totalExVat
()
{
return
this
.
subscription
.
quantity
*
this
.
selectedPlanPrice
;
return
this
.
subscription
.
quantity
*
this
.
selectedPlanPrice
;
},
},
...
@@ -67,7 +66,7 @@ export default {
...
@@ -67,7 +66,7 @@ export default {
return
this
.
subscription
.
quantity
>
0
;
return
this
.
subscription
.
quantity
>
0
;
},
},
namespaceName
()
{
namespaceName
()
{
return
this
.
selected
Group
.
name
;
return
this
.
selected
Namespace
.
name
;
},
},
titleWithName
()
{
titleWithName
()
{
return
sprintf
(
this
.
title
,
{
name
:
this
.
namespaceName
});
return
sprintf
(
this
.
title
,
{
name
:
this
.
namespaceName
});
...
...
ee/app/assets/javascripts/subscriptions/buy_addons_shared/constants.js
View file @
75f1f22a
...
@@ -6,7 +6,7 @@ export const planTags = {
...
@@ -6,7 +6,7 @@ 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
CUSTOMER
_CLIENT
=
'
customer
Client
'
;
export
const
CUSTOMER
SDOT_CLIENT
=
'
customersDot
Client
'
;
export
const
GITLAB_CLIENT
=
'
gitlabClient
'
;
export
const
GITLAB_CLIENT
=
'
gitlabClient
'
;
export
const
CI_MINUTES_PER_PACK
=
1000
;
export
const
CI_MINUTES_PER_PACK
=
1000
;
...
...
ee/app/assets/javascripts/subscriptions/buy_addons_shared/graphql.js
View file @
75f1f22a
...
@@ -4,7 +4,7 @@ import VueApollo from 'vue-apollo';
...
@@ -4,7 +4,7 @@ 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
,
CUSTOMER_CLIENT
}
from
'
./constants
'
;
import
{
GITLAB_CLIENT
,
CUSTOMER
SDOT
_CLIENT
}
from
'
./constants
'
;
import
{
resolvers
}
from
'
./graphql/resolvers
'
;
import
{
resolvers
}
from
'
./graphql/resolvers
'
;
Vue
.
use
(
VueApollo
);
Vue
.
use
(
VueApollo
);
...
@@ -13,7 +13,7 @@ const gitlabClient = createClient(merge({}, resolvers, purchaseFlowResolvers), {
...
@@ -13,7 +13,7 @@ const gitlabClient = createClient(merge({}, resolvers, purchaseFlowResolvers), {
typeDefs
,
typeDefs
,
assumeImmutableResults
:
true
,
assumeImmutableResults
:
true
,
});
});
const
customerClient
=
createClient
(
const
customer
sDot
Client
=
createClient
(
{},
{},
{
{
path
:
'
/-/customers_dot/proxy/graphql
'
,
path
:
'
/-/customers_dot/proxy/graphql
'
,
...
@@ -26,6 +26,6 @@ export default new VueApollo({
...
@@ -26,6 +26,6 @@ export default new VueApollo({
defaultClient
:
gitlabClient
,
defaultClient
:
gitlabClient
,
clients
:
{
clients
:
{
[
GITLAB_CLIENT
]:
gitlabClient
,
[
GITLAB_CLIENT
]:
gitlabClient
,
[
CUSTOMER
_CLIENT
]:
customer
Client
,
[
CUSTOMER
SDOT_CLIENT
]:
customersDot
Client
,
},
},
});
});
ee/app/assets/javascripts/subscriptions/buy_addons_shared/graphql/resolvers.js
View file @
75f1f22a
...
@@ -39,11 +39,9 @@ export const resolvers = {
...
@@ -39,11 +39,9 @@ export const resolvers = {
},
},
updateState
:
(
_
,
{
input
},
{
cache
})
=>
{
updateState
:
(
_
,
{
input
},
{
cache
})
=>
{
const
oldState
=
cache
.
readQuery
({
query
:
stateQuery
});
const
oldState
=
cache
.
readQuery
({
query
:
stateQuery
});
const
state
=
produce
(
oldState
,
(
draftState
)
=>
{
const
state
=
produce
(
oldState
,
(
draftState
)
=>
{
merge
(
draftState
,
input
);
merge
(
draftState
,
input
);
});
});
cache
.
writeQuery
({
query
:
stateQuery
,
data
:
state
});
cache
.
writeQuery
({
query
:
stateQuery
,
data
:
state
});
},
},
},
},
...
...
ee/app/assets/javascripts/subscriptions/buy_addons_shared/utils.js
View file @
75f1f22a
...
@@ -12,8 +12,9 @@ function arrayToGraphqlArray(arr, typename) {
...
@@ -12,8 +12,9 @@ function arrayToGraphqlArray(arr, typename) {
export
function
writeInitialDataToApolloCache
(
apolloProvider
,
dataset
)
{
export
function
writeInitialDataToApolloCache
(
apolloProvider
,
dataset
)
{
const
{
groupData
,
namespaceId
,
redirectAfterSuccess
,
subscriptionQuantity
}
=
dataset
;
const
{
groupData
,
namespaceId
,
redirectAfterSuccess
,
subscriptionQuantity
}
=
dataset
;
// eslint-disable-next-line @gitlab/require-i18n-strings
// eslint-disable-next-line @gitlab/require-i18n-strings
const
n
amespaces
=
arrayToGraphqlArray
(
JSON
.
parse
(
groupData
),
'
Namespace
'
);
const
eligibleN
amespaces
=
arrayToGraphqlArray
(
JSON
.
parse
(
groupData
),
'
Namespace
'
);
const
quantity
=
subscriptionQuantity
||
1
;
const
quantity
=
subscriptionQuantity
||
1
;
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeQuery
({
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeQuery
({
...
@@ -23,11 +24,11 @@ export function writeInitialDataToApolloCache(apolloProvider, dataset) {
...
@@ -23,11 +24,11 @@ export function writeInitialDataToApolloCache(apolloProvider, dataset) {
fullName
:
null
,
fullName
:
null
,
isSetupForCompany
:
false
,
isSetupForCompany
:
false
,
selectedPlanId
:
null
,
selectedPlanId
:
null
,
n
amespaces
,
eligibleN
amespaces
,
redirectAfterSuccess
,
redirectAfterSuccess
,
selectedNamespaceId
:
namespaceId
,
subscription
:
{
subscription
:
{
quantity
,
quantity
,
namespaceId
,
// eslint-disable-next-line @gitlab/require-i18n-strings
// eslint-disable-next-line @gitlab/require-i18n-strings
__typename
:
'
Subscription
'
,
__typename
:
'
Subscription
'
,
},
},
...
...
ee/app/assets/javascripts/subscriptions/buy_minutes/components/app.vue
View file @
75f1f22a
...
@@ -20,14 +20,13 @@ import {
...
@@ -20,14 +20,13 @@ import {
I18N_CI_MINUTES_PRICE_PRE_UNIT
,
I18N_CI_MINUTES_PRICE_PRE_UNIT
,
I18N_CI_MINUTES_TITLE
,
I18N_CI_MINUTES_TITLE
,
planTags
,
planTags
,
CUSTOMER_CLIENT
,
CUSTOMER
SDOT
_CLIENT
,
CI_MINUTES_PER_PACK
,
CI_MINUTES_PER_PACK
,
}
from
'
../../buy_addons_shared/constants
'
;
}
from
'
../../buy_addons_shared/constants
'
;
import
plansQuery
from
'
../../graphql/queries/plans.customer.query.graphql
'
;
import
plansQuery
from
'
../../graphql/queries/plans.customer.query.graphql
'
;
export
default
{
export
default
{
name
:
'
BuyCIMinutesApp
'
,
components
:
{
components
:
{
Checkout
,
Checkout
,
GlEmptyState
,
GlEmptyState
,
...
@@ -93,7 +92,7 @@ export default {
...
@@ -93,7 +92,7 @@ export default {
},
},
apollo
:
{
apollo
:
{
plans
:
{
plans
:
{
client
:
CUSTOMER_CLIENT
,
client
:
CUSTOMER
SDOT
_CLIENT
,
query
:
plansQuery
,
query
:
plansQuery
,
variables
:
{
variables
:
{
tags
:
[
planTags
.
CI_1000_MINUTES_PLAN
],
tags
:
[
planTags
.
CI_1000_MINUTES_PLAN
],
...
...
ee/app/assets/javascripts/subscriptions/buy_minutes/index.js
View file @
75f1f22a
...
@@ -17,6 +17,7 @@ export default (el) => {
...
@@ -17,6 +17,7 @@ export default (el) => {
return
new
Vue
({
return
new
Vue
({
el
,
el
,
name
:
'
BuyCIMinutes
'
,
apolloProvider
,
apolloProvider
,
render
(
createElement
)
{
render
(
createElement
)
{
return
createElement
(
extendedApp
);
return
createElement
(
extendedApp
);
...
...
ee/app/assets/javascripts/subscriptions/buy_storage/components/app.vue
View file @
75f1f22a
...
@@ -20,7 +20,7 @@ import {
...
@@ -20,7 +20,7 @@ import {
I18N_STORAGE_PRICE_PRE_UNIT
,
I18N_STORAGE_PRICE_PRE_UNIT
,
I18N_STORAGE_TOOLTIP_NOTE
,
I18N_STORAGE_TOOLTIP_NOTE
,
planTags
,
planTags
,
CUSTOMER_CLIENT
,
CUSTOMER
SDOT
_CLIENT
,
STORAGE_PER_PACK
,
STORAGE_PER_PACK
,
}
from
'
../../buy_addons_shared/constants
'
;
}
from
'
../../buy_addons_shared/constants
'
;
import
plansQuery
from
'
../../graphql/queries/plans.customer.query.graphql
'
;
import
plansQuery
from
'
../../graphql/queries/plans.customer.query.graphql
'
;
...
@@ -94,7 +94,7 @@ export default {
...
@@ -94,7 +94,7 @@ export default {
},
},
apollo
:
{
apollo
:
{
plans
:
{
plans
:
{
client
:
CUSTOMER_CLIENT
,
client
:
CUSTOMER
SDOT
_CLIENT
,
query
:
plansQuery
,
query
:
plansQuery
,
variables
:
{
variables
:
{
tags
:
[
planTags
.
STORAGE_PLAN
],
tags
:
[
planTags
.
STORAGE_PLAN
],
...
...
ee/app/assets/javascripts/subscriptions/graphql/queries/state.query.graphql
View file @
75f1f22a
query
State
{
query
State
{
n
amespaces
@client
{
eligibleN
amespaces
@client
{
id
id
accountId
name
name
users
users
}
}
...
@@ -8,6 +9,7 @@ query State {
...
@@ -8,6 +9,7 @@ query State {
fullName
@client
fullName
@client
isSetupForCompany
@client
isSetupForCompany
@client
selectedPlanId
@client
selectedPlanId
@client
selectedNamespaceId
@client
redirectAfterSuccess
@client
redirectAfterSuccess
@client
customer
@client
{
customer
@client
{
country
country
...
@@ -27,7 +29,6 @@ query State {
...
@@ -27,7 +29,6 @@ query State {
}
}
subscription
@client
{
subscription
@client
{
quantity
quantity
namespaceId
}
}
activeStep
@client
{
activeStep
@client
{
id
id
...
...
ee/app/assets/javascripts/vue_shared/purchase_flow/components/checkout/payment_method.vue
View file @
75f1f22a
<
script
>
<
script
>
import
{
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
GlSprintf
}
from
'
@gitlab/ui
'
;
import
find
from
'
lodash/find
'
;
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
'
;
...
@@ -17,8 +18,18 @@ export default {
...
@@ -17,8 +18,18 @@ export default {
query
:
stateQuery
,
query
:
stateQuery
,
update
:
(
data
)
=>
data
.
paymentMethod
,
update
:
(
data
)
=>
data
.
paymentMethod
,
},
},
selectedNamespace
:
{
query
:
stateQuery
,
update
:
({
eligibleNamespaces
,
selectedNamespaceId
})
=>
{
const
id
=
Number
(
selectedNamespaceId
);
return
find
(
eligibleNamespaces
,
{
id
});
},
},
},
},
computed
:
{
computed
:
{
accountId
()
{
return
this
.
selectedNamespace
?.
accountId
||
''
;
},
isValid
()
{
isValid
()
{
return
Boolean
(
this
.
paymentMethod
.
id
);
return
Boolean
(
this
.
paymentMethod
.
id
);
},
},
...
@@ -40,10 +51,10 @@ export default {
...
@@ -40,10 +51,10 @@ export default {
<
template
>
<
template
>
<step
:step-id=
"$options.stepId"
:title=
"$options.i18n.stepTitle"
:is-valid=
"isValid"
>
<step
:step-id=
"$options.stepId"
:title=
"$options.i18n.stepTitle"
:is-valid=
"isValid"
>
<template
#body
="
{ active }">
<template
#body
="
{ active }">
<zuora
:active=
"active"
/>
<zuora
:active=
"active"
:account-id=
"accountId"
/>
</
template
>
</
template
>
<
template
#summary
>
<
template
#summary
>
<div
class=
"js-summary-line-1
"
>
<div
data-testid=
"card-details
"
>
<gl-sprintf
:message=
"$options.i18n.paymentMethod"
>
<gl-sprintf
:message=
"$options.i18n.paymentMethod"
>
<template
#cardType
>
<template
#cardType
>
{{
paymentMethod
.
creditCardType
}}
{{
paymentMethod
.
creditCardType
}}
...
@@ -53,7 +64,7 @@ export default {
...
@@ -53,7 +64,7 @@ export default {
</
template
>
</
template
>
</gl-sprintf>
</gl-sprintf>
</div>
</div>
<div
class=
"js-summary-line-2
"
>
<div
data-testid=
"card-expiration
"
>
{{ expirationDate }}
{{ expirationDate }}
</div>
</div>
</template>
</template>
...
...
ee/app/assets/javascripts/vue_shared/purchase_flow/components/checkout/zuora.vue
View file @
75f1f22a
...
@@ -23,11 +23,16 @@ export default {
...
@@ -23,11 +23,16 @@ export default {
type
:
Boolean
,
type
:
Boolean
,
required
:
true
,
required
:
true
,
},
},
accountId
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
},
},
data
()
{
data
()
{
return
{
return
{
isLoading
:
false
,
isLoading
:
false
,
paymentFormParams
:
null
,
paymentFormParams
:
{}
,
zuoraLoaded
:
false
,
zuoraLoaded
:
false
,
zuoraScriptEl
:
null
,
zuoraScriptEl
:
null
,
};
};
...
@@ -36,6 +41,14 @@ export default {
...
@@ -36,6 +41,14 @@ export default {
shouldShowZuoraFrame
()
{
shouldShowZuoraFrame
()
{
return
this
.
active
&&
this
.
zuoraLoaded
&&
!
this
.
isLoading
;
return
this
.
active
&&
this
.
zuoraLoaded
&&
!
this
.
isLoading
;
},
},
renderParams
()
{
return
{
...
this
.
paymentFormParams
,
...
ZUORA_IFRAME_OVERRIDE_PARAMS
,
// @TODO: should the component handle re-rendering the form in case this changes?
field_accountId
:
this
.
accountId
,
};
},
},
},
mounted
()
{
mounted
()
{
this
.
loadZuoraScript
();
this
.
loadZuoraScript
();
...
@@ -94,9 +107,8 @@ export default {
...
@@ -94,9 +107,8 @@ export default {
});
});
},
},
renderZuoraIframe
()
{
renderZuoraIframe
()
{
const
params
=
{
...
this
.
paymentFormParams
,
...
ZUORA_IFRAME_OVERRIDE_PARAMS
};
window
.
Z
.
runAfterRender
(
this
.
zuoraIframeRendered
);
window
.
Z
.
runAfterRender
(
this
.
zuoraIframeRendered
);
window
.
Z
.
render
(
p
arams
,
{},
this
.
paymentFormSubmitted
);
window
.
Z
.
render
(
this
.
renderP
arams
,
{},
this
.
paymentFormSubmitted
);
},
},
activateNextStep
()
{
activateNextStep
()
{
return
this
.
$apollo
return
this
.
$apollo
...
...
ee/app/helpers/subscriptions_helper.rb
View file @
75f1f22a
...
@@ -60,6 +60,7 @@ module SubscriptionsHelper
...
@@ -60,6 +60,7 @@ module SubscriptionsHelper
def
present_group
(
namespace
)
def
present_group
(
namespace
)
{
{
id:
namespace
.
id
,
id:
namespace
.
id
,
account_id:
nil
,
name:
namespace
.
name
,
name:
namespace
.
name
,
users:
namespace
.
member_count
,
users:
namespace
.
member_count
,
guests:
namespace
.
guest_count
guests:
namespace
.
guest_count
...
...
ee/spec/frontend/subscriptions/buy_addons_shared/components/order_summary_spec.js
View file @
75f1f22a
import
{
shallowMount
,
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
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
OrderSummary
from
'
ee/subscriptions/buy_addons_shared/components/order_summary.vue
'
;
import
OrderSummary
from
'
ee/subscriptions/buy_addons_shared/components/order_summary.vue
'
;
import
subscriptionsResolvers
from
'
ee/subscriptions/buy_addons_shared/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
'
;
...
@@ -17,32 +18,30 @@ localVue.use(VueApollo);
...
@@ -17,32 +18,30 @@ localVue.use(VueApollo);
describe
(
'
Order Summary
'
,
()
=>
{
describe
(
'
Order Summary
'
,
()
=>
{
const
resolvers
=
{
...
purchaseFlowResolvers
,
...
subscriptionsResolvers
};
const
resolvers
=
{
...
purchaseFlowResolvers
,
...
subscriptionsResolvers
};
const
selectedNamespaceId
=
mockParsedNamespaces
[
0
].
id
;
const
initialStateData
=
{
const
initialStateData
=
{
selectedPlanId
:
'
ciMinutesPackPlanId
'
,
eligibleNamespaces
:
mockParsedNamespaces
,
namespaces
:
[
mockParsedNamespaces
[
0
]],
selectedNamespaceId
,
subscription
:
{
subscription
:
{},
namespaceId
:
mockParsedNamespaces
[
0
].
id
,
},
};
};
let
wrapper
;
let
wrapper
;
const
findAmount
=
()
=>
wrapper
.
findByTestId
(
'
amount
'
);
const
findTitle
=
()
=>
wrapper
.
findByTestId
(
'
title
'
);
const
createMockApolloProvider
=
(
stateData
=
{})
=>
{
const
createMockApolloProvider
=
(
stateData
=
{})
=>
{
const
mockApollo
=
createMockApollo
([],
resolvers
);
const
mockApollo
=
createMockApollo
([],
resolvers
);
const
data
=
merge
({},
mockStateData
,
initialStateData
,
stateData
);
const
data
=
merge
({},
mockStateData
,
initialStateData
,
stateData
);
mockApollo
.
clients
.
defaultClient
.
cache
.
writeQuery
({
mockApollo
.
clients
.
defaultClient
.
cache
.
writeQuery
({
query
:
stateQuery
,
query
:
stateQuery
,
data
,
data
,
});
});
return
mockApollo
;
return
mockApollo
;
};
};
const
createComponent
=
(
stateData
)
=>
{
const
createComponent
=
(
stateData
)
=>
{
const
apolloProvider
=
createMockApolloProvider
(
stateData
);
const
apolloProvider
=
createMockApolloProvider
(
stateData
);
wrapper
=
shallowMountExtended
(
OrderSummary
,
{
wrapper
=
shallowMount
(
OrderSummary
,
{
localVue
,
localVue
,
apolloProvider
,
apolloProvider
,
propsData
:
{
propsData
:
{
...
@@ -65,9 +64,7 @@ describe('Order Summary', () => {
...
@@ -65,9 +64,7 @@ describe('Order Summary', () => {
});
});
it
(
'
displays the title
'
,
()
=>
{
it
(
'
displays the title
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="title"]
'
).
text
()).
toMatchInterpolatedText
(
expect
(
findTitle
().
text
()).
toMatchInterpolatedText
(
"
Gitlab Org's CI minutes
"
);
"
Gitlab Org's CI minutes
"
,
);
});
});
});
});
...
@@ -79,7 +76,7 @@ describe('Order Summary', () => {
...
@@ -79,7 +76,7 @@ describe('Order Summary', () => {
});
});
it
(
'
renders amount
'
,
()
=>
{
it
(
'
renders amount
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="amount"]
'
).
text
()).
toBe
(
'
$30
'
);
expect
(
findAmount
(
).
text
()).
toBe
(
'
$30
'
);
});
});
});
});
...
@@ -91,7 +88,7 @@ describe('Order Summary', () => {
...
@@ -91,7 +88,7 @@ describe('Order Summary', () => {
});
});
it
(
'
does not render amount
'
,
()
=>
{
it
(
'
does not render amount
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="amount"]
'
).
text
()).
toBe
(
'
-
'
);
expect
(
findAmount
(
).
text
()).
toBe
(
'
-
'
);
});
});
});
});
});
});
ee/spec/frontend/subscriptions/buy_
minutes/graphql
/resolvers_spec.js
→
ee/spec/frontend/subscriptions/buy_
addons_shared
/resolvers_spec.js
View file @
75f1f22a
File moved
ee/spec/frontend/subscriptions/buy_
minutes
/utils_spec.js
→
ee/spec/frontend/subscriptions/buy_
addons_shared
/utils_spec.js
View file @
75f1f22a
import
apolloProvider
from
'
ee/subscriptions/buy_addons_shared/graphql
'
;
import
apolloProvider
from
'
ee/subscriptions/buy_addons_shared/graphql
'
;
import
{
writeInitialDataToApolloCache
}
from
'
ee/subscriptions/buy_addons_shared/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
'
.
./buy_minutes
/mock_data
'
;
const
DEFAULT_DATA
=
{
const
DEFAULT_DATA
=
{
groupData
:
mockNamespaces
,
groupData
:
mockNamespaces
,
...
@@ -26,7 +26,7 @@ describe('utils', () => {
...
@@ -26,7 +26,7 @@ describe('utils', () => {
${
''
}
|
${{}}
|
$
{
true
}
${
''
}
|
${{}}
|
$
{
true
}
${
mockNamespaces
}
|
${
mockParsedNamespaces
}
|
${
false
}
${
mockNamespaces
}
|
${
mockParsedNamespaces
}
|
${
false
}
`
(
'
parameter decoding
'
,
({
namespaces
,
parsedNamespaces
,
throws
})
=>
{
`
(
'
parameter decoding
'
,
({
namespaces
,
parsedNamespaces
,
throws
})
=>
{
it
(
`decodes
$
{
namespaces
}
to
${
parsedNamespaces
}
`
,
async
()
=>
{
it
(
`decodes $
namespaces to $parsedNamespaces
`
,
async
()
=>
{
if
(
throws
)
{
if
(
throws
)
{
expect
(()
=>
{
expect
(()
=>
{
writeInitialDataToApolloCache
(
apolloProvider
,
{
groupData
:
namespaces
});
writeInitialDataToApolloCache
(
apolloProvider
,
{
groupData
:
namespaces
});
...
@@ -39,7 +39,7 @@ describe('utils', () => {
...
@@ -39,7 +39,7 @@ describe('utils', () => {
const
sourceData
=
await
apolloProvider
.
clients
.
defaultClient
.
query
({
const
sourceData
=
await
apolloProvider
.
clients
.
defaultClient
.
query
({
query
:
stateQuery
,
query
:
stateQuery
,
});
});
expect
(
sourceData
.
data
.
n
amespaces
).
toStrictEqual
(
parsedNamespaces
);
expect
(
sourceData
.
data
.
eligibleN
amespaces
).
toStrictEqual
(
parsedNamespaces
);
}
}
});
});
});
});
...
...
ee/spec/frontend/subscriptions/buy_minutes/components/checkout/billing_address_spec.js
View file @
75f1f22a
...
@@ -61,7 +61,7 @@ describe('Billing Address', () => {
...
@@ -61,7 +61,7 @@ describe('Billing Address', () => {
});
});
describe
(
'
validations
'
,
()
=>
{
describe
(
'
validations
'
,
()
=>
{
const
isStepValid
=
()
=>
wrapper
.
find
(
Step
).
props
(
'
isValid
'
);
const
isStepValid
=
()
=>
wrapper
.
find
Component
(
Step
).
props
(
'
isValid
'
);
const
customerData
=
{
const
customerData
=
{
country
:
'
US
'
,
country
:
'
US
'
,
address1
:
'
address line 1
'
,
address1
:
'
address line 1
'
,
...
...
ee/spec/frontend/subscriptions/buy_minutes/components/checkout/confirm_order_spec.js
View file @
75f1f22a
...
@@ -11,20 +11,19 @@ import { createMockApolloProvider } from 'ee_jest/vue_shared/purchase_flow/spec_
...
@@ -11,20 +11,19 @@ import { createMockApolloProvider } from 'ee_jest/vue_shared/purchase_flow/spec_
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
flash
from
'
~/flash
'
;
import
flash
from
'
~/flash
'
;
import
*
as
UrlUtility
from
'
~/lib/utils/url_utility
'
;
import
*
as
UrlUtility
from
'
~/lib/utils/url_utility
'
;
import
flushPromises
from
'
helpers/flush_promises
'
;
jest
.
mock
(
'
~/lib/utils/url_utility
'
);
jest
.
mock
(
'
~/lib/utils/url_utility
'
);
jest
.
mock
(
'
~/flash
'
);
jest
.
mock
(
'
~/flash
'
);
jest
.
mock
(
'
ee/api.js
'
);
jest
.
mock
(
'
ee/api.js
'
);
const
flushPromises
=
()
=>
new
Promise
(
setImmediate
);
describe
(
'
Confirm Order
'
,
()
=>
{
describe
(
'
Confirm Order
'
,
()
=>
{
let
mockApolloProvider
;
let
mockApolloProvider
;
let
wrapper
;
let
wrapper
;
const
findRootElement
=
()
=>
wrapper
.
findByTestId
(
'
confirm-order-root
'
);
const
findRootElement
=
()
=>
wrapper
.
findByTestId
(
'
confirm-order-root
'
);
const
findConfirmButton
=
()
=>
wrapper
.
find
(
GlButton
);
const
findConfirmButton
=
()
=>
wrapper
.
find
Component
(
GlButton
);
const
findLoadingIcon
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
const
findLoadingIcon
=
()
=>
wrapper
.
find
Component
(
GlLoadingIcon
);
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
localVue
.
use
(
VueApollo
);
localVue
.
use
(
VueApollo
);
...
@@ -77,7 +76,7 @@ describe('Confirm Order', () => {
...
@@ -77,7 +76,7 @@ describe('Confirm Order', () => {
expect
(
Api
.
confirmOrder
).
toHaveBeenCalledTimes
(
1
);
expect
(
Api
.
confirmOrder
).
toHaveBeenCalledTimes
(
1
);
expect
(
Api
.
confirmOrder
.
mock
.
calls
[
0
][
0
]).
toMatchObject
({
expect
(
Api
.
confirmOrder
.
mock
.
calls
[
0
][
0
]).
toMatchObject
({
setup_for_company
:
true
,
setup_for_company
:
true
,
selected_group
:
null
,
selected_group
:
undefined
,
new_user
:
false
,
new_user
:
false
,
redirect_after_success
:
'
/path/to/redirect/
'
,
redirect_after_success
:
'
/path/to/redirect/
'
,
customer
:
{
customer
:
{
...
...
ee/spec/frontend/subscriptions/buy_minutes/mock_data.js
View file @
75f1f22a
import
{
STEPS
}
from
'
ee/subscriptions/constants
'
;
import
{
STEPS
}
from
'
ee/subscriptions/constants
'
;
export
const
accountId
=
'
111111111111
'
;
export
const
mockCiMinutesPlans
=
[
export
const
mockCiMinutesPlans
=
[
{
{
id
:
'
ciMinutesPackPlanId
'
,
id
:
'
ciMinutesPackPlanId
'
,
...
@@ -9,16 +11,18 @@ export const mockCiMinutesPlans = [
...
@@ -9,16 +11,18 @@ export const mockCiMinutesPlans = [
__typename
:
'
Plan
'
,
__typename
:
'
Plan
'
,
},
},
];
];
export
const
mockNamespaces
=
'
[{"id":132,"name":"Gitlab Org","users":3},{"id":483,"name":"Gnuwget","users":12}]
'
;
export
const
mockParsedNamespaces
=
[
export
const
mockNamespaces
=
`
{
__typename
:
'
Namespace
'
,
id
:
132
,
name
:
'
Gitlab Org
'
,
users
:
3
},
[{"id":132,"accountId":"
${
accountId
}
","name":"Gitlab Org","users":3},
{
__typename
:
'
Namespace
'
,
id
:
483
,
name
:
'
Gnuwget
'
,
users
:
12
},
{"id":483,"accountId":null,"name":"Gnuwget","users":12}]
];
`
;
export
const
mockParsedNamespaces
=
JSON
.
parse
(
mockNamespaces
).
map
((
namespace
)
=>
({
...
namespace
,
__typename
:
'
Namespace
'
,
}));
export
const
mockNewUser
=
'
false
'
;
export
const
mockNewUser
=
'
false
'
;
export
const
mockFullName
=
'
John Admin
'
;
export
const
mockSetupForCompany
=
'
true
'
;
export
const
mockSetupForCompany
=
'
true
'
;
export
const
mockDefaultCache
=
{
export
const
mockDefaultCache
=
{
...
@@ -28,13 +32,13 @@ export const mockDefaultCache = {
...
@@ -28,13 +32,13 @@ export const mockDefaultCache = {
};
};
export
const
stateData
=
{
export
const
stateData
=
{
n
amespaces
:
[],
eligibleN
amespaces
:
[],
subscription
:
{
subscription
:
{
quantity
:
1
,
quantity
:
1
,
namespaceId
:
null
,
__typename
:
'
Subscription
'
,
__typename
:
'
Subscription
'
,
},
},
redirectAfterSuccess
:
'
/path/to/redirect/
'
,
redirectAfterSuccess
:
'
/path/to/redirect/
'
,
selectedNamespaceId
:
null
,
selectedPlanId
:
null
,
selectedPlanId
:
null
,
paymentMethod
:
{
paymentMethod
:
{
id
:
null
,
id
:
null
,
...
...
ee/spec/frontend/subscriptions/buy_minutes/spec_helper.js
View file @
75f1f22a
...
@@ -2,6 +2,7 @@ import VueApollo from 'vue-apollo';
...
@@ -2,6 +2,7 @@ import VueApollo from 'vue-apollo';
import
{
writeInitialDataToApolloCache
}
from
'
ee/subscriptions/buy_addons_shared/utils
'
;
import
{
writeInitialDataToApolloCache
}
from
'
ee/subscriptions/buy_addons_shared/utils
'
;
import
plansQuery
from
'
ee/subscriptions/graphql/queries/plans.customer.query.graphql
'
;
import
plansQuery
from
'
ee/subscriptions/graphql/queries/plans.customer.query.graphql
'
;
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
{
mockCiMinutesPlans
,
mockDefaultCache
}
from
'
./mock_data
'
;
import
{
mockCiMinutesPlans
,
mockDefaultCache
}
from
'
./mock_data
'
;
export
function
createMockApolloProvider
(
mockResponses
=
{},
dataset
=
{})
{
export
function
createMockApolloProvider
(
mockResponses
=
{},
dataset
=
{})
{
...
@@ -12,11 +13,11 @@ export function createMockApolloProvider(mockResponses = {}, dataset = {}) {
...
@@ -12,11 +13,11 @@ export function createMockApolloProvider(mockResponses = {}, dataset = {}) {
const
{
quantity
}
=
dataset
;
const
{
quantity
}
=
dataset
;
const
mockDefaultClient
=
createMockClient
();
const
mockDefaultClient
=
createMockClient
();
const
mockCustomerClient
=
createMockClient
([[
plansQuery
,
plansQueryMock
]]);
const
mockCustomer
sDot
Client
=
createMockClient
([[
plansQuery
,
plansQueryMock
]]);
const
apolloProvider
=
new
VueApollo
({
const
apolloProvider
=
new
VueApollo
({
defaultClient
:
mockDefaultClient
,
defaultClient
:
mockDefaultClient
,
clients
:
{
customerClient
:
mockCustomer
Client
},
clients
:
{
[
CUSTOMERSDOT_CLIENT
]:
mockCustomersDot
Client
},
});
});
writeInitialDataToApolloCache
(
apolloProvider
,
{
writeInitialDataToApolloCache
(
apolloProvider
,
{
...
...
ee/spec/frontend/subscriptions/new/components/checkout/billing_address_spec.js
View file @
75f1f22a
...
@@ -85,7 +85,7 @@ describe('Billing Address', () => {
...
@@ -85,7 +85,7 @@ describe('Billing Address', () => {
});
});
describe
(
'
validations
'
,
()
=>
{
describe
(
'
validations
'
,
()
=>
{
const
isStepValid
=
()
=>
wrapper
.
find
(
Step
).
props
(
'
isValid
'
);
const
isStepValid
=
()
=>
wrapper
.
find
Component
(
Step
).
props
(
'
isValid
'
);
beforeEach
(()
=>
{
beforeEach
(()
=>
{
store
.
commit
(
types
.
UPDATE_COUNTRY
,
'
country
'
);
store
.
commit
(
types
.
UPDATE_COUNTRY
,
'
country
'
);
...
...
ee/spec/frontend/subscriptions/new/components/checkout/confirm_order_spec.js
View file @
75f1f22a
...
@@ -31,8 +31,8 @@ describe('Confirm Order', () => {
...
@@ -31,8 +31,8 @@ describe('Confirm Order', () => {
});
});
}
}
const
findConfirmButton
=
()
=>
wrapper
.
find
(
GlButton
);
const
findConfirmButton
=
()
=>
wrapper
.
find
Component
(
GlButton
);
const
findLoadingIcon
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
const
findLoadingIcon
=
()
=>
wrapper
.
find
Component
(
GlLoadingIcon
);
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
...
...
ee/spec/frontend/subscriptions/new/components/checkout/payment_method_spec.js
View file @
75f1f22a
...
@@ -44,7 +44,7 @@ describe('Payment Method', () => {
...
@@ -44,7 +44,7 @@ describe('Payment Method', () => {
});
});
describe
(
'
validations
'
,
()
=>
{
describe
(
'
validations
'
,
()
=>
{
const
isStepValid
=
()
=>
wrapper
.
find
(
Step
).
props
(
'
isValid
'
);
const
isStepValid
=
()
=>
wrapper
.
find
Component
(
Step
).
props
(
'
isValid
'
);
it
(
'
should be valid when paymentMethodId is defined
'
,
()
=>
{
it
(
'
should be valid when paymentMethodId is defined
'
,
()
=>
{
expect
(
isStepValid
()).
toBe
(
true
);
expect
(
isStepValid
()).
toBe
(
true
);
...
...
ee/spec/frontend/subscriptions/new/components/checkout/subscription_details_spec.js
View file @
75f1f22a
...
@@ -263,7 +263,7 @@ describe('Subscription Details', () => {
...
@@ -263,7 +263,7 @@ describe('Subscription Details', () => {
});
});
describe
(
'
validations
'
,
()
=>
{
describe
(
'
validations
'
,
()
=>
{
const
isStepValid
=
()
=>
wrapper
.
find
(
Step
).
props
(
'
isValid
'
);
const
isStepValid
=
()
=>
wrapper
.
find
Component
(
Step
).
props
(
'
isValid
'
);
let
store
;
let
store
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
...
ee/spec/frontend/subscriptions/new/components/checkout/zuora_spec.js
View file @
75f1f22a
...
@@ -39,7 +39,7 @@ describe('Zuora', () => {
...
@@ -39,7 +39,7 @@ describe('Zuora', () => {
});
});
};
};
const
findLoading
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
const
findLoading
=
()
=>
wrapper
.
find
Component
(
GlLoadingIcon
);
const
findZuoraPayment
=
()
=>
wrapper
.
find
(
'
#zuora_payment
'
);
const
findZuoraPayment
=
()
=>
wrapper
.
find
(
'
#zuora_payment
'
);
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
...
ee/spec/frontend/subscriptions/new/components/checkout_spec.js
View file @
75f1f22a
...
@@ -17,7 +17,7 @@ describe('Checkout', () => {
...
@@ -17,7 +17,7 @@ describe('Checkout', () => {
});
});
};
};
const
findProgressBar
=
()
=>
wrapper
.
find
(
ProgressBar
);
const
findProgressBar
=
()
=>
wrapper
.
find
Component
(
ProgressBar
);
beforeEach
(()
=>
{
beforeEach
(()
=>
{
store
=
createStore
();
store
=
createStore
();
...
...
ee/spec/frontend/
subscriptions/buy_minutes
/components/checkout/payment_method_spec.js
→
ee/spec/frontend/
vue_shared/purchase_flow
/components/checkout/payment_method_spec.js
View file @
75f1f22a
import
{
mount
,
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
{
resolvers
}
from
'
ee/subscriptions/buy_addons_shared/graphql/resolvers
'
;
import
{
resolvers
}
from
'
ee/subscriptions/buy_addons_shared/graphql/resolvers
'
;
...
@@ -6,8 +6,13 @@ import { STEPS } from 'ee/subscriptions/constants';
...
@@ -6,8 +6,13 @@ 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
'
;
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
{
mockParsedNamespaces
,
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
Zuora
from
'
ee/vue_shared/purchase_flow/components/checkout/zuora.vue
'
;
import
{
mountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
localVue
.
use
(
VueApollo
);
localVue
.
use
(
VueApollo
);
...
@@ -15,6 +20,12 @@ localVue.use(VueApollo);
...
@@ -15,6 +20,12 @@ localVue.use(VueApollo);
describe
(
'
Payment Method
'
,
()
=>
{
describe
(
'
Payment Method
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
const
findCCDetails
=
()
=>
wrapper
.
findByTestId
(
'
card-details
'
);
const
findCCExpiration
=
()
=>
wrapper
.
findByTestId
(
'
card-expiration
'
);
const
findZuora
=
()
=>
wrapper
.
findComponent
(
Zuora
);
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
],
{
...
resolvers
,
...
resolvers
,
...
@@ -24,7 +35,7 @@ describe('Payment Method', () => {
...
@@ -24,7 +35,7 @@ describe('Payment Method', () => {
data
:
merge
({},
initialStateData
,
apolloLocalState
),
data
:
merge
({},
initialStateData
,
apolloLocalState
),
});
});
return
mount
(
PaymentMethod
,
{
return
mount
Extended
(
PaymentMethod
,
{
localVue
,
localVue
,
apolloProvider
,
apolloProvider
,
});
});
...
@@ -46,14 +57,12 @@ describe('Payment Method', () => {
...
@@ -46,14 +57,12 @@ describe('Payment Method', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
describe
(
'
validations
'
,
()
=>
{
describe
(
'
payment method step
'
,
()
=>
{
const
isStepValid
=
()
=>
wrapper
.
find
(
Step
).
props
(
'
isValid
'
);
it
(
'
is valid when paymentMethodId is defined
'
,
()
=>
{
it
(
'
should be valid when paymentMethodId is defined
'
,
()
=>
{
expect
(
isStepValid
()).
toBe
(
true
);
expect
(
isStepValid
()).
toBe
(
true
);
});
});
it
(
'
should be
invalid when paymentMethodId is undefined
'
,
()
=>
{
it
(
'
is
invalid when paymentMethodId is undefined
'
,
()
=>
{
wrapper
=
createComponent
({
wrapper
=
createComponent
({
paymentMethod
:
{
id
:
null
},
paymentMethod
:
{
id
:
null
},
});
});
...
@@ -62,15 +71,50 @@ describe('Payment Method', () => {
...
@@ -62,15 +71,50 @@ describe('Payment Method', () => {
});
});
});
});
describe
(
'
showing the summary
'
,
()
=>
{
describe
(
'
summary
'
,
()
=>
{
it
(
'
should show the entered credit card details
'
,
()
=>
{
it
(
'
shows the entered credit card details
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-summary-line-1
'
).
text
()).
toMatchInterpolatedText
(
expect
(
findCCDetails
().
text
()).
toMatchInterpolatedText
(
'
Visa ending in 4242
'
);
'
Visa ending in 4242
'
,
});
);
it
(
'
shows the entered credit card expiration date
'
,
()
=>
{
expect
(
findCCExpiration
().
text
()).
toBe
(
'
Exp 12/09
'
);
});
});
describe
(
'
Zuora Component
'
,
()
=>
{
const
eligibleNamespaces
=
mockParsedNamespaces
;
const
active
=
true
;
const
activeStep
=
STEPS
[
2
];
describe
(
'
when the selected namespace exists
'
,
()
=>
{
describe
(
'
when it has an account id
'
,
()
=>
{
it
(
'
has the selected account id
'
,
()
=>
{
const
{
accountId
,
id
}
=
mockParsedNamespaces
[
0
];
const
selectedNamespaceId
=
`
${
id
}
`
;
wrapper
=
createComponent
({
eligibleNamespaces
,
selectedNamespaceId
,
activeStep
});
expect
(
findZuora
().
props
()).
toMatchObject
({
active
,
accountId
});
});
});
describe
(
'
when it has no account id
'
,
()
=>
{
it
(
'
has the default account id
'
,
()
=>
{
const
{
id
}
=
mockParsedNamespaces
[
1
];
const
selectedNamespaceId
=
`
${
id
}
`
;
wrapper
=
createComponent
({
eligibleNamespaces
,
selectedNamespaceId
,
activeStep
});
expect
(
findZuora
().
props
()).
toMatchObject
({
active
,
accountId
:
''
});
});
});
});
});
it
(
'
should show the entered credit card expiration date
'
,
()
=>
{
describe
(
'
when the selected namespace does not exists
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-summary-line-2
'
).
text
()).
toBe
(
'
Exp 12/09
'
);
it
(
'
has the default account id
'
,
()
=>
{
const
selectedNamespaceId
=
`000`
;
wrapper
=
createComponent
({
eligibleNamespaces
,
selectedNamespaceId
,
activeStep
});
expect
(
findZuora
().
props
()).
toMatchObject
({
active
,
accountId
:
''
});
});
});
});
});
});
});
});
ee/spec/frontend/
subscriptions/buy_minutes
/components/checkout/zuora_spec.js
→
ee/spec/frontend/
vue_shared/purchase_flow
/components/checkout/zuora_spec.js
View file @
75f1f22a
...
@@ -10,6 +10,7 @@ import Zuora from 'ee/vue_shared/purchase_flow/components/checkout/zuora.vue';
...
@@ -10,6 +10,7 @@ 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
flushPromises
from
'
helpers/flush_promises
'
;
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
localVue
.
use
(
VueApollo
);
localVue
.
use
(
VueApollo
);
...
@@ -39,7 +40,7 @@ describe('Zuora', () => {
...
@@ -39,7 +40,7 @@ describe('Zuora', () => {
});
});
};
};
const
findLoading
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
const
findLoading
=
()
=>
wrapper
.
find
Component
(
GlLoadingIcon
);
const
findZuoraPayment
=
()
=>
wrapper
.
find
(
'
#zuora_payment
'
);
const
findZuoraPayment
=
()
=>
wrapper
.
find
(
'
#zuora_payment
'
);
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
@@ -47,7 +48,7 @@ describe('Zuora', () => {
...
@@ -47,7 +48,7 @@ describe('Zuora', () => {
runAfterRender
(
fn
)
{
runAfterRender
(
fn
)
{
return
Promise
.
resolve
().
then
(
fn
);
return
Promise
.
resolve
().
then
(
fn
);
},
},
render
()
{}
,
render
:
jest
.
fn
()
,
};
};
axiosMock
=
new
AxiosMockAdapter
(
axios
);
axiosMock
=
new
AxiosMockAdapter
(
axios
);
...
@@ -97,4 +98,25 @@ describe('Zuora', () => {
...
@@ -97,4 +98,25 @@ describe('Zuora', () => {
expect
(
findZuoraPayment
().
isVisible
()).
toBe
(
false
);
expect
(
findZuoraPayment
().
isVisible
()).
toBe
(
false
);
});
});
});
});
describe
.
each
([
''
,
'
111111
'
])(
'
when rendering the iframe with account id: %s
'
,
(
id
)
=>
{
beforeEach
(()
=>
{
wrapper
=
createComponent
({
accountId
:
id
},
{
isLoading
:
false
});
wrapper
.
vm
.
zuoraScriptEl
.
onload
();
return
flushPromises
();
});
it
(
`calls render with
${
id
}
`
,
()
=>
{
expect
(
window
.
Z
.
render
).
toHaveBeenCalledWith
(
{
field_accountId
:
id
,
retainValues
:
'
true
'
,
style
:
'
inline
'
,
submitEnabled
:
'
true
'
,
},
{},
expect
.
any
(
Function
),
);
});
});
});
});
ee/spec/frontend/vue_shared/purchase_flow/components/step_spec.js
View file @
75f1f22a
...
@@ -171,14 +171,14 @@ describe('Step', () => {
...
@@ -171,14 +171,14 @@ describe('Step', () => {
const
mockApollo
=
createMockApolloProvider
(
STEPS
,
1
);
const
mockApollo
=
createMockApolloProvider
(
STEPS
,
1
);
wrapper
=
createComponent
({
apolloProvider
:
mockApollo
});
wrapper
=
createComponent
({
apolloProvider
:
mockApollo
});
expect
(
wrapper
.
find
(
GlButton
).
attributes
(
'
disabled
'
)).
toBeUndefined
();
expect
(
wrapper
.
find
Component
(
GlButton
).
attributes
(
'
disabled
'
)).
toBeUndefined
();
});
});
it
(
'
displays an error if navigating too far
'
,
async
()
=>
{
it
(
'
displays an error if navigating too far
'
,
async
()
=>
{
const
mockApollo
=
createMockApolloProvider
(
STEPS
,
2
);
const
mockApollo
=
createMockApolloProvider
(
STEPS
,
2
);
wrapper
=
createComponent
({
propsData
:
{
stepId
:
STEPS
[
2
].
id
},
apolloProvider
:
mockApollo
});
wrapper
=
createComponent
({
propsData
:
{
stepId
:
STEPS
[
2
].
id
},
apolloProvider
:
mockApollo
});
wrapper
.
find
(
GlButton
).
vm
.
$emit
(
'
click
'
);
wrapper
.
find
Component
(
GlButton
).
vm
.
$emit
(
'
click
'
);
await
waitForPromises
();
await
waitForPromises
();
expect
(
flash
.
mock
.
calls
).
toHaveLength
(
1
);
expect
(
flash
.
mock
.
calls
).
toHaveLength
(
1
);
...
...
ee/spec/helpers/subscriptions_helper_spec.rb
View file @
75f1f22a
...
@@ -51,7 +51,7 @@ RSpec.describe SubscriptionsHelper do
...
@@ -51,7 +51,7 @@ RSpec.describe SubscriptionsHelper do
it
{
is_expected
.
to
include
(
plan_id:
'bronze_id'
)
}
it
{
is_expected
.
to
include
(
plan_id:
'bronze_id'
)
}
it
{
is_expected
.
to
include
(
namespace_id:
group
.
id
.
to_s
)
}
it
{
is_expected
.
to
include
(
namespace_id:
group
.
id
.
to_s
)
}
it
{
is_expected
.
to
include
(
source:
'some_source'
)
}
it
{
is_expected
.
to
include
(
source:
'some_source'
)
}
it
{
is_expected
.
to
include
(
group_data:
%Q{[{"id":
#{
group
.
id
}
,"name":"My Namespace","users":2,"guests":1}]}
)
}
it
{
is_expected
.
to
include
(
group_data:
%Q{[{"id":
#{
group
.
id
}
,"
account_id":null,"
name":"My Namespace","users":2,"guests":1}]}
)
}
describe
'new_user'
do
describe
'new_user'
do
where
(
:referer
,
:expected_result
)
do
where
(
:referer
,
:expected_result
)
do
...
@@ -150,7 +150,7 @@ RSpec.describe SubscriptionsHelper do
...
@@ -150,7 +150,7 @@ RSpec.describe SubscriptionsHelper do
it
{
is_expected
.
to
include
(
namespace_id:
group
.
id
.
to_s
)
}
it
{
is_expected
.
to
include
(
namespace_id:
group
.
id
.
to_s
)
}
it
{
is_expected
.
to
include
(
source:
'some_source'
)
}
it
{
is_expected
.
to
include
(
source:
'some_source'
)
}
it
{
is_expected
.
to
include
(
group_data:
%Q{[{"id":
#{
group
.
id
}
,"name":"My Namespace","users":1,"guests":0}]}
)
}
it
{
is_expected
.
to
include
(
group_data:
%Q{[{"id":
#{
group
.
id
}
,"
account_id":null,"
name":"My Namespace","users":1,"guests":0}]}
)
}
it
{
is_expected
.
to
include
(
redirect_after_success:
group_usage_quotas_path
(
group
,
anchor:
anchor
,
purchased_product:
purchased_product
))
}
it
{
is_expected
.
to
include
(
redirect_after_success:
group_usage_quotas_path
(
group
,
anchor:
anchor
,
purchased_product:
purchased_product
))
}
end
end
end
end
spec/frontend/__helpers__/flush_promises.js
0 → 100644
View file @
75f1f22a
export
default
function
flushPromises
()
{
return
new
Promise
(
setImmediate
);
}
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