Skip to content

Commit

Permalink
feat: use navigator.userAgent to detect test user
Browse files Browse the repository at this point in the history
  • Loading branch information
BrickheadJohnny committed Jul 23, 2024
1 parent 2fcb6f9 commit 1bf45f9
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 43 deletions.
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"attributePosition": "auto"
},
"files": {
"include": ["src", "playwright"],
"include": ["src", "playwright", "playwright.config.ts"],
"ignore": ["node_modules", ".next", "public", ".out", "package-lock.json"]
},
"organizeImports": {
Expand Down
16 changes: 12 additions & 4 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig, devices } from "@playwright/test"

const baseURL = "http://localhost:3000";
const baseURL = "http://localhost:3000"

export default defineConfig({

Check warning on line 5 in playwright.config.ts

View workflow job for this annotation

GitHub Actions / quality-assurance

lint/style/noDefaultExport

Avoid default exports.
testDir: "./playwright",
Expand All @@ -10,18 +10,26 @@ export default defineConfig({
workers: process.env.CI ? 1 : undefined,
reporter: process.env.CI ? "github" : "html",
outputDir: "playwright/results/",

use: {
baseURL,
trace: "on-first-retry",
},

projects: [
{ name: "auth-setup", testMatch: /auth\.setup\.ts/ },
{
name: "auth-setup",
testMatch: /auth\.setup\.ts/,
use: {
...devices["Desktop Chrome"],
userAgent: `${devices["Desktop Chrome"].userAgent} GUILD_E2E`,
},
},
{
name: "chromium",
use: {
...devices["Desktop Chrome"],
userAgent: `${devices["Desktop Chrome"].userAgent} GUILD_E2E`,
},
dependencies: ["auth-setup"],
},
Expand Down Expand Up @@ -56,7 +64,7 @@ export default defineConfig({
],

webServer: {
command: 'npm run start',
command: "npm run start",
url: baseURL,
reuseExistingServer: !process.env.CI,
},
Expand Down
81 changes: 43 additions & 38 deletions src/wagmiConfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ export const wagmiConfig = createConfig({
[blast.id]: http(),
[blastSepolia.id]: http(),
[oasisSapphire.id]: http(),
[sepolia.id]: http("https://ethereum-sepolia-rpc.publicnode.com"),
[sepolia.id]: http(
env.NEXT_PUBLIC_E2E_WALLET_MNEMONIC
? "http://localhost:8545"
: "https://ethereum-sepolia-rpc.publicnode.com"
),
[astarZkEVM.id]: http(),
[coreDao.id]: http(),
[liskSepolia.id]: http(),
Expand All @@ -191,43 +195,44 @@ export const wagmiConfig = createConfig({
[mint.id]: http(),
},
ssr: true,
connectors: process.env.NEXT_PUBLIC_E2E_WALLET_MNEMONIC
? [
mock({
accounts: [mnemonicToAccount(process.env.NEXT_PUBLIC_E2E_WALLET_MNEMONIC)],
features: {
reconnect: true,
},
}),
]
: [
injected(),
coinbaseWallet({
appName: "Guild.xyz",
appLogoUrl: "https://guild.xyz/guild-icon.png",
version: "4",
}),
walletConnect({
projectId: env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID,
showQrModal: true,
qrModalOptions: {
explorerRecommendedWalletIds: [
"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709", // OKX
"107bb20463699c4e614d3a2fb7b961e66f48774cb8f6d6c1aee789853280972c", // Bitcoin.com
"541d5dcd4ede02f3afaf75bf8e3e4c4f1fb09edb5fa6c4377ebf31c2785d9adf", // Ronin
"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0", // Trust
],
themeVariables: {
"--wcm-z-index": "10001",
"--w3m-z-index": "10001",
} as any, // casting it, so `--wcm-z-index` is accepted
},
}),
safe({
allowedDomains: [/gnosis-safe\.io$/, /app\.safe\.global$/],
debug: false,
}),
],
connectors:
typeof navigator !== "undefined" && navigator.userAgent.includes("GUILD_E2E")
? [
mock({
accounts: [mnemonicToAccount(env.NEXT_PUBLIC_E2E_WALLET_MNEMONIC)],
features: {
reconnect: true,
},
}),
]
: [
injected(),
coinbaseWallet({
appName: "Guild.xyz",
appLogoUrl: "https://guild.xyz/guild-icon.png",
version: "4",
}),
walletConnect({
projectId: env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID,
showQrModal: true,
qrModalOptions: {
explorerRecommendedWalletIds: [
"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709", // OKX
"107bb20463699c4e614d3a2fb7b961e66f48774cb8f6d6c1aee789853280972c", // Bitcoin.com
"541d5dcd4ede02f3afaf75bf8e3e4c4f1fb09edb5fa6c4377ebf31c2785d9adf", // Ronin
"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0", // Trust
],
themeVariables: {
"--wcm-z-index": "10001",
"--w3m-z-index": "10001",
} as any, // casting it, so `--wcm-z-index` is accepted
},
}),
safe({
allowedDomains: [/gnosis-safe\.io$/, /app\.safe\.global$/],
debug: false,
}),
],
})

export const COINBASE_INJECTED_WALLET_ID = "com.coinbase.wallet"
Expand Down

0 comments on commit 1bf45f9

Please sign in to comment.