Skip to content

Commit c74affd

Browse files
committed
feat: add condition deliveryLeadTime and fix tests
1 parent 4de316d commit c74affd

10 files changed

Lines changed: 105 additions & 112 deletions

File tree

components/composite/StepPlaceOrder/styled.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export const ErrorsContainer = styled.div`
3636
${tw`mb-10`}
3737
}
3838
`
39-
export const StyledPlaceOrderButton = styled<any & StyledPlaceOrderButtonProps>(
39+
export const StyledPlaceOrderButton = styled(
4040
PlaceOrderButton
41-
)`
41+
)<StyledPlaceOrderButtonProps>`
4242
${ButtonCss}
4343
${({ isActive }) => (isActive ? null : tw`hidden`)}
4444
${tw`mx-5 mt-3.5 md:mx-0 md:mt-0`}

components/composite/StepShipping/index.tsx

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import {
3333
ShippingWrapper,
3434
ShippingTitle,
3535
ShippingSummary,
36-
ShippingSummaryItem,
3736
ShippingSummaryItemDescription,
3837
ShippingSummaryValue,
3938
ShippingLineItem,
@@ -184,38 +183,46 @@ export const StepShipping: React.FC<Props> = () => {
184183
) => handleChange(shippingMethod)}
185184
/>
186185
<ShippingMethodName data-cy="shipping-method-name">
187-
{(props) => (
188-
<label
189-
className="flex flex-col p-3 border rounded cursor-pointer hover:border-primary transition duration-200 ease-in"
190-
htmlFor={`shipment-${props.shippingMethod.shipmentId}-${props.shippingMethod.id}`}
191-
>
192-
<ShippingLineItemTitle>
193-
{props.label}
194-
</ShippingLineItemTitle>
195-
<ShippingSummaryItemDescription>
196-
<Trans
197-
t={t}
198-
i18nKey="stepShipping.deliveryLeadTime"
199-
>
200-
<DeliveryLeadTime
201-
type="minDays"
202-
data-cy="delivery-lead-time-min-days"
203-
/>
204-
<DeliveryLeadTime
205-
type="maxDays"
206-
data-cy="delivery-lead-time-max-days"
207-
className="mr-1"
186+
{(props) => {
187+
const deliveryLeadTime =
188+
props.shippingMethod.deliveryLeadTimeForShipment()
189+
190+
return (
191+
<label
192+
className="flex flex-col p-3 border rounded cursor-pointer hover:border-primary transition duration-200 ease-in"
193+
htmlFor={`shipment-${props.shippingMethod.shipmentId}-${props.shippingMethod.id}`}
194+
>
195+
<ShippingLineItemTitle>
196+
{props.label}
197+
</ShippingLineItemTitle>
198+
{deliveryLeadTime?.minDays &&
199+
deliveryLeadTime.maxDays && (
200+
<ShippingSummaryItemDescription>
201+
<Trans
202+
t={t}
203+
i18nKey="stepShipping.deliveryLeadTime"
204+
>
205+
<DeliveryLeadTime
206+
type="minDays"
207+
data-cy="delivery-lead-time-min-days"
208+
/>
209+
<DeliveryLeadTime
210+
type="maxDays"
211+
data-cy="delivery-lead-time-max-days"
212+
className="mr-1"
213+
/>
214+
</Trans>
215+
</ShippingSummaryItemDescription>
216+
)}
217+
<ShippingSummaryValue>
218+
<ShippingMethodPrice
219+
data-cy="shipping-method-price"
220+
labelFreeOver={t("general.free")}
208221
/>
209-
</Trans>
210-
</ShippingSummaryItemDescription>
211-
<ShippingSummaryValue>
212-
<ShippingMethodPrice
213-
data-cy="shipping-method-price"
214-
labelFreeOver={t("general.free")}
215-
/>
216-
</ShippingSummaryValue>
217-
</label>
218-
)}
222+
</ShippingSummaryValue>
223+
</label>
224+
)
225+
}}
219226
</ShippingMethodName>
220227
</ShippingSummary>
221228
</ShippingMethod>

cypress/integration/GTM.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ describe("check Data Layers GTM", () => {
111111
cy.dataCy("shipping-method-button").each((e, i) => {
112112
cy.wrap(e).as(`shippingMethodButton${i}`)
113113
})
114-
cy.get("@shippingMethodButton0").click()
115-
cy.get("@shippingMethodButton2").click()
114+
cy.get("@shippingMethodButton0").click({ force: true })
115+
cy.get("@shippingMethodButton2").click({ force: true })
116116
cy.wait(
117117
[
118118
"@getShipments",
@@ -162,7 +162,7 @@ describe("check Data Layers GTM", () => {
162162
cy.dataCy("shipping-method-button").each((e, i) => {
163163
cy.wrap(e).as(`shippingMethodButton${i}`)
164164
})
165-
cy.get("@shippingMethodButton1").click()
165+
cy.get("@shippingMethodButton1").click({ force: true })
166166
cy.wait(
167167
[
168168
"@getShipments",
@@ -179,7 +179,7 @@ describe("check Data Layers GTM", () => {
179179
timeout: 100000,
180180
}
181181
)
182-
cy.get("@shippingMethodButton3").click()
182+
cy.get("@shippingMethodButton3").click({ force: true })
183183
cy.wait(
184184
[
185185
"@getShipments",
@@ -231,8 +231,8 @@ describe("check Data Layers GTM", () => {
231231
cy.dataCy("shipping-method-button").each((e, i) => {
232232
cy.wrap(e).as(`shippingMethodButton${i}`)
233233
})
234-
cy.get("@shippingMethodButton1").click()
235-
cy.get("@shippingMethodButton2").click()
234+
cy.get("@shippingMethodButton1").click({ force: true })
235+
cy.get("@shippingMethodButton2").click({ force: true })
236236
cy.dataCy("save-shipments-button").click()
237237
cy.wait(
238238
[
@@ -280,7 +280,7 @@ describe("check Data Layers GTM", () => {
280280
cy.dataCy("shipping-method-button").each((e, i) => {
281281
cy.wrap(e).as(`shippingMethodButton${i}`)
282282
})
283-
cy.get("@shippingMethodButton0").click()
283+
cy.get("@shippingMethodButton0").click({ force: true })
284284
cy.wait(
285285
[
286286
"@getShipments",
@@ -291,7 +291,7 @@ describe("check Data Layers GTM", () => {
291291
],
292292
{ timeout: 100000 }
293293
)
294-
cy.get("@shippingMethodButton3").click()
294+
cy.get("@shippingMethodButton3").click({ force: true })
295295
cy.wait(
296296
[
297297
"@getShipments",
@@ -429,7 +429,7 @@ describe("check Data Layers GTM", () => {
429429
cy.dataCy("shipping-method-button").each((e, i) => {
430430
cy.wrap(e).as(`shippingMethodButton${i}`)
431431
})
432-
cy.get("@shippingMethodButton0").click()
432+
cy.get("@shippingMethodButton0").click({ force: true })
433433
cy.wait(
434434
[
435435
"@getShipments",

cypress/integration/checkout-complete.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ describe("Checkout Complete", () => {
100100
cy.dataCy("shipping-method-button").each((e, i) => {
101101
cy.wrap(e).as(`shippingMethodButton${i}`)
102102
})
103-
cy.get("@shippingMethodButton0").click()
103+
cy.get("@shippingMethodButton0").click({ force: true })
104104
cy.wait(
105105
[
106106
"@getShipments",

cypress/integration/checkout-free-payment.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe("Checkout Free Payment", () => {
145145
cy.dataCy("shipping-method-button").each((e, i) => {
146146
cy.wrap(e).as(`shippingMethodButton${i}`)
147147
})
148-
cy.get("@shippingMethodButton0").click()
148+
cy.get("@shippingMethodButton0").click({ force: true })
149149
cy.wait(
150150
[
151151
"@getShipments",
@@ -387,7 +387,7 @@ describe("Checkout Free Payment", () => {
387387
cy.dataCy("shipping-method-button").each((e, i) => {
388388
cy.wrap(e).as(`shippingMethodButton${i}`)
389389
})
390-
cy.get("@shippingMethodButton0").click()
390+
cy.get("@shippingMethodButton0").click({ force: true })
391391
cy.wait(
392392
[
393393
"@getShipments",

cypress/integration/coupon.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe("Checkout Coupon", () => {
118118
cy.dataCy("shipping-method-button").each((e, i) => {
119119
cy.wrap(e).as(`shippingMethodButton${i}`)
120120
})
121-
cy.get("@shippingMethodButton0").click()
121+
cy.get("@shippingMethodButton0").click({ force: true })
122122
cy.wait(
123123
[
124124
"@getShipments",
@@ -132,7 +132,7 @@ describe("Checkout Coupon", () => {
132132
timeout: 100000,
133133
}
134134
)
135-
cy.get("@shippingMethodButton3").click()
135+
cy.get("@shippingMethodButton3").click({ force: true })
136136
cy.wait(
137137
[
138138
"@getShipments",
@@ -253,7 +253,7 @@ describe("Checkout Coupon", () => {
253253
cy.dataCy("shipping-method-button").each((e, i) => {
254254
cy.wrap(e).as(`shippingMethodButton${i}`)
255255
})
256-
cy.get("@shippingMethodButton0").click()
256+
cy.get("@shippingMethodButton0").click({ force: true })
257257
cy.wait(
258258
[
259259
"@getShipments",
@@ -267,7 +267,7 @@ describe("Checkout Coupon", () => {
267267
timeout: 100000,
268268
}
269269
)
270-
cy.get("@shippingMethodButton3").click()
270+
cy.get("@shippingMethodButton3").click({ force: true })
271271
cy.wait(
272272
[
273273
"@getShipments",

cypress/integration/giftcard.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ describe("Checkout GiftCard", () => {
133133
cy.dataCy("shipping-method-button").each((e, i) => {
134134
cy.wrap(e).as(`shippingMethodButton${i}`)
135135
})
136-
cy.get("@shippingMethodButton0").click()
136+
cy.get("@shippingMethodButton0").click({ force: true })
137137
cy.wait(
138138
[
139139
"@getShipments",
@@ -147,7 +147,7 @@ describe("Checkout GiftCard", () => {
147147
timeout: 100000,
148148
}
149149
)
150-
cy.get("@shippingMethodButton3").click()
150+
cy.get("@shippingMethodButton3").click({ force: true })
151151
cy.wait(
152152
[
153153
"@getShipments",
@@ -295,7 +295,7 @@ describe("Checkout GiftCard", () => {
295295
cy.dataCy("shipping-method-button").each((e, i) => {
296296
cy.wrap(e).as(`shippingMethodButton${i}`)
297297
})
298-
cy.get("@shippingMethodButton0").click()
298+
cy.get("@shippingMethodButton0").click({ force: true })
299299
cy.wait(
300300
[
301301
"@getShipments",
@@ -309,7 +309,7 @@ describe("Checkout GiftCard", () => {
309309
timeout: 100000,
310310
}
311311
)
312-
cy.get("@shippingMethodButton3").click()
312+
cy.get("@shippingMethodButton3").click({ force: true })
313313
cy.wait(
314314
[
315315
"@getShipments",

cypress/integration/payments.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe("Checkout Payments", () => {
114114
cy.dataCy("shipping-method-button").each((e, i) => {
115115
cy.wrap(e).as(`shippingMethodButton${i}`)
116116
})
117-
cy.get("@shippingMethodButton0").click()
117+
cy.get("@shippingMethodButton0").click({ force: true })
118118
cy.wait(
119119
[
120120
"@getShipments",
@@ -128,7 +128,7 @@ describe("Checkout Payments", () => {
128128
timeout: 100000,
129129
}
130130
)
131-
cy.get("@shippingMethodButton3").click()
131+
cy.get("@shippingMethodButton3").click({ force: true })
132132
cy.wait(
133133
[
134134
"@getShipments",
@@ -264,7 +264,7 @@ describe("Checkout Payments", () => {
264264
cy.dataCy("shipping-method-button").each((e, i) => {
265265
cy.wrap(e).as(`shippingMethodButton${i}`)
266266
})
267-
cy.get("@shippingMethodButton0").click()
267+
cy.get("@shippingMethodButton0").click({ force: true })
268268
cy.wait(
269269
[
270270
"@getShipments",
@@ -278,7 +278,7 @@ describe("Checkout Payments", () => {
278278
timeout: 100000,
279279
}
280280
)
281-
cy.get("@shippingMethodButton3").click()
281+
cy.get("@shippingMethodButton3").click({ force: true })
282282
cy.wait(
283283
[
284284
"@getShipments",
@@ -414,7 +414,7 @@ describe("Checkout Payments", () => {
414414
cy.dataCy("shipping-method-button").each((e, i) => {
415415
cy.wrap(e).as(`shippingMethodButton${i}`)
416416
})
417-
cy.get("@shippingMethodButton0").click()
417+
cy.get("@shippingMethodButton0").click({ force: true })
418418
cy.wait(
419419
[
420420
"@getShipments",
@@ -428,7 +428,7 @@ describe("Checkout Payments", () => {
428428
timeout: 100000,
429429
}
430430
)
431-
cy.get("@shippingMethodButton3").click()
431+
cy.get("@shippingMethodButton3").click({ force: true })
432432
cy.wait(
433433
[
434434
"@getShipments",
@@ -611,7 +611,7 @@ describe("Checkout Payments", () => {
611611
cy.dataCy("shipping-method-button").each((e, i) => {
612612
cy.wrap(e).as(`shippingMethodButton${i}`)
613613
})
614-
cy.get("@shippingMethodButton0").click()
614+
cy.get("@shippingMethodButton0").click({ force: true })
615615
cy.wait(
616616
[
617617
"@getShipments",
@@ -625,7 +625,7 @@ describe("Checkout Payments", () => {
625625
timeout: 100000,
626626
}
627627
)
628-
cy.get("@shippingMethodButton3").click()
628+
cy.get("@shippingMethodButton3").click({ force: true })
629629
cy.wait(
630630
[
631631
"@getShipments",
@@ -783,7 +783,7 @@ describe("Checkout Payments", () => {
783783
cy.dataCy("shipping-method-button").each((e, i) => {
784784
cy.wrap(e).as(`shippingMethodButton${i}`)
785785
})
786-
cy.get("@shippingMethodButton0").click()
786+
cy.get("@shippingMethodButton0").click({ force: true })
787787
cy.wait(
788788
[
789789
"@getShipments",
@@ -954,7 +954,7 @@ describe("Checkout Payments", () => {
954954
cy.dataCy("shipping-method-button").each((e, i) => {
955955
cy.wrap(e).as(`shippingMethodButton${i}`)
956956
})
957-
cy.get("@shippingMethodButton0").click()
957+
cy.get("@shippingMethodButton0").click({ force: true })
958958
cy.wait(
959959
[
960960
"@getShipments",
@@ -1132,7 +1132,7 @@ describe("Checkout Payments", () => {
11321132
cy.dataCy("shipping-method-button").each((e, i) => {
11331133
cy.wrap(e).as(`shippingMethodButton${i}`)
11341134
})
1135-
cy.get("@shippingMethodButton0").click()
1135+
cy.get("@shippingMethodButton0").click({ force: true })
11361136
cy.wait(
11371137
[
11381138
"@getShipments",
@@ -1146,7 +1146,7 @@ describe("Checkout Payments", () => {
11461146
timeout: 100000,
11471147
}
11481148
)
1149-
cy.get("@shippingMethodButton3").click()
1149+
cy.get("@shippingMethodButton3").click({ force: true })
11501150
cy.wait(
11511151
[
11521152
"@getShipments",

0 commit comments

Comments
 (0)