@@ -13,6 +13,9 @@ import config from 'config'
13
13
14
14
import { ThemeContextProvider } from 'shared/ThemeContext'
15
15
16
+ import { Location } from 'history'
17
+ import { UnverifiedPaymentMethodSchema } from 'services/account'
18
+ import { z } from 'zod'
16
19
import PlanPage from './PlanPage'
17
20
18
21
vi . mock ( 'config' )
@@ -40,9 +43,9 @@ const queryClientV5 = new QueryClientV5({
40
43
defaultOptions : { queries : { retry : false } } ,
41
44
} )
42
45
43
- let testLocation
46
+ let testLocation : Location < unknown >
44
47
const wrapper =
45
- ( initialEntries = '' ) =>
48
+ ( initialEntries = '' ) : React . FC < React . PropsWithChildren > =>
46
49
( { children } ) => (
47
50
< QueryClientProviderV5 client = { queryClientV5 } >
48
51
< QueryClientProvider client = { queryClient } >
@@ -79,7 +82,13 @@ afterAll(() => {
79
82
80
83
describe ( 'PlanPage' , ( ) => {
81
84
function setup (
82
- { owner, isSelfHosted = false } = {
85
+ {
86
+ owner,
87
+ isSelfHosted = false ,
88
+ unverifiedPaymentMethods = [ ] as z . infer <
89
+ typeof UnverifiedPaymentMethodSchema
90
+ > [ ] ,
91
+ } = {
83
92
owner : {
84
93
username : 'codecov' ,
85
94
isCurrentUserPartOfOrg : true ,
@@ -92,6 +101,17 @@ describe('PlanPage', () => {
92
101
server . use (
93
102
graphql . query ( 'PlanPageData' , ( ) => {
94
103
return HttpResponse . json ( { data : { owner } } )
104
+ } ) ,
105
+ graphql . query ( 'UnverifiedPaymentMethods' , ( ) => {
106
+ return HttpResponse . json ( {
107
+ data : {
108
+ owner : {
109
+ billing : {
110
+ unverifiedPaymentMethods,
111
+ } ,
112
+ } ,
113
+ } ,
114
+ } )
95
115
} )
96
116
)
97
117
}
@@ -102,7 +122,7 @@ describe('PlanPage', () => {
102
122
owner : {
103
123
username : 'codecov' ,
104
124
isCurrentUserPartOfOrg : false ,
105
- numberOfUploads : null ,
125
+ numberOfUploads : 0 ,
106
126
} ,
107
127
} )
108
128
} )
@@ -120,7 +140,7 @@ describe('PlanPage', () => {
120
140
owner : {
121
141
username : 'codecov' ,
122
142
isCurrentUserPartOfOrg : false ,
123
- numberOfUploads : null ,
143
+ numberOfUploads : 0 ,
124
144
} ,
125
145
} )
126
146
} )
@@ -149,6 +169,34 @@ describe('PlanPage', () => {
149
169
const tabs = await screen . findByText ( / T a b s / )
150
170
expect ( tabs ) . toBeInTheDocument ( )
151
171
} )
172
+
173
+ describe ( 'when there are unverified payment methods' , ( ) => {
174
+ beforeEach ( ( ) => {
175
+ setup ( {
176
+ owner : {
177
+ username : 'codecov' ,
178
+ isCurrentUserPartOfOrg : true ,
179
+ numberOfUploads : 30 ,
180
+ } ,
181
+ unverifiedPaymentMethods : [
182
+ {
183
+ paymentMethodId : 'pm_123' ,
184
+ hostedVerificationUrl : 'https://verify.stripe.com' ,
185
+ } ,
186
+ ] ,
187
+ } )
188
+ } )
189
+
190
+ it ( 'renders unverified payment method alert' , async ( ) => {
191
+ render ( < PlanPage /> , { wrapper : wrapper ( '/plan/gh/codecov' ) } )
192
+
193
+ const alert = await screen . findByText ( / V e r i f y Y o u r N e w P a y m e n t M e t h o d / )
194
+ expect ( alert ) . toBeInTheDocument ( )
195
+
196
+ const link = screen . getByText ( 'Click here' )
197
+ expect ( link ) . toHaveAttribute ( 'href' , 'https://verify.stripe.com' )
198
+ } )
199
+ } )
152
200
} )
153
201
154
202
describe ( 'testing routes' , ( ) => {
0 commit comments