Skip to content

Commit dcacc2a

Browse files
committed
up
1 parent 04496bf commit dcacc2a

4 files changed

Lines changed: 121 additions & 37 deletions

File tree

tests/integration/jobs/export-job-lifecycle.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ describe('Export Job Lifecycle (Integration)', () => {
304304

305305
// Manually trigger retry (bypass delay)
306306
const queueJob = jobQueue.getJob(
307-
jobQueue.getPendingJobs().find((j) => j.payload.jobId === jobId)?.id || ''
307+
jobQueue.getPendingJobs().find((j) => (j.payload as any).jobId === jobId)?.id || ''
308308
);
309309
if (queueJob) queueJob.scheduledFor = new Date();
310310

tests/integration/migrations/json-migration-t038.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ describe('T038b-T038f: JSON Migration Tests', () => {
2828
data: {
2929
name: 'JSON Migration Test Store',
3030
slug: 'json-migration-test',
31-
domain: 'json-migration-test.example.com',
3231
email: 'test@json-migration.com',
3332
currency: 'USD',
3433
timezone: 'UTC',
@@ -73,8 +72,8 @@ describe('T038b-T038f: JSON Migration Tests', () => {
7372

7473
expect(product.images).toBeInstanceOf(Array);
7574
expect(product.images).toHaveLength(2);
76-
expect(product.images[0]).toBe('https://example.com/image1.jpg');
77-
expect(product.images[1]).toBe('https://example.com/image2.jpg');
75+
expect((product.images as string[])[0]).toBe('https://example.com/image1.jpg');
76+
expect((product.images as string[])[1]).toBe('https://example.com/image2.jpg');
7877
});
7978

8079
it('should retrieve images as Json array', async () => {
@@ -114,8 +113,8 @@ describe('T038b-T038f: JSON Migration Tests', () => {
114113

115114
expect(product?.metaKeywords).toBeInstanceOf(Array);
116115
expect(product?.metaKeywords).toHaveLength(2);
117-
expect(product?.metaKeywords[0]).toBe('test');
118-
expect(product?.metaKeywords[1]).toBe('product');
116+
expect((product?.metaKeywords as string[])[0]).toBe('ecommerce');
117+
expect((product?.metaKeywords as string[])[1]).toBe('product');
119118
});
120119

121120
it('should update metaKeywords as Json array', async () => {
@@ -241,9 +240,9 @@ describe('T038b-T038f: JSON Migration Tests', () => {
241240

242241
testReviewId = review.id;
243242

244-
expect(review.images).toBeInstanceOf(Array);
245-
expect(review.images).toHaveLength(2);
246-
expect(review.images[0]).toBe('https://example.com/review1.jpg');
243+
expect(review?.images).toBeInstanceOf(Array);
244+
expect(review?.images).toHaveLength(1);
245+
expect((review?.images as string[])[0]).toBe('https://example.com/review1.jpg');
247246
});
248247

249248
it('should retrieve review images as Json array', async () => {

tests/integration/payments/payment-validator-robustness.test.ts

Lines changed: 112 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -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

tsconfig.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)