Skip to content

Commit 614b161

Browse files
committed
feat(e2e): add data-testids for discount related parts in checkout
1 parent 8613b59 commit 614b161

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

src/modules/checkout/components/discount-code/index.tsx

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,15 @@ const DiscountCode: React.FC<DiscountCodeProps> = ({ cart }) => {
6969
>
7070
<Text className="flex gap-x-1 items-baseline">
7171
<span>Code: </span>
72-
<span className="truncate" data-testid="gift-card-code">{gc.code}</span>
72+
<span className="truncate" data-testid="gift-card-code">
73+
{gc.code}
74+
</span>
7375
</Text>
74-
<Text className="font-semibold" data-testid="gift-card-amount">
76+
<Text
77+
className="font-semibold"
78+
data-testid="gift-card-amount"
79+
data-value={gc.balance}
80+
>
7581
{formatAmount({
7682
region: region,
7783
amount: gc.balance,
@@ -95,15 +101,27 @@ const DiscountCode: React.FC<DiscountCodeProps> = ({ cart }) => {
95101
<div className="w-full flex items-center">
96102
<div className="flex flex-col w-full">
97103
<Heading className="txt-medium">Discount applied:</Heading>
98-
<div className="flex items-center justify-between w-full max-w-full">
104+
<div
105+
className="flex items-center justify-between w-full max-w-full"
106+
data-testid="discount-row"
107+
>
99108
<Text className="flex gap-x-1 items-baseline txt-small-plus w-4/5 pr-1">
100109
<span>Code:</span>
101-
<span className="truncate">{discounts[0].code}</span>
102-
<span className="min-w-fit">({appliedDiscount})</span>
110+
<span className="truncate" data-testid="discount-code">
111+
{discounts[0].code}
112+
</span>
113+
<span
114+
className="min-w-fit"
115+
data-testid="discount-amount"
116+
data-value={discounts[0].rule.value}
117+
>
118+
({appliedDiscount})
119+
</span>
103120
</Text>
104121
<button
105122
className="flex items-center"
106123
onClick={removeDiscountCode}
124+
data-testid="remove-discount-button"
107125
>
108126
<Trash size={14} />
109127
<span className="sr-only">
@@ -138,9 +156,17 @@ const DiscountCode: React.FC<DiscountCodeProps> = ({ cart }) => {
138156
autoFocus={false}
139157
data-testid="discount-input"
140158
/>
141-
<SubmitButton variant="secondary" data-testid="discount-apply-button">Apply</SubmitButton>
159+
<SubmitButton
160+
variant="secondary"
161+
data-testid="discount-apply-button"
162+
>
163+
Apply
164+
</SubmitButton>
142165
</div>
143-
<ErrorMessage error={message} data-testid="discount-error-message" />
166+
<ErrorMessage
167+
error={message}
168+
data-testid="discount-error-message"
169+
/>
144170
</>
145171
)}
146172
</form>

src/modules/checkout/components/payment-button/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ const GiftCardPaymentButton = () => {
7272
}
7373

7474
return (
75-
<Button onClick={handleOrder} isLoading={submitting}>
75+
<Button
76+
onClick={handleOrder}
77+
isLoading={submitting}
78+
data-testid="submit-order-button"
79+
>
7680
Place order
7781
</Button>
7882
)

0 commit comments

Comments
 (0)