@@ -4,7 +4,7 @@ import { prisma } from "@/db/prisma";
44import { hashPassword } from "@/lib/security" ;
55import type { CreateUserDTO } from "@/models/user.model" ;
66
7- import { baseUrl , cleanDatabase } from "./utils-tests-e2e" ;
7+ import { baseUrl , cleanDatabase , creditCards } from "./utils-tests-e2e" ;
88
99test . beforeEach ( async ( ) => {
1010 await cleanDatabase ( ) ;
@@ -19,9 +19,13 @@ test.describe("User", () => {
1919 isGuest : false ,
2020 } ;
2121
22- await prisma . user . create ( {
22+ console . log ( "Creating test user:" , testUser ) ;
23+
24+ const user = await prisma . user . create ( {
2325 data : testUser ,
2426 } ) ;
27+
28+ console . log ( "Test user created:" , user ) ;
2529 } ) ;
2630
2731 test ( "User can create an order" , async ( { page } ) => {
@@ -76,9 +80,43 @@ test.describe("User", () => {
7680
7781 await page . getByRole ( "button" , { name : "Confirmar Orden" } ) . click ( ) ;
7882
83+ const checkoutFrame = page . locator ( 'iframe[name="checkout_frame"]' ) ;
84+ await expect ( checkoutFrame ) . toBeVisible ( ) ;
85+
86+ const validCard = creditCards . valid ;
87+
88+ await checkoutFrame
89+ . contentFrame ( )
90+ . getByRole ( "textbox" , { name : "#### #### #### ####" } )
91+ . fill ( validCard . number ) ;
92+
7993 await expect (
80- page . getByText ( "¡Muchas gracias por tu compra!" )
94+ checkoutFrame . contentFrame ( ) . getByRole ( "img" , { name : "Culqi icon" } )
8195 ) . toBeVisible ( ) ;
96+
97+ await checkoutFrame
98+ . contentFrame ( )
99+ . getByRole ( "textbox" , { name : "MM/AA" } )
100+ . fill ( validCard . exp ) ;
101+
102+ await checkoutFrame
103+ . contentFrame ( )
104+ . getByRole ( "textbox" , { name : "CVV" } )
105+ . fill ( validCard . cvv ) ;
106+
107+ await checkoutFrame
108+ . contentFrame ( )
109+ . getByRole ( "textbox" , { name :
"[email protected] " } ) 110+ . fill ( loginForm [ "Correo electrónico" ] ) ;
111+
112+ await checkoutFrame
113+ . contentFrame ( )
114+ . getByRole ( "button" , { name : "Pagar S/" } )
115+ . click ( ) ;
116+
117+ await expect ( page . getByText ( "¡Muchas gracias por tu compra!" ) ) . toBeVisible ( {
118+ timeout : 10000 ,
119+ } ) ;
82120 await expect ( page . getByTestId ( "orderId" ) ) . toBeVisible ( ) ;
83121 } ) ;
84122} ) ;
0 commit comments