Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions specs/e2e/flex-promotion-buy-x-pay-y.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from "../fixtures/tokenizedPage"

test.describe("with coupon code", () => {
test.use({
defaultParams: {
order: "with-items",
lineItemsAttributes: [
{ sku_code: "SWEETSMUB7B7B7E63E74LXXX", quantity: 3 },
],
couponCode: "flex_promotion_buy_x_pay_y",
},
})

test("should execute a checkout", async ({ checkoutPage }) => {
await checkoutPage.checkOrderSummary("Order Summary")
await checkoutPage.checkDiscountAmount("-€35")
})
})
21 changes: 21 additions & 0 deletions specs/e2e/flex-promotion-dynamic-bundles.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { test, expect } from "../fixtures/tokenizedPage"

test.describe("with coupon code", () => {
test.use({
defaultParams: {
order: "with-items",
lineItemsAttributes: [
{ sku_code: "5PANECAP9D9CA1FFFFFFXXXX", quantity: 2 },
{ sku_code: "CROPTOPW000000FFFFFFLXXX", quantity: 2 },
{ sku_code: "CROPTOPWE8E8E8000000XSXX", quantity: 1 },
{ sku_code: "HOODIEWC000000FFFFFFLXXX", quantity: 1 },
],
couponCode: "flex_promotion_dynamic_bundles",
},
})

test("should execute a checkout", async ({ checkoutPage }) => {
await checkoutPage.checkOrderSummary("Order Summary")
await checkoutPage.checkDiscountAmount("-€37,86")
})
})
26 changes: 26 additions & 0 deletions specs/e2e/flex-promotion-dynamic-value.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { test, expect } from "../fixtures/tokenizedPage"

test.describe("with coupon code", () => {
test.use({
defaultParams: {
order: "with-items",
lineItemsAttributes: [
{ sku_code: "SOCKXXMUFFFFFF000000MXXX", quantity: 1 },
{ sku_code: "TSHIRTMMFFFFFFE63E74MXXX", quantity: 1 },
{ sku_code: "LSLEEVMM000000E63E74LXXX", quantity: 1 },
],
couponCode: "flex_promotion_dynamic_value",
},
})

test("should execute a checkout", async ({ checkoutPage }) => {
await checkoutPage.checkOrderSummary("Order Summary")
await checkoutPage.setCustomerMail("test@commercelayer.io")
await checkoutPage.setBillingAddress()
await checkoutPage.checkStep("Customer", "open")
await checkoutPage.save("Customer")
await checkoutPage.checkStep("Shipping", "open")
await checkoutPage.selectShippingMethod({ text: "Standard Shipping" })
await checkoutPage.checkDiscountAmount("-€12,20")
})
})
18 changes: 18 additions & 0 deletions specs/e2e/flex-promotion-every-x-discount-y.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from "../fixtures/tokenizedPage"

test.describe("with coupon code", () => {
test.use({
defaultParams: {
order: "with-items",
lineItemsAttributes: [
{ sku_code: "SWEETSMUB7B7B7E63E74LXXX", quantity: 5 },
],
couponCode: "flex_promotion_every_x_discount_y",
},
})

test("should execute a checkout", async ({ checkoutPage }) => {
await checkoutPage.checkOrderSummary("Order Summary")
await checkoutPage.checkDiscountAmount("-€5")
})
})
18 changes: 18 additions & 0 deletions specs/e2e/flex-promotion-fixed-amount.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from "../fixtures/tokenizedPage"

test.describe("with coupon code", () => {
test.use({
defaultParams: {
order: "with-items",
lineItemsAttributes: [
{ sku_code: "SWEETSMUB7B7B7E63E74LXXX", quantity: 5 },
],
couponCode: "flex_promotion_fixed_amount",
},
})

test("should execute a checkout", async ({ checkoutPage }) => {
await checkoutPage.checkOrderSummary("Order Summary")
await checkoutPage.checkDiscountAmount("-€5")
})
})
18 changes: 18 additions & 0 deletions specs/e2e/flex-promotion-fixed-price.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from "../fixtures/tokenizedPage"

test.describe("with coupon code", () => {
test.use({
defaultParams: {
order: "with-items",
lineItemsAttributes: [
{ sku_code: "SWEETSMUB7B7B7E63E74LXXX", quantity: 5 },
],
couponCode: "flex_promotion_fixed_price",
},
})

test("should execute a checkout", async ({ checkoutPage }) => {
await checkoutPage.checkOrderSummary("Order Summary")
await checkoutPage.checkDiscountAmount("-€162,5")
})
})
32 changes: 32 additions & 0 deletions specs/e2e/flex-promotion-nested-country-code.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { test, expect } from "../fixtures/tokenizedPage"

test.describe("with coupon code", () => {
test.use({
defaultParams: {
order: "with-items",
lineItemsAttributes: [
{
sku_code: "DUFFLBAG000000FFFFFFXXXX",
quantity: 1,
sku_options: [
{
name: "Premium zipper",
}
]
}
],
couponCode: "flex_promotion_nested_country_code",
},
})

test("should execute a checkout", async ({ checkoutPage }) => {
await checkoutPage.checkOrderSummary("Order Summary")
await checkoutPage.setCustomerMail("prospect@commercelayer.io")
await checkoutPage.setBillingAddress()
await checkoutPage.checkStep("Customer", "open")
await checkoutPage.save("Customer")
await checkoutPage.checkStep("Shipping", "open")
await checkoutPage.selectShippingMethod({ text: "Standard Shipping" })
await checkoutPage.checkDiscountAmount("-€25,00")
})
})
18 changes: 18 additions & 0 deletions specs/e2e/flex-promotion-percentage.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from "../fixtures/tokenizedPage"

test.describe("with coupon code", () => {
test.use({
defaultParams: {
order: "with-items",
lineItemsAttributes: [
{ sku_code: "SWEETSMUB7B7B7E63E74LXXX", quantity: 5 },
],
couponCode: "flex_promotion_percentage",
},
})

test("should execute a checkout", async ({ checkoutPage }) => {
await checkoutPage.checkOrderSummary("Order Summary")
await checkoutPage.checkDiscountAmount("-€18,50")
})
})
35 changes: 18 additions & 17 deletions specs/fixtures/CheckoutPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ export class CheckoutPage {
}

async goto({ orderId, token }: GoToProps) {
const url = `${
process.env.NEXT_PUBLIC_BASE_PATH || ""
}/${orderId}?accessToken=${token}`
const url = `${process.env.NEXT_PUBLIC_BASE_PATH || ""
}/${orderId}?accessToken=${token}`

await this.page.route("**/api/organization**", (route) => {
// // Add a prefix to the title.
Expand Down Expand Up @@ -475,10 +474,10 @@ export class CheckoutPage {
}
const fieldType =
key === "country_code" ||
(key === "state_code" &&
address.country_code &&
// TODO Adjust to check for select or input
["IT", "US"].includes(address.country_code))
(key === "state_code" &&
address.country_code &&
// TODO Adjust to check for select or input
["IT", "US"].includes(address.country_code))
? "select"
: "input"
const element = this.page.locator(`${fieldType}[name=${type}_${key}]`)
Expand Down Expand Up @@ -627,7 +626,7 @@ export class CheckoutPage {
}

async checkLineItemAmount(text?: string) {
const element = await this.page.getByTestId(`line-item-amount`)
const element = this.page.getByTestId(`line-item-amount`)
if (text !== undefined) {
await element.waitFor({ state: "visible" })
await expect(await element.innerText()).toBe(text)
Expand All @@ -637,7 +636,9 @@ export class CheckoutPage {
}

async checkDiscountAmount(text?: string) {
const element = await this.page.getByTestId("discount-amount")
const element = this.page.locator(
`[data-testid=discount-amount] >> text=${text}`
)
if (text !== undefined) {
await element.waitFor({ state: "visible" })
} else {
Expand All @@ -646,7 +647,7 @@ export class CheckoutPage {
}

async checkGiftCardAmount(text?: string) {
const element = await this.page.locator(
const element = this.page.locator(
`[data-testid=giftcard-amount] >> text=${text}`
)
if (text !== undefined) {
Expand Down Expand Up @@ -740,13 +741,13 @@ export class CheckoutPage {
}: {
type: "adyen-dropin" | "klarna" | "stripe"
gateway?:
| "paypal"
| "card"
| "card3DS"
| "klarna_pay_over_time"
| "klarna_pay_later"
| "klarna_pay_now"
| "klarna"
| "paypal"
| "card"
| "card3DS"
| "klarna_pay_over_time"
| "klarna_pay_later"
| "klarna_pay_now"
| "klarna"
language?: "fr" | "de" | "us"
}) {
switch (type) {
Expand Down