Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
42 changes: 29 additions & 13 deletions src/config/rainbow-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Author

@agualis agualis Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not using ssr: true casues hydration issues. Is there an explicit reason why you are not using it by default?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I don't see why not to enable this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming we still want this updated?

Suggested change
ssr: isLocalhost,
ssr: true,

})
35 changes: 35 additions & 0 deletions tests/e2e/fixtures/mockWallet.ts
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
}
2 changes: 2 additions & 0 deletions tests/e2e/fixtures/testData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import en from "@/intl/en/common.json"
import enStart from "@/intl/en/page-start.json"
import es from "@/intl/es/common.json"

/**
Expand Down Expand Up @@ -36,6 +37,7 @@ export const testData = {
content: {
headings: {
homepage: en["site-title"],
startPage: enStart["page-start-meta-title"],
findWallet: en["nav-find-wallet-label"],
notFoundEn: en["we-couldnt-find-that-page"],
notFoundEs: es["we-couldnt-find-that-page"],
Expand Down
56 changes: 56 additions & 0 deletions tests/e2e/pages/StartPage.ts
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()
}
}
1 change: 1 addition & 0 deletions tests/e2e/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
export { BasePage } from "./BasePage"
export { FindWalletPage } from "./FindWalletPage"
export { HomePage } from "./HomePage"
export { StartPage } from "./StartPage"
15 changes: 15 additions & 0 deletions tests/e2e/start.spec.ts
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()
})
})