Skip to content

Commit c21d34d

Browse files
committed
fff
1 parent 0eb63a5 commit c21d34d

4 files changed

Lines changed: 19 additions & 45 deletions

File tree

.github/workflows/e2e.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,9 @@ jobs:
113113

114114
steps:
115115
- name: 📢 Send Slack notification
116+
if: env.SLACK_WEBHOOK_URL != ''
116117
uses: slackapi/slack-github-action@v1
117118
with:
118-
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
119-
webhook-type: incoming-webhook
120119
payload: |
121120
{
122121
"text": "❌ E2E Tests Failed",

src/lib/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class BaseError extends Error {
4949
error: {
5050
code: this.code,
5151
message: this.message,
52-
...(this.details && { details: this.details }),
52+
...(this.details ? { details: this.details } : {}),
5353
},
5454
};
5555
}

src/services/pricing-service.ts

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,13 @@ export async function calculateCheckoutPricing(
8989
id: { in: productIds },
9090
storeId,
9191
deletedAt: null,
92-
status: 'active',
9392
},
9493
select: {
9594
id: true,
9695
name: true,
9796
price: true,
98-
currency: true,
9997
sku: true,
10098
inventoryQty: true,
101-
variants: {
102-
where: { deletedAt: null },
103-
select: {
104-
id: true,
105-
price: true,
106-
sku: true,
107-
inventoryQty: true,
108-
},
109-
},
11099
},
111100
});
112101

@@ -120,32 +109,23 @@ export async function calculateCheckoutPricing(
120109
// Calculate line items
121110
const lineItems: LineItemCalculation[] = [];
122111
let subtotal = 0;
123-
const currency = products[0]?.currency || 'USD';
112+
// Currency is stored at store level, not product level
113+
const currency = 'USD'; // TODO: Get from store settings
124114

125115
for (const item of items) {
126116
const product = products.find(p => p.id === item.productId);
127117
if (!product) {
128118
throw new NotFoundError('Product', item.productId);
129119
}
130120

131-
// Check currency consistency
132-
if (product.currency !== currency) {
133-
throw new ValidationError('All products must use the same currency');
134-
}
135-
136121
let unitPrice = product.price;
137122
let sku = product.sku;
138123
let inventoryQty = product.inventoryQty;
139124

140125
// Handle variant pricing if variant selected
141126
if (item.variantId) {
142-
const variant = product.variants.find(v => v.id === item.variantId);
143-
if (!variant) {
144-
throw new NotFoundError('Product variant', item.variantId);
145-
}
146-
unitPrice = variant.price;
147-
sku = variant.sku;
148-
inventoryQty = variant.inventoryQty;
127+
// TODO: Add variant support - query ProductVariant table separately
128+
throw new ValidationError('Product variants not yet supported');
149129
}
150130

151131
// Validate inventory
@@ -208,9 +188,9 @@ export async function calculateCheckoutPricing(
208188
* @returns Total discount amount
209189
*/
210190
async function calculateDiscounts(
211-
storeId: string,
212-
subtotal: number,
213-
lineItems: LineItemCalculation[],
191+
_storeId: string,
192+
_subtotal: number,
193+
_lineItems: LineItemCalculation[],
214194
discountCode?: string
215195
): Promise<number> {
216196
if (!discountCode) {
@@ -231,9 +211,9 @@ async function calculateDiscounts(
231211
* @returns Tax amount
232212
*/
233213
async function calculateTax(
234-
storeId: string,
235-
subtotalAfterDiscount: number,
236-
shippingTotal: number
214+
_storeId: string,
215+
_subtotalAfterDiscount: number,
216+
_shippingTotal: number
237217
): Promise<number> {
238218
// TODO: Implement tax calculation based on store settings and shipping address
239219
// For now, return 0 (will be implemented with tax service)
@@ -265,13 +245,6 @@ export async function validateInventoryAvailability(
265245
id: true,
266246
name: true,
267247
inventoryQty: true,
268-
variants: {
269-
where: { deletedAt: null },
270-
select: {
271-
id: true,
272-
inventoryQty: true,
273-
},
274-
},
275248
},
276249
});
277250

@@ -284,11 +257,8 @@ export async function validateInventoryAvailability(
284257
let availableQty = product.inventoryQty;
285258

286259
if (item.variantId) {
287-
const variant = product.variants.find(v => v.id === item.variantId);
288-
if (!variant) {
289-
throw new NotFoundError('Product variant', item.variantId);
290-
}
291-
availableQty = variant.inventoryQty;
260+
// TODO: Add variant support - query ProductVariant table separately
261+
throw new ValidationError('Product variants not yet supported');
292262
}
293263

294264
if (availableQty < item.quantity) {

tests/integration/checkout-atomic.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ describe('Atomic Checkout Transactions', () => {
3131
name: 'Test Store - Atomic Checkout',
3232
slug: 'test-atomic-checkout',
3333
description: 'Test store for atomic checkout tests',
34+
email: 'atomic-test@stormcom.test',
3435
},
3536
});
3637
testStoreId = store.id;
@@ -46,6 +47,8 @@ describe('Atomic Checkout Transactions', () => {
4647
inventoryQty: initialStock,
4748
trackInventory: true,
4849
isPublished: true,
50+
images: '[]',
51+
metaKeywords: '[]',
4952
},
5053
});
5154
testProductId = product.id;
@@ -130,6 +133,8 @@ describe('Atomic Checkout Transactions', () => {
130133
inventoryQty: 50,
131134
trackInventory: true,
132135
isPublished: true,
136+
images: '[]',
137+
metaKeywords: '[]',
133138
},
134139
});
135140

0 commit comments

Comments
 (0)