Skip to content

Commit 79f12ad

Browse files
committed
fix: calculate proper taxes on address change
1 parent 033155a commit 79f12ad

7 files changed

Lines changed: 66 additions & 9 deletions

File tree

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
/// <reference path="./.next/types/routes.d.ts" />
3+
/// <reference path="./out/dist/types/routes.d.ts" />
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"dependencies": {
7676
"@commercelayer/js-auth": "^6.7.2",
7777
"@commercelayer/organization-config": "^2.4.0",
78-
"@commercelayer/react-components": "4.25.6",
78+
"@commercelayer/react-components": "4.25.7",
7979
"@commercelayer/sdk": "^6.45.1",
8080
"@faker-js/faker": "^10.0.0",
8181
"@headlessui/react": "^2.2.7",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specs/e2e/guest-addresses.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ test.describe("with customer email and shipping country code lock", () => {
211211
test("Checkout guest address", async ({ checkoutPage }) => {
212212
await checkoutPage.checkOrderSummary("Order Summary")
213213

214-
let email = await checkoutPage.getCustomerMail()
214+
let email = checkoutPage.getCustomerMail()
215215

216216
await expect(email).toHaveValue(customerEmail)
217217

specs/e2e/tax-calculations.spec.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { faker } from "@faker-js/faker"
2+
3+
import { expect, test } from "../fixtures/tokenizedPage"
4+
import { euAddress, euAddressNoBillingInfo } from "../utils/addresses"
5+
6+
const customerEmail = faker.internet.email().toLocaleLowerCase()
7+
8+
test.describe("with different tax calculators", () => {
9+
test.use({
10+
defaultParams: {
11+
order: "with-items",
12+
lineItemsAttributes: [
13+
{ sku_code: "CANVASAU000000FFFFFF1824", quantity: 1 },
14+
],
15+
orderAttributes: {
16+
customer_email: customerEmail,
17+
},
18+
market: "NO",
19+
},
20+
})
21+
22+
test("Checkout address changing from Italy to Norway", async ({
23+
checkoutPage,
24+
}) => {
25+
await checkoutPage.checkOrderSummary("Order Summary")
26+
27+
let email = checkoutPage.getCustomerMail()
28+
29+
await expect(email).toHaveValue(customerEmail)
30+
31+
await checkoutPage.changeCustomerEmail("customer@example.com")
32+
await checkoutPage.blurCustomerEmail()
33+
email = checkoutPage.getCustomerMail()
34+
35+
await expect(email).toHaveValue("customer@example.com")
36+
await checkoutPage.checkStep("Customer", "open")
37+
38+
await checkoutPage.setBillingAddress(euAddressNoBillingInfo)
39+
40+
await checkoutPage.save("Customer")
41+
await checkoutPage.checkStep("Customer", "close")
42+
43+
await checkoutPage.checkCustomerEmail("customer@example.com")
44+
45+
await checkoutPage.checkTaxSummary("0,00 Kr")
46+
47+
await checkoutPage.clickStep("Customer")
48+
await checkoutPage.checkStep("Customer", "open")
49+
50+
await checkoutPage.selectCountry("billing_address", "NO")
51+
52+
await checkoutPage.save("Customer")
53+
54+
await checkoutPage.checkTaxSummary("2,75 Kr")
55+
})
56+
})

specs/fixtures/CheckoutPage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export class CheckoutPage {
297297

298298
async selectCountry(
299299
type: "billing_address" | "shipping_address",
300-
country: "IT" | "US" | "GB" | "FR" | "ES",
300+
country: "IT" | "US" | "GB" | "FR" | "ES" | "NO",
301301
) {
302302
await this.page.selectOption(
303303
`[data-testid=input_${type}_country_code]`,

specs/fixtures/tokenizedPage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type ValidMarket =
4343
| "VV"
4444
| "PT"
4545
| "AT"
46+
| "NO"
4647

4748
interface BaseLineItemObject {
4849
quantity: number

0 commit comments

Comments
 (0)