@@ -29,7 +29,8 @@ describe('Payment Validator Provider Outage Resilience (T041)', () => {
2929 const store = await db . store . create ( {
3030 data : {
3131 name : 'Integration Test Store' ,
32- domain : 'integration-test.example.com' ,
32+ slug : 'integration-test' ,
33+ email : 'integration-test@example.com' ,
3334 currency : 'USD' ,
3435 timezone : 'America/New_York' ,
3536 } ,
@@ -42,7 +43,7 @@ describe('Payment Validator Provider Outage Resilience (T041)', () => {
4243 email : 'integration@example.com' ,
4344 name : 'Integration Test User' ,
4445 password : 'hashed' ,
45- role : 'Customer ' ,
46+ role : 'CUSTOMER ' ,
4647 } ,
4748 } ) ;
4849 userId = user . id ;
@@ -91,26 +92,59 @@ describe('Payment Validator Provider Outage Resilience (T041)', () => {
9192 expect ( result1 . isValid ) . toBe ( true ) ;
9293
9394 // Simulate creating order with this payment intent
95+ // Create addresses first
96+ const shippingAddr = await db . address . create ( {
97+ data : {
98+ firstName : 'Test' ,
99+ lastName : 'User' ,
100+ address1 : '123 Test St' ,
101+ city : 'Test City' ,
102+ state : 'TS' ,
103+ postalCode : '12345' ,
104+ country : 'US' ,
105+ phone : '555-0100' ,
106+ } ,
107+ } ) ;
108+
109+ const billingAddr = await db . address . create ( {
110+ data : {
111+ firstName : 'Test' ,
112+ lastName : 'User' ,
113+ address1 : '123 Test St' ,
114+ city : 'Test City' ,
115+ state : 'TS' ,
116+ postalCode : '12345' ,
117+ country : 'US' ,
118+ phone : '555-0100' ,
119+ } ,
120+ } ) ;
121+
94122 const order = await db . order . create ( {
95123 data : {
96124 storeId,
97125 userId,
98126 orderNumber : 'ORD-OUTAGE-TEST' ,
99127 status : 'PENDING' ,
100- total : 5000 ,
101- shippingAddress : JSON . stringify ( { street : '123 Test St' } ) ,
102- billingAddress : JSON . stringify ( { street : '123 Test St' } ) ,
128+ subtotal : 5000 ,
129+ taxAmount : 0 ,
130+ shippingAmount : 0 ,
131+ discountAmount : 0 ,
132+ totalAmount : 5000 ,
133+ shippingAddress : { connect : { id : shippingAddr . id } } ,
134+ billingAddress : { connect : { id : billingAddr . id } } ,
103135 } ,
104136 } ) ;
105137
106138 await db . payment . create ( {
107139 data : {
140+ storeId,
108141 orderId : order . id ,
109142 amount : 5000 ,
110143 currency : 'USD' ,
111144 status : 'PENDING' ,
145+ method : 'CREDIT_CARD' ,
112146 gatewayPaymentId : paymentIntentId ,
113- gateway : 'stripe ' ,
147+ gateway : 'STRIPE ' ,
114148 } ,
115149 } ) ;
116150
@@ -141,15 +175,45 @@ describe('Payment Validator Provider Outage Resilience (T041)', () => {
141175 ) ;
142176
143177 // Simulate database changes (other users creating orders)
178+ const otherShippingAddr = await db . address . create ( {
179+ data : {
180+ firstName : 'Other' ,
181+ lastName : 'User' ,
182+ address1 : '789 Other St' ,
183+ city : 'Other City' ,
184+ state : 'OT' ,
185+ postalCode : '67890' ,
186+ country : 'US' ,
187+ phone : '555-0200' ,
188+ } ,
189+ } ) ;
190+
191+ const otherBillingAddr = await db . address . create ( {
192+ data : {
193+ firstName : 'Other' ,
194+ lastName : 'User' ,
195+ address1 : '789 Other St' ,
196+ city : 'Other City' ,
197+ state : 'OT' ,
198+ postalCode : '67890' ,
199+ country : 'US' ,
200+ phone : '555-0200' ,
201+ } ,
202+ } ) ;
203+
144204 await db . order . create ( {
145205 data : {
146206 storeId,
147207 userId,
148208 orderNumber : 'ORD-OTHER-USER' ,
149209 status : 'PENDING' ,
150- total : 15000 ,
151- shippingAddress : JSON . stringify ( { } ) ,
152- billingAddress : JSON . stringify ( { } ) ,
210+ subtotal : 15000 ,
211+ taxAmount : 0 ,
212+ shippingAmount : 0 ,
213+ discountAmount : 0 ,
214+ totalAmount : 15000 ,
215+ shippingAddress : { connect : { id : otherShippingAddr . id } } ,
216+ billingAddress : { connect : { id : otherBillingAddr . id } } ,
153217 } ,
154218 } ) ;
155219
@@ -173,7 +237,8 @@ describe('Payment Validator Provider Outage Resilience (T041)', () => {
173237 const store2 = await db . store . create ( {
174238 data : {
175239 name : 'Second Integration Store' ,
176- domain : 'store2-integration.example.com' ,
240+ slug : 'store2-integration' ,
241+ email : 'store2@example.com' ,
177242 currency : 'EUR' ,
178243 timezone : 'Europe/London' ,
179244 } ,
@@ -264,40 +329,60 @@ describe('Payment Validator Provider Outage Resilience (T041)', () => {
264329
265330 expect ( validation . isValid ) . toBe ( true ) ;
266331
267- // Step 2: Create order
332+ // Step 2: Create order with addresses
333+ const checkoutShippingAddr = await db . address . create ( {
334+ data : {
335+ firstName : 'Checkout' ,
336+ lastName : 'User' ,
337+ address1 : '456 Main St' ,
338+ city : 'Testville' ,
339+ state : 'TS' ,
340+ postalCode : '12345' ,
341+ country : 'US' ,
342+ phone : '555-0300' ,
343+ } ,
344+ } ) ;
345+
346+ const checkoutBillingAddr = await db . address . create ( {
347+ data : {
348+ firstName : 'Checkout' ,
349+ lastName : 'User' ,
350+ address1 : '456 Main St' ,
351+ city : 'Testville' ,
352+ state : 'TS' ,
353+ postalCode : '12345' ,
354+ country : 'US' ,
355+ phone : '555-0300' ,
356+ } ,
357+ } ) ;
358+
268359 const order = await db . order . create ( {
269360 data : {
270361 storeId,
271362 userId,
272363 orderNumber : 'ORD-FULL-FLOW' ,
273364 status : 'PENDING' ,
274- total : 12000 ,
275- shippingAddress : JSON . stringify ( {
276- street : '456 Main St' ,
277- city : 'Testville' ,
278- state : 'TS' ,
279- zip : '12345' ,
280- country : 'US' ,
281- } ) ,
282- billingAddress : JSON . stringify ( {
283- street : '456 Main St' ,
284- city : 'Testville' ,
285- state : 'TS' ,
286- zip : '12345' ,
287- country : 'US' ,
288- } ) ,
365+ subtotal : 12000 ,
366+ taxAmount : 0 ,
367+ shippingAmount : 0 ,
368+ discountAmount : 0 ,
369+ totalAmount : 12000 ,
370+ shippingAddress : { connect : { id : checkoutShippingAddr . id } } ,
371+ billingAddress : { connect : { id : checkoutBillingAddr . id } } ,
289372 } ,
290373 } ) ;
291374
292375 // Step 3: Create payment
293376 const payment = await db . payment . create ( {
294377 data : {
378+ storeId,
295379 orderId : order . id ,
296380 amount : 12000 ,
297381 currency : 'USD' ,
298382 status : 'PENDING' ,
383+ method : 'CREDIT_CARD' ,
299384 gatewayPaymentId : paymentIntentId ,
300- gateway : 'stripe ' ,
385+ gateway : 'STRIPE ' ,
301386 } ,
302387 } ) ;
303388
0 commit comments