-
Notifications
You must be signed in to change notification settings - Fork 146
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
1 parent
c16b0d5
commit 5e09e3b
Showing
7 changed files
with
120 additions
and
79 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,24 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import { mintWithGoogleAuthWorkflow } from "./helpers/mintWorkflow"; | ||
const googleEmail = process.env.PLAYWRIGHT_GOOGLE_EMAIL; | ||
const googlePassword = process.env.PLAYWRIGHT_GOOGLE_PASSWORD; | ||
|
||
test.beforeEach(async ({ page, baseURL }) => { | ||
await page.goto(baseURL!); | ||
}); | ||
test("Google sign in", async ({ page }) => { | ||
if (!googleEmail || !googlePassword) { | ||
throw new Error( | ||
"PLAYWRIGHT_GOOGLE_EMAIL and PLAYWRIGHT_GOOGLE_PASSWORD must be set" | ||
); | ||
} | ||
await expect(page).toHaveTitle(/Account Kit/); | ||
// Fast way to initialize the page and ensure config is loaded | ||
await page.getByRole("switch", { name: "Email" }).click(); | ||
await page.getByRole("switch", { name: "Email" }).click(); | ||
const walletSwitch = await page.locator("#wallet-switch"); | ||
if ((await walletSwitch.getAttribute("aria-checked")) === "false") { | ||
await walletSwitch.click(); | ||
} | ||
await mintWithGoogleAuthWorkflow(page, googleEmail, googlePassword); | ||
}); |
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 @@ | ||
// sharedWorkflow.ts | ||
import { Page, expect } from "@playwright/test"; | ||
|
||
export async function mintWithGoogleAuthWorkflow( | ||
page: Page, | ||
googleEmail: string, | ||
googlePassword: string | ||
) { | ||
// Google sign in | ||
await page.locator("button[aria-label='Google sign in']").click(); | ||
const popup = await page.waitForEvent("popup"); | ||
await popup.waitForLoadState("networkidle"); | ||
|
||
const emailInput = popup.getByRole("textbox"); | ||
await emailInput.fill(googleEmail); | ||
await popup.getByRole("button", { name: /Next/i }).click(); | ||
await expect(popup.getByText(/Enter your password/i)).toBeVisible(); | ||
|
||
const passwordInput = popup.locator("input[type='password']:visible"); | ||
await passwordInput.fill(googlePassword); | ||
await popup.getByRole("button", { name: /Next/i }).click(); | ||
|
||
// Wait for page to load after sign in | ||
await expect(page.getByText(/Gasless transactions/i)).toBeVisible(); | ||
const avatar = page.getByRole("button", { name: `Hello, ${googleEmail}` }); | ||
await expect(avatar).toBeVisible(); | ||
await page.locator("img[alt='An NFT']"); | ||
|
||
// Collect NFT | ||
await page.getByRole("button", { name: "Collect NFT" }).click(); | ||
await expect(page.getByText("Success", { exact: true })).toBeVisible({ | ||
timeout: 30000, | ||
}); | ||
|
||
// Create session key | ||
await page.getByRole("button", { name: "Create session key" }).click(); | ||
await expect(page.getByText("Bought 1 ETH")).toBeVisible({ | ||
timeout: 30000, | ||
}); | ||
|
||
// Check external links | ||
await expect(page.locator("a[aria-label='View transaction']")).toBeVisible(); | ||
await expect(page.getByRole("link", { name: "Quickstart" })).toHaveAttribute( | ||
"href", | ||
"https://accountkit.alchemy.com/react/quickstart" | ||
); | ||
await expect(page.locator("a[aria-label='GitHub']")).toHaveAttribute( | ||
"href", | ||
"https://github.com/alchemyplatform/aa-sdk/tree/v4.x.x" | ||
); | ||
await expect(page.getByRole("link", { name: "CSS" })).toHaveAttribute( | ||
"href", | ||
"https://github.com/alchemyplatform/aa-sdk/blob/v4.x.x/account-kit/react/src/tailwind/types.ts#L6" | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import { mintWithGoogleAuthWorkflow } from "./helpers/mintWorkflow"; | ||
const googleEmail = process.env.PLAYWRIGHT_GOOGLE_EMAIL; | ||
const googlePassword = process.env.PLAYWRIGHT_GOOGLE_PASSWORD; | ||
|
||
test.beforeEach(async ({ page, baseURL }) => { | ||
await page.goto(baseURL!); | ||
}); | ||
test("Google sign in", async ({ page }) => { | ||
if (!googleEmail || !googlePassword) { | ||
throw new Error( | ||
"PLAYWRIGHT_GOOGLE_EMAIL and PLAYWRIGHT_GOOGLE_PASSWORD must be set" | ||
); | ||
} | ||
await expect(page).toHaveTitle(/Account Kit/); | ||
// Fast way to initialize the page and ensure config is loaded | ||
await page.getByRole("switch", { name: "Email" }).click(); | ||
await page.getByRole("switch", { name: "Email" }).click(); | ||
|
||
const walletSwitch = await page.locator("#wallet-switch"); | ||
if ((await walletSwitch.getAttribute("aria-checked")) === "true") { | ||
await walletSwitch.click(); | ||
} | ||
|
||
await mintWithGoogleAuthWorkflow(page, googleEmail, googlePassword); | ||
}); |
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