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
e9922349
Commit
e9922349
authored
Jul 07, 2021
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix frontend tests
parent
5a0b1180
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
222 deletions
+43
-222
ee/spec/frontend/subscriptions/buy_minutes/components/checkout/addon_purchase_details_spec.js
...inutes/components/checkout/addon_purchase_details_spec.js
+1
-7
ee/spec/frontend/subscriptions/buy_minutes/components/checkout/order_summary_spec.js
...ons/buy_minutes/components/checkout/order_summary_spec.js
+30
-136
ee/spec/frontend/subscriptions/buy_minutes/mock_data.js
ee/spec/frontend/subscriptions/buy_minutes/mock_data.js
+7
-2
ee/spec/frontend/subscriptions/buy_minutes/utils_spec.js
ee/spec/frontend/subscriptions/buy_minutes/utils_spec.js
+5
-77
No files found.
ee/spec/frontend/subscriptions/buy_minutes/components/checkout/addon_purchase_details_spec.js
View file @
e9922349
...
@@ -8,10 +8,7 @@ import subscriptionsResolvers from 'ee/subscriptions/buy_minutes/graphql/resolve
...
@@ -8,10 +8,7 @@ import subscriptionsResolvers from 'ee/subscriptions/buy_minutes/graphql/resolve
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
purchaseFlowResolvers
from
'
ee/vue_shared/purchase_flow/graphql/resolvers
'
;
import
purchaseFlowResolvers
from
'
ee/vue_shared/purchase_flow/graphql/resolvers
'
;
import
{
import
{
stateData
as
initialStateData
}
from
'
ee_jest/subscriptions/buy_minutes/mock_data
'
;
stateData
as
initialStateData
,
mockCiMinutesPlans
,
}
from
'
ee_jest/subscriptions/buy_minutes/mock_data
'
;
import
createMockApollo
from
'
helpers/mock_apollo_helper
'
;
import
createMockApollo
from
'
helpers/mock_apollo_helper
'
;
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
...
@@ -40,9 +37,6 @@ describe('AddonPurchaseDetails', () => {
...
@@ -40,9 +37,6 @@ describe('AddonPurchaseDetails', () => {
return
mount
(
AddonPurchaseDetails
,
{
return
mount
(
AddonPurchaseDetails
,
{
localVue
,
localVue
,
apolloProvider
,
apolloProvider
,
propsData
:
{
plans
:
mockCiMinutesPlans
,
},
stubs
:
{
stubs
:
{
Step
,
Step
,
},
},
...
...
ee/spec/frontend/subscriptions/buy_minutes/components/checkout/order_summary_spec.js
View file @
e9922349
...
@@ -7,6 +7,7 @@ import stateQuery from 'ee/subscriptions/graphql/queries/state.query.graphql';
...
@@ -7,6 +7,7 @@ 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
{
mockCiMinutesPlans
,
mockCiMinutesPlans
,
mockParsedNamespaces
,
stateData
as
mockStateData
,
stateData
as
mockStateData
,
}
from
'
ee_jest/subscriptions/buy_minutes/mock_data
'
;
}
from
'
ee_jest/subscriptions/buy_minutes/mock_data
'
;
import
createMockApollo
from
'
helpers/mock_apollo_helper
'
;
import
createMockApollo
from
'
helpers/mock_apollo_helper
'
;
...
@@ -17,7 +18,11 @@ localVue.use(VueApollo);
...
@@ -17,7 +18,11 @@ localVue.use(VueApollo);
describe
(
'
Order Summary
'
,
()
=>
{
describe
(
'
Order Summary
'
,
()
=>
{
const
resolvers
=
{
...
purchaseFlowResolvers
,
...
subscriptionsResolvers
};
const
resolvers
=
{
...
purchaseFlowResolvers
,
...
subscriptionsResolvers
};
const
initialStateData
=
{
const
initialStateData
=
{
selectedPlanId
:
'
secondPlanId
'
,
selectedPlanId
:
'
ciMinutesPackPlanId
'
,
namespaces
:
[
mockParsedNamespaces
[
0
]],
subscription
:
{
namespaceId
:
mockParsedNamespaces
[
0
].
id
,
},
};
};
let
wrapper
;
let
wrapper
;
...
@@ -41,7 +46,7 @@ describe('Order Summary', () => {
...
@@ -41,7 +46,7 @@ describe('Order Summary', () => {
localVue
,
localVue
,
apolloProvider
,
apolloProvider
,
propsData
:
{
propsData
:
{
plan
s
:
mockCiMinutesPlans
,
plan
:
mockCiMinutesPlans
[
0
]
,
},
},
});
});
};
};
...
@@ -50,161 +55,50 @@ describe('Order Summary', () => {
...
@@ -50,161 +55,50 @@ describe('Order Summary', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
describe
(
'
Changing the company name
'
,
()
=>
{
describe
(
'
When purchasing for a single user
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
isSetupForCompany
:
false
});
});
it
(
'
should display the title with the passed name
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
h4
'
).
text
()).
toContain
(
"
Full Name's GitLab subscription
"
);
});
});
describe
(
'
When purchasing for a company or group
'
,
()
=>
{
describe
(
'
Without a group name provided
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
isSetupForCompany
:
true
});
});
it
(
'
should display the title with the default name
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
h4
'
).
text
()).
toContain
(
"
Your organization's GitLab subscription
"
);
});
});
describe
(
'
With a group name provided
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
isSetupForCompany
:
true
,
customer
:
{
company
:
'
My group
'
},
});
});
it
(
'
when given a group name, it should display the title with the group name
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
h4
'
).
text
()).
toContain
(
"
My group's GitLab subscription
"
);
});
});
});
});
describe
(
'
Changing the plan
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
();
});
describe
(
'
the selected plan
'
,
()
=>
{
it
(
'
should display the chosen plan
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-selected-plan
'
).
text
()).
toContain
(
'
silver plan
'
);
});
it
(
'
should display the correct formatted amount price per user
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-per-user
'
).
text
()).
toContain
(
'
$228 per user per year
'
);
});
});
describe
(
'
the default plan
'
,
()
=>
{
describe
(
'
the default plan
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createComponent
({
createComponent
({
subscription
:
{
quantity
:
1
},
subscription
:
{
quantity
:
1
},
selectedPlanId
:
'
firstPlanId
'
,
selectedPlanId
:
'
ciMinutesPackPlanId
'
,
});
});
it
(
'
should display the chosen plan
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-selected-plan
'
).
text
()).
toContain
(
'
bronze plan
'
);
});
it
(
'
should display the correct formatted amount price per user
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-per-user
'
).
text
()).
toContain
(
'
$48 per user per year
'
);
});
it
(
'
should display the correct formatted total amount
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-total-amount
'
).
text
()).
toContain
(
'
$48
'
);
});
});
});
describe
(
'
Changing the number of users
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
subscription
:
{
quantity
:
1
},
});
});
});
});
describe
(
'
the default of 1 selected user
'
,
()
=>
{
it
(
'
displays the chosen plan
'
,
()
=>
{
it
(
'
should display the correct number of users
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-selected-plan
'
).
text
()).
toMatchInterpolatedText
(
expect
(
wrapper
.
find
(
'
.js-number-of-users
'
).
text
()).
toContain
(
'
(x1)
'
);
'
1000 CI minutes pack plan (x1)
'
,
);
});
});
it
(
'
should display the correct formatted amount price per user
'
,
()
=>
{
it
(
'
displays the correct formatted amount price per pack
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-per-user
'
).
text
()).
toContain
(
'
$228 per user
per year
'
);
expect
(
wrapper
.
find
(
'
.js-per-unit
'
).
text
()).
toContain
(
'
$10 per pack
per year
'
);
});
});
it
(
'
should display the correct multiplied formatted amount of the chosen plan
'
,
()
=>
{
it
(
'
displays the correct formatted total amount
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-amount
'
).
text
()).
toContain
(
'
$228
'
);
expect
(
wrapper
.
find
(
'
.js-total-amount
'
).
text
()).
toContain
(
'
$10
'
);
});
it
(
'
should display the correct formatted total amount
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-total-amount
'
).
text
()).
toContain
(
'
$228
'
);
});
});
});
});
describe
(
'
3 selected users
'
,
()
=>
{
describe
(
'
changing quantity
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createComponent
({
createComponent
({
subscription
:
{
quantity
:
3
},
subscription
:
{
quantity
:
3
},
});
});
});
});
it
(
'
should display the correct number of users
'
,
()
=>
{
it
(
'
displays the correct quantity
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-number-of-users
'
).
text
()).
toContain
(
'
(x3)
'
);
expect
(
wrapper
.
find
(
'
.js-quantity
'
).
text
()).
toContain
(
'
(x3)
'
);
});
});
it
(
'
should display the correct formatted amount price per user
'
,
()
=>
{
it
(
'
displays the correct formatted amount price per unit
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-per-user
'
).
text
()).
toContain
(
'
$228 per user
per year
'
);
expect
(
wrapper
.
find
(
'
.js-per-unit
'
).
text
()).
toContain
(
'
$10 per pack
per year
'
);
});
});
it
(
'
should display
the correct multiplied formatted amount of the chosen plan
'
,
()
=>
{
it
(
'
displays
the correct multiplied formatted amount of the chosen plan
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-amount
'
).
text
()).
toContain
(
'
$684
'
);
expect
(
wrapper
.
find
(
'
.js-amount
'
).
text
()).
toContain
(
'
$30
'
);
});
});
it
(
'
should display the correct formatted total amount
'
,
()
=>
{
it
(
'
displays the correct formatted total amount
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-total-amount
'
).
text
()).
toContain
(
'
$684
'
);
expect
(
wrapper
.
find
(
'
.js-total-amount
'
).
text
()).
toContain
(
'
$30
'
);
});
});
describe
(
'
no selected users
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
subscription
:
{
quantity
:
0
},
});
});
it
(
'
should not display the number of users
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-number-of-users
'
).
exists
()).
toBe
(
false
);
});
it
(
'
should display the correct formatted amount price per user
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-per-user
'
).
text
()).
toContain
(
'
$228 per user per year
'
);
});
it
(
'
should not display the amount
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-amount
'
).
text
()).
toContain
(
'
-
'
);
});
it
(
'
should display the correct formatted total amount
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-total-amount
'
).
text
()).
toContain
(
'
-
'
);
});
});
describe
(
'
date range
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
();
});
it
(
'
shows the formatted date range from the start date to one year in the future
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-dates
'
).
text
()).
toContain
(
'
Jul 6, 2020 - Jul 6, 2021
'
);
});
});
});
describe
(
'
tax rate
'
,
()
=>
{
describe
(
'
tax rate
'
,
()
=>
{
...
...
ee/spec/frontend/subscriptions/buy_minutes/mock_data.js
View file @
e9922349
import
{
STEPS
}
from
'
ee/subscriptions/constants
'
;
import
{
STEPS
}
from
'
ee/subscriptions/constants
'
;
export
const
mockCiMinutesPlans
=
[
export
const
mockCiMinutesPlans
=
[
{
id
:
'
firstPlanId
'
,
code
:
'
bronze
'
,
pricePerYear
:
48
,
name
:
'
bronze
'
,
__typename
:
'
Plan
'
},
{
{
id
:
'
secondPlanId
'
,
code
:
'
silver
'
,
pricePerYear
:
228
,
name
:
'
silver
'
,
__typename
:
'
Plan
'
},
id
:
'
ciMinutesPackPlanId
'
,
code
:
'
ci_minutes
'
,
pricePerYear
:
10
,
name
:
'
1000 CI minutes pack
'
,
__typename
:
'
Plan
'
,
},
];
];
export
const
mockNamespaces
=
export
const
mockNamespaces
=
'
[{"id":132,"name":"Gitlab Org","users":3},{"id":483,"name":"Gnuwget","users":12}]
'
;
'
[{"id":132,"name":"Gitlab Org","users":3},{"id":483,"name":"Gnuwget","users":12}]
'
;
...
...
ee/spec/frontend/subscriptions/buy_minutes/utils_spec.js
View file @
e9922349
import
apolloProvider
from
'
ee/subscriptions/buy_minutes/graphql
'
;
import
apolloProvider
from
'
ee/subscriptions/buy_minutes/graphql
'
;
import
{
writeInitialDataToApolloCache
}
from
'
ee/subscriptions/buy_minutes/utils
'
;
import
{
writeInitialDataToApolloCache
}
from
'
ee/subscriptions/buy_minutes/utils
'
;
import
stateQuery
from
'
ee/subscriptions/graphql/queries/state.query.graphql
'
;
import
stateQuery
from
'
ee/subscriptions/graphql/queries/state.query.graphql
'
;
import
{
import
{
mockNamespaces
,
mockParsedNamespaces
}
from
'
./mock_data
'
;
mockNamespaces
,
mockParsedNamespaces
,
mockNewUser
,
mockFullName
,
mockSetupForCompany
,
}
from
'
./mock_data
'
;
const
DEFAULT_DATA
=
{
const
DEFAULT_DATA
=
{
groupData
:
mockNamespaces
,
groupData
:
mockNamespaces
,
newUser
:
mockNewUser
,
namespaceId
:
mockParsedNamespaces
[
0
].
id
,
fullName
:
mockFullName
,
newUser
:
false
,
setupForCompany
:
mockSetupForCompany
,
fullName
:
null
,
setupForCompany
:
false
,
};
};
describe
(
'
utils
'
,
()
=>
{
describe
(
'
utils
'
,
()
=>
{
...
@@ -48,72 +43,5 @@ describe('utils', () => {
...
@@ -48,72 +43,5 @@ describe('utils', () => {
});
});
});
});
});
});
describe
(
'
newUser
'
,
()
=>
{
describe
.
each
`
newUser | parsedNewUser | throws
${
'
true
'
}
|
${
true
}
|
${
false
}
${
mockNewUser
}
|
${
false
}
|
${
false
}
${
''
}
|
${
false
}
|
${
true
}
`
(
'
parameter decoding
'
,
({
newUser
,
parsedNewUser
,
throws
})
=>
{
it
(
`decodes
${
newUser
}
to
${
parsedNewUser
}
`
,
async
()
=>
{
if
(
throws
)
{
expect
(()
=>
{
writeInitialDataToApolloCache
(
apolloProvider
,
{
newUser
});
}).
toThrow
();
}
else
{
writeInitialDataToApolloCache
(
apolloProvider
,
{
...
DEFAULT_DATA
,
newUser
});
const
sourceData
=
await
apolloProvider
.
clients
.
defaultClient
.
query
({
query
:
stateQuery
,
});
expect
(
sourceData
.
data
.
isNewUser
).
toEqual
(
parsedNewUser
);
}
});
});
});
describe
(
'
fullName
'
,
()
=>
{
describe
.
each
`
fullName | parsedFullName
${
mockFullName
}
|
${
mockFullName
}
${
''
}
|
${
''
}
${
null
}
|
${
null
}
`
(
'
parameter decoding
'
,
({
fullName
,
parsedFullName
})
=>
{
it
(
`decodes
${
fullName
}
to
${
parsedFullName
}
`
,
async
()
=>
{
writeInitialDataToApolloCache
(
apolloProvider
,
{
...
DEFAULT_DATA
,
fullName
});
const
sourceData
=
await
apolloProvider
.
clients
.
defaultClient
.
query
({
query
:
stateQuery
,
});
expect
(
sourceData
.
data
.
fullName
).
toEqual
(
parsedFullName
);
});
});
});
describe
(
'
setupForCompany
'
,
()
=>
{
describe
.
each
`
setupForCompany | parsedSetupForCompany | throws
${
mockSetupForCompany
}
|
${
true
}
|
${
false
}
${
'
false
'
}
|
${
false
}
|
${
false
}
${
''
}
|
${
false
}
|
${
true
}
`
(
'
parameter decoding
'
,
({
setupForCompany
,
parsedSetupForCompany
,
throws
})
=>
{
it
(
`decodes
${
setupForCompany
}
to
${
parsedSetupForCompany
}
`
,
async
()
=>
{
if
(
throws
)
{
expect
(()
=>
{
writeInitialDataToApolloCache
(
apolloProvider
,
{
setupForCompany
});
}).
toThrow
();
}
else
{
writeInitialDataToApolloCache
(
apolloProvider
,
{
...
DEFAULT_DATA
,
newUser
:
'
true
'
,
setupForCompany
,
});
const
sourceData
=
await
apolloProvider
.
clients
.
defaultClient
.
query
({
query
:
stateQuery
,
});
expect
(
sourceData
.
data
.
isSetupForCompany
).
toEqual
(
parsedSetupForCompany
);
}
});
});
});
});
});
});
});
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