@@ -56,6 +56,10 @@ const createPricingPayload = premiumOverrides => ({
5656 }
5757} )
5858
59+ const chooseBitcoinPayment = async page => {
60+ await page . locator ( '.q-radio' ) . filter ( { hasText : 'Bitcoin' } ) . click ( )
61+ }
62+
5963test ( 'renders pricing plans from the dev pricing API' , async ( { page} ) => {
6064 await page . addInitScript ( ( ) => {
6165 window . localStorage . setItem ( 'apiEnv' , 'dev' )
@@ -225,14 +229,85 @@ test('shows every instance type returned by the API in the create instance fundi
225229 expect ( optionLabels ) . toEqual ( expectedLabels )
226230 await page . keyboard . press ( 'Escape' )
227231
228- await page . getByRole ( 'button' , { name : / P a y w i t h U S D | P a y m e n t / } ) . click ( )
232+ await chooseBitcoinPayment ( page )
233+ await page . getByRole ( 'button' , { name : / P a y w i t h b i t c o i n / } ) . click ( )
229234 await expect . poll ( ( ) => createInstanceRequestBody ) . toMatchObject ( {
230235 instance_type : 'lnbits-spark' ,
231236 payment_plan_tier : 'premium' ,
232237 payment_plan_interval : 'monthly'
233238 } )
234239} )
235240
241+ test ( 'warns instead of checking out when fiat payment is selected' , async ( { page} ) => {
242+ let createInstanceRequestBody = null
243+
244+ await page . addInitScript ( ( ) => {
245+ window . localStorage . setItem ( 'apiEnv' , 'dev' )
246+ window . localStorage . setItem ( 'email' , 'pricing-test@example.com' )
247+ } )
248+
249+ await page . route ( 'https://api.dev.lnbits.com/pricing' , route =>
250+ route . fulfill ( {
251+ status : 200 ,
252+ contentType : 'application/json' ,
253+ body : JSON . stringify ( pricingPayload )
254+ } )
255+ )
256+ await page . route ( 'https://api.dev.lnbits.com/instance' , route =>
257+ route . request ( ) . method ( ) === 'POST'
258+ ? ( ( ) => {
259+ createInstanceRequestBody = route . request ( ) . postDataJSON ( )
260+ return route . fulfill ( {
261+ status : 200 ,
262+ contentType : 'application/json' ,
263+ body : JSON . stringify ( {
264+ id : 'instance-1' ,
265+ domain : 'instance-1.example.com' ,
266+ is_enabled : true ,
267+ is_active : true ,
268+ timestamp : 1700000000 ,
269+ timestamp_start : 1700000000 ,
270+ timestamp_stop : 1700086400 ,
271+ installtoken : 'install-token' ,
272+ lnurl : ''
273+ } )
274+ } )
275+ } ) ( )
276+ : route . fulfill ( {
277+ status : 200 ,
278+ contentType : 'application/json' ,
279+ body : JSON . stringify ( [ ] )
280+ } )
281+ )
282+ await page . route ( 'https://api.dev.lnbits.com/' , route =>
283+ route . fulfill ( {
284+ status : 200 ,
285+ contentType : 'application/json' ,
286+ body : JSON . stringify ( { timestamp : Math . floor ( Date . now ( ) / 1000 ) } )
287+ } )
288+ )
289+ await page . route ( 'https://api.dev.lnbits.com/instance/types' , route =>
290+ route . fulfill ( {
291+ status : 200 ,
292+ contentType : 'application/json' ,
293+ body : JSON . stringify ( instanceTypesPayload )
294+ } )
295+ )
296+
297+ await page . goto ( '/instances?tier=premium&billing=monthly&funding=spark_l2' )
298+ await page
299+ . locator ( '#lnbits-chat-embed-iframe' )
300+ . evaluateAll ( nodes => nodes . forEach ( node => node . remove ( ) ) )
301+
302+ await page . getByRole ( 'button' , { name : / P a y w i t h U S D | P a y m e n t / } ) . click ( )
303+
304+ await expect (
305+ page . getByText ( 'Fiat payments are temporarily unavailable.' )
306+ ) . toBeVisible ( )
307+ await page . waitForTimeout ( 100 )
308+ expect ( createInstanceRequestBody ) . toBeNull ( )
309+ } )
310+
236311test ( 'prompts for a custom subdomain when the selected payment plan allows it' , async ( { page} ) => {
237312 let createInstanceRequestBody = null
238313
@@ -315,7 +390,8 @@ test('prompts for a custom subdomain when the selected payment plan allows it',
315390 await expect ( domainInput ) . toHaveAttribute ( 'aria-label' , 'Subdomain' )
316391 await expect ( page . locator ( '.q-field__suffix' ) ) . toContainText ( '.lnbits.com' )
317392 await domainInput . fill ( 'my-team' )
318- await page . getByRole ( 'button' , { name : / P a y w i t h U S D | P a y m e n t / } ) . click ( )
393+ await chooseBitcoinPayment ( page )
394+ await page . getByRole ( 'button' , { name : / P a y w i t h b i t c o i n / } ) . click ( )
319395
320396 await expect . poll ( ( ) => createInstanceRequestBody ) . toMatchObject ( {
321397 instance_type : 'lnbits-spark' ,
@@ -406,7 +482,8 @@ test('prompts for a custom domain when the selected payment plan allows it', asy
406482 await expect ( domainInput ) . toBeVisible ( )
407483 await expect ( domainInput ) . toHaveAttribute ( 'aria-label' , 'Domain or subdomain' )
408484 await domainInput . fill ( 'pay.example.com' )
409- await page . getByRole ( 'button' , { name : / P a y w i t h U S D | P a y m e n t / } ) . click ( )
485+ await chooseBitcoinPayment ( page )
486+ await page . getByRole ( 'button' , { name : / P a y w i t h b i t c o i n / } ) . click ( )
410487
411488 await expect . poll ( ( ) => createInstanceRequestBody ) . toMatchObject ( {
412489 instance_type : 'lnbits-spark' ,
0 commit comments