-
Notifications
You must be signed in to change notification settings - Fork 5.2k
feat: add playwright test for start page [fixes #15896] #15897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,21 +9,37 @@ import { | |||||
zerionWallet, | ||||||
} from "@rainbow-me/rainbowkit/wallets" | ||||||
|
||||||
import { mockWallet } from "../../tests/e2e/fixtures/mockWallet" | ||||||
|
||||||
const walletGroups = [ | ||||||
{ | ||||||
groupName: "New to crypto", | ||||||
wallets: [ | ||||||
coinbaseWallet, | ||||||
rainbowWallet, | ||||||
metaMaskWallet, | ||||||
zerionWallet, | ||||||
oneKeyWallet, | ||||||
walletConnectWallet, | ||||||
], | ||||||
}, | ||||||
] | ||||||
|
||||||
const isLocalhost = | ||||||
typeof window !== "undefined" && window.location.hostname === "localhost" | ||||||
|
||||||
// Add mock wallet only when running on localhost | ||||||
if (isLocalhost) { | ||||||
walletGroups.push({ | ||||||
groupName: "Test", | ||||||
wallets: [mockWallet], | ||||||
}) | ||||||
} | ||||||
|
||||||
export const rainbowkitConfig = getDefaultConfig({ | ||||||
appName: "ethereum.org", | ||||||
projectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID!, | ||||||
chains: [mainnet], | ||||||
wallets: [ | ||||||
{ | ||||||
groupName: "New to crypto", | ||||||
wallets: [ | ||||||
coinbaseWallet, | ||||||
rainbowWallet, | ||||||
metaMaskWallet, | ||||||
zerionWallet, | ||||||
oneKeyWallet, | ||||||
walletConnectWallet, | ||||||
], | ||||||
}, | ||||||
], | ||||||
wallets: walletGroups, | ||||||
ssr: isLocalhost, | ||||||
|
ssr: isLocalhost, | |
ssr: true, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Address } from "viem" | ||
import { CreateConnectorFn, mock } from "wagmi" | ||
import type { Wallet } from "@rainbow-me/rainbowkit" | ||
import { WalletDetailsParams } from "@rainbow-me/rainbowkit" | ||
|
||
const defaultAnvilAccount: Address = | ||
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" | ||
|
||
export const mockWallet = (): Wallet => { | ||
return { | ||
id: "mock", | ||
name: "Mock Wallet", | ||
shortName: "Mock", | ||
installed: true, | ||
iconBackground: "rgba(0, 255, 0, 0.5)", | ||
iconUrl: "/images/assets/svgs/eth-glyph-colored.svg", | ||
downloadUrls: {}, | ||
createConnector: createMockConnector, | ||
} | ||
} | ||
|
||
function createMockConnector( | ||
walletDetails: WalletDetailsParams | ||
): CreateConnectorFn { | ||
const mockConnector: CreateConnectorFn = (config) => { | ||
return { | ||
...mock({ | ||
accounts: [defaultAnvilAccount], | ||
})(config), | ||
rkDetails: walletDetails.rkDetails, | ||
} | ||
} | ||
|
||
return mockConnector | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { expect, Page } from "@playwright/test" | ||
|
||
import { testData } from "../fixtures/testData" | ||
|
||
import { BasePage } from "./BasePage" | ||
|
||
/** | ||
* Page Object Model for the Start page | ||
*/ | ||
export class StartPage extends BasePage { | ||
private readonly url = "/en/start" | ||
|
||
constructor(page: Page) { | ||
super(page) | ||
} | ||
|
||
/** | ||
* Navigate to the start page | ||
*/ | ||
async goto() { | ||
await this.navigateTo(this.url) | ||
} | ||
|
||
/** | ||
* Verify the start page has loaded successfully | ||
*/ | ||
async verifyPageLoaded() { | ||
await this.assertTitleContains(testData.content.headings.startPage) | ||
} | ||
|
||
async connectWithExistingWallet() { | ||
await this.page | ||
.getByRole("paragraph") | ||
.filter({ hasText: "I have a wallet." }) | ||
.click() | ||
await this.page.getByRole("button", { name: "Continue" }).click() | ||
await this.page | ||
.getByRole("button", { name: "Sign in with Ethereum" }) | ||
.click() | ||
// Choose mock wallet option in RainbowKit modal | ||
await this.page.getByTestId("rk-wallet-option-mock").click() | ||
// Verify wallet connected | ||
await expect( | ||
this.page | ||
.getByRole("paragraph") | ||
.filter({ hasText: "This is your account" }) | ||
).toBeVisible() | ||
} | ||
|
||
async continueToUseAppsStep() { | ||
await this.page.getByRole("button", { name: "Lets continue" }).click() | ||
await expect( | ||
this.page.getByRole("heading", { name: "Let Use Some Apps" }) | ||
).toBeVisible() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { test } from "@playwright/test" | ||
|
||
import { StartPage } from "./pages" | ||
|
||
test.describe("Start Page", () => { | ||
test("Connect wallet", async ({ page }) => { | ||
const startPage = new StartPage(page) | ||
await startPage.goto() | ||
await startPage.verifyPageLoaded() | ||
|
||
await startPage.connectWithExistingWallet() | ||
|
||
await startPage.continueToUseAppsStep() | ||
}) | ||
}) |
Uh oh!
There was an error while loading. Please reload this page.