diff --git a/e2e/coupon-fraud.spec.ts b/e2e/coupon-fraud.spec.ts index b2a2446d..923ba4a3 100644 --- a/e2e/coupon-fraud.spec.ts +++ b/e2e/coupon-fraud.spec.ts @@ -1,4 +1,4 @@ -import { Page, test } from '@playwright/test'; +import { Page, test, expect } from '@playwright/test'; import { resetScenarios } from './resetHelper'; import { TEST_IDS } from '../src/client/testIDs'; import { COUPON_FRAUD_COPY } from '../src/pages/api/coupon-fraud/claim'; @@ -21,12 +21,14 @@ test.describe('Coupon fraud', () => { await insertCoupon(page, 'Does not exist'); await submitCoupon(page); await page.getByText(COUPON_FRAUD_COPY.doesNotExist).waitFor(); + await expect(page.getByTestId(TEST_IDS.common.cart.discount)).toBeAttached({ attached: false }); }); test('should apply correct coupon only once', async ({ page }) => { await insertCoupon(page, 'Promo3000'); await submitCoupon(page); await page.getByText(COUPON_FRAUD_COPY.success).waitFor(); + await page.getByTestId(TEST_IDS.common.cart.discount); await submitCoupon(page); await page.getByText(COUPON_FRAUD_COPY.usedBefore).waitFor(); @@ -35,6 +37,7 @@ test.describe('Coupon fraud', () => { test('should prevent spamming multiple coupons', async ({ page }) => { await insertCoupon(page, 'Promo3000'); await submitCoupon(page); + await page.getByTestId(TEST_IDS.common.cart.discount); await page.getByText(COUPON_FRAUD_COPY.success).waitFor(); await insertCoupon(page, 'BlackFriday'); diff --git a/src/client/components/common/Cart/Cart.tsx b/src/client/components/common/Cart/Cart.tsx index 4de53fa4..65f1f933 100644 --- a/src/client/components/common/Cart/Cart.tsx +++ b/src/client/components/common/Cart/Cart.tsx @@ -81,7 +81,7 @@ export const Cart: FunctionComponent = ({ items, discount, taxPerItem {format$(taxesApplied)} {discount > 0 && ( -
+
Coupon Discount {discount}% -{format$(discountApplied)}
diff --git a/src/client/testIDs.ts b/src/client/testIDs.ts index 2c786b64..f961f3b6 100644 --- a/src/client/testIDs.ts +++ b/src/client/testIDs.ts @@ -8,6 +8,7 @@ export const TEST_IDS = { cartItemCount: 'cartItemCount', cartItemPrice: 'cartItemPrice', cartSubTotal: 'cartSubTotal', + discount: 'discount', }, alert: 'alert', },