Skip to content

Commit

Permalink
feat: hide tax and payment provider fees when not applicable
Browse files Browse the repository at this point in the history
chore: fix offer e2e test with a payment fee of zero

fix: redeem coupons e2e test
  • Loading branch information
MelissaDTH authored and ChristiaanScheermeijer committed May 30, 2023
1 parent 9745686 commit 790dba4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
7 changes: 3 additions & 4 deletions src/components/CheckoutForm/CheckoutForm.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,21 @@
}

tfoot {
tr:first-child {
tr:first-of-type {
td {
padding-top: 8px;
font-weight: var(--body-font-weight-bold);
font-size: 24px;
}
}

tr:last-child {
tr:not(:first-of-type) {
td {
font-size: 14px;
}
}
}
}

}
.divider {
border: none;
border-top: 1px solid rgba(variables.$white, 0.34);
Expand Down
20 changes: 12 additions & 8 deletions src/components/CheckoutForm/CheckoutForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,24 @@ const CheckoutForm: React.FC<Props> = ({
<td>{formatPrice(-offer.customerPriceInclTax, order.currency, offer.customerCountry)}</td>
</tr>
) : null}
<tr>
<td>{t('checkout.payment_method_fee')}</td>
<td>{formatPrice(order.priceBreakdown.paymentMethodFee, order.currency, offer.customerCountry)}</td>
</tr>
{order.priceBreakdown.paymentMethodFee > 0 && (
<tr>
<td>{t('checkout.payment_method_fee')}</td>
<td>{formatPrice(order.priceBreakdown.paymentMethodFee, order.currency, offer.customerCountry)}</td>
</tr>
)}
</tbody>
<tfoot>
<tr>
<td>{t('checkout.total_price')}</td>
<td>{formatPrice(order.totalPrice, order.currency, offer.customerCountry)}</td>
</tr>
<tr>
<td>{t('checkout.applicable_tax', { taxRate: Math.round(order.taxRate * 100) })}</td>
<td>{formatPrice(order.priceBreakdown.taxValue, order.currency, offer.customerCountry)}</td>
</tr>
{order.priceBreakdown.taxValue > 0 && (
<tr>
<td>{t('checkout.applicable_tax', { taxRate: Math.round(order.taxRate * 100) })}</td>
<td>{formatPrice(order.priceBreakdown.taxValue, order.currency, offer.customerCountry)}</td>
</tr>
)}
</tfoot>
</table>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,7 @@ exports[`<CheckoutForm> > renders and matches snapshot 1`] = `
<table
class="_orderTotals_abc9bc"
>
<tbody>
<tr>
<td>
checkout.payment_method_fee
</td>
<td>
€ 0,00
</td>
</tr>
</tbody>
<tbody />
<tfoot>
<tr>
<td>
Expand Down
4 changes: 3 additions & 1 deletion test-e2e/tests/payments/coupons_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ function runTestSuite(props: ProviderProps, providerName: string) {

I.see(formatPrice(-37.5, 'EUR', props.locale));
I.see(formatPrice(12.5, 'EUR', props.locale));
I.see(formatPrice(props.applicableTax, 'EUR', props.locale));
if (props.applicableTax !== 0) {
I.see(formatPrice(props.applicableTax, 'EUR', props.locale));
}

I.fillField('couponCode', 'test100');
I.click('Apply');
Expand Down
4 changes: 2 additions & 2 deletions test-e2e/tests/payments/subscription_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ function runTestSuite(props: ProviderProps, providerName: string) {

I.see('Redeem coupon');
I.see(props.yearlyOffer.price);
I.see('Payment method fee');
I.see(props.yearlyOffer.paymentFee);
I.dontSee('Payment method fee');
I.dontSee(props.yearlyOffer.paymentFee);
I.see('Total');
if (props.applicableTax !== 0) {
I.see('Applicable tax (21%)');
Expand Down

0 comments on commit 790dba4

Please sign in to comment.