@@ -166,6 +166,25 @@ describe('getDefaultValuesUpgradeForm', () => {
166166 } )
167167 } )
168168
169+ it ( 'returns correct seats when free seats are present' , ( ) => {
170+ const data = getDefaultValuesUpgradeForm ( {
171+ accountDetails,
172+ selectedPlan : proPlanYear ,
173+ plans : [ teamPlanMonth ] ,
174+ plan : {
175+ billingRate : BillingRate . MONTHLY ,
176+ value : Plans . USERS_TEAMM ,
177+ planUserCount : 5 ,
178+ freeSeatCount : 2 ,
179+ isTeamPlan : true ,
180+ } as Plan ,
181+ } )
182+
183+ expect ( data ) . toStrictEqual ( {
184+ seats : 3 ,
185+ } )
186+ } )
187+
169188 it ( 'returns pro sentry plan if user is sentry upgrade' , ( ) => {
170189 const data = getDefaultValuesUpgradeForm ( {
171190 accountDetails,
@@ -214,6 +233,56 @@ describe('getDefaultValuesUpgradeForm', () => {
214233 seats : 2 ,
215234 } )
216235 } )
236+
237+ describe ( 'quantity calculation edge cases' , ( ) => {
238+ it ( 'returns 0 when planUserCount is null' , ( ) => {
239+ const data = getDefaultValuesUpgradeForm ( {
240+ accountDetails,
241+ selectedPlan : proPlanYear ,
242+ plans : [ proPlanYear ] ,
243+ plan : {
244+ billingRate : BillingRate . MONTHLY ,
245+ value : Plans . USERS_PR_INAPPM ,
246+ planUserCount : null ,
247+ } as unknown as Plan ,
248+ } )
249+
250+ expect ( data ) . toStrictEqual ( {
251+ newPlan : {
252+ value : Plans . USERS_PR_INAPPM ,
253+ billingRate : BillingRate . MONTHLY ,
254+ planUserCount : undefined ,
255+ } ,
256+ // extractSeats() will be passed quantity: 0, but returns min plan seats
257+ seats : 2 ,
258+ } )
259+ } )
260+
261+ it ( 'handles case where freeSeatCount equals planUserCount' , ( ) => {
262+ const data = getDefaultValuesUpgradeForm ( {
263+ accountDetails,
264+ selectedPlan : proPlanYear ,
265+ plans : [ proPlanYear ] ,
266+ plan : {
267+ billingRate : BillingRate . MONTHLY ,
268+ value : Plans . USERS_PR_INAPPM ,
269+ planUserCount : 3 ,
270+ freeSeatCount : 3 ,
271+ } as Plan ,
272+ } )
273+
274+ expect ( data ) . toStrictEqual ( {
275+ newPlan : {
276+ value : Plans . USERS_PR_INAPPM ,
277+ billingRate : BillingRate . MONTHLY ,
278+ planUserCount : 3 ,
279+ freeSeatCount : 3 ,
280+ } ,
281+ // extractSeats() will be passed quantity: 0, but returns min plan seats
282+ seats : 2 ,
283+ } )
284+ } )
285+ } )
217286} )
218287
219288describe ( 'getSchema' , ( ) => {
0 commit comments