-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
479 changed files
with
24,771 additions
and
6,340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { test } from "@playwright/test"; | ||
import { createD2CProductDetailPage } from "./models/d2c-product-detail-page"; | ||
import { client } from "./util/epcc-client"; | ||
import { createD2CCartPage } from "./models/d2c-cart-page"; | ||
import { createD2CCheckoutPage } from "./models/d2c-checkout-page"; | ||
|
||
test.describe("Checkout flow", async () => { | ||
test("should perform product checkout", async ({ page }) => { | ||
const productDetailPage = createD2CProductDetailPage(page, client); | ||
const cartPage = createD2CCartPage(page); | ||
const checkoutPage = createD2CCheckoutPage(page); | ||
|
||
/* Go to simple product page */ | ||
await productDetailPage.gotoSimpleProduct(); | ||
|
||
/* Add the product to cart */ | ||
await productDetailPage.addProductToCart(); | ||
|
||
/* Go to cart page and checkout */ | ||
await cartPage.goto(); | ||
await cartPage.checkoutCart(); | ||
|
||
/* Enter information */ | ||
await checkoutPage.enterInformation({ | ||
Email: { value: "[email protected]", fieldType: "input" }, | ||
"First Name": { value: "Jim", fieldType: "input" }, | ||
"Last Name": { value: "Brown", fieldType: "input" }, | ||
"Street Address": { value: "Main Street", fieldType: "input" }, | ||
"Extended Address": { value: "Extended Address", fieldType: "input" }, | ||
City: { value: "Brownsville", fieldType: "input" }, | ||
County: { value: "Brownsville County", fieldType: "input" }, | ||
Region: { value: "Browns", fieldType: "input" }, | ||
Postcode: { value: "ABC 123", fieldType: "input" }, | ||
Country: { value: "Algeria", fieldType: "select" }, | ||
"Phone Number": { value: "01234567891", fieldType: "input" }, | ||
"Additional Instructions": { | ||
value: "This is some extra instructions.", | ||
fieldType: "input", | ||
}, | ||
}); | ||
|
||
await checkoutPage.checkout(); | ||
await checkoutPage.checkOrderComplete; | ||
|
||
/* Continue Shopping */ | ||
await checkoutPage.continueShopping(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import type { Locator, Page } from "@playwright/test"; | ||
import { fillAllFormFields, FormInput } from "../util/fill-form-field"; | ||
import { expect } from "@playwright/test"; | ||
import { enterPaymentInformation as _enterPaymentInformation } from "../util/enter-payment-information"; | ||
|
||
export interface D2CCheckoutPage { | ||
readonly page: Page; | ||
readonly payNowBtn: Locator; | ||
readonly checkoutBtn: Locator; | ||
readonly goto: () => Promise<void>; | ||
readonly enterInformation: (values: FormInput) => Promise<void>; | ||
readonly checkout: () => Promise<void>; | ||
readonly enterPaymentInformation: (values: FormInput) => Promise<void>; | ||
readonly submitPayment: () => Promise<void>; | ||
readonly checkOrderComplete: () => Promise<void>; | ||
readonly continueShopping: () => Promise<void>; | ||
} | ||
|
||
export function createD2CCheckoutPage(page: Page): D2CCheckoutPage { | ||
const payNowBtn = page.getByRole("button", { name: "Pay now" }); | ||
const checkoutBtn = page.getByRole("button", { name: "Checkout Now" }); | ||
const continueShoppingBtn = page.getByRole("button", { | ||
name: "Continue Shopping", | ||
}); | ||
|
||
return { | ||
page, | ||
payNowBtn, | ||
checkoutBtn, | ||
async goto() { | ||
await page.goto(`/cart`); | ||
}, | ||
async enterPaymentInformation(values: FormInput) { | ||
await _enterPaymentInformation(page, values); | ||
}, | ||
async enterInformation(values: FormInput) { | ||
await fillAllFormFields(page, values); | ||
}, | ||
async submitPayment() { | ||
await payNowBtn.click(); | ||
}, | ||
async checkout() { | ||
await checkoutBtn.click(); | ||
}, | ||
async checkOrderComplete() { | ||
await page.getByText("Thank you for your order!"); | ||
}, | ||
async continueShopping() { | ||
await continueShoppingBtn.click(); | ||
await expect( | ||
page.getByRole("heading", { name: "Your Elastic Path storefront" }), | ||
).toBeVisible(); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Page } from "@playwright/test"; | ||
import { fillAllFormFields, FormInput } from "./fill-form-field"; | ||
|
||
export async function enterPaymentInformation(page: Page, values: FormInput) { | ||
const paymentIframe = await page | ||
.locator('[id="payment-element"]') | ||
.frameLocator("iframe"); | ||
|
||
await fillAllFormFields(paymentIframe, values); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { Moltin as EPCCClient } from "@moltin/sdk"; | ||
|
||
export async function gatewayCheck(client: EPCCClient): Promise<boolean> { | ||
try { | ||
const gateways = await client.Gateways.All(); | ||
const epPaymentGateway = gateways.data.find( | ||
(gateway) => gateway.slug === "elastic_path_payments_stripe", | ||
)?.enabled; | ||
return !!epPaymentGateway; | ||
} catch (err) { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { test } from "@playwright/test"; | ||
import { gatewayCheck } from "./gateway-check"; | ||
import { adminClient } from "./epcc-admin-client"; | ||
|
||
export async function gatewayIsEnabled(): Promise<void> { | ||
test.skip( | ||
!(await gatewayCheck(adminClient)), | ||
"Skipping tests because they payment gateway is not enabled.", | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
examples/algolia/src/app/(auth)/account-memeber-credentials-schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { z } from "zod"; | ||
|
||
export const accountMemberCredentialSchema = z.object({ | ||
account_id: z.string(), | ||
account_name: z.string(), | ||
expires: z.string(), | ||
token: z.string(), | ||
type: z.literal("account_management_authentication_token"), | ||
}); | ||
|
||
export type AccountMemberCredential = z.infer< | ||
typeof accountMemberCredentialSchema | ||
>; | ||
|
||
export const accountMemberCredentialsSchema = z.object({ | ||
accounts: z.record(z.string(), accountMemberCredentialSchema), | ||
selected: z.string(), | ||
accountMemberId: z.string(), | ||
}); | ||
|
||
export type AccountMemberCredentials = z.infer< | ||
typeof accountMemberCredentialsSchema | ||
>; |
Oops, something went wrong.