Skip to content

Commit

Permalink
Target preview keychain when running playwright on ci
Browse files Browse the repository at this point in the history
  • Loading branch information
JunichiSugiura committed Aug 21, 2024
1 parent 150f556 commit 38182fa
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 12 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ jobs:
- name: Install Playwright Browsers
run: pnpm example:next e2e:deps
- name: Run Playwright tests
run: pnpm e2e:ci
run: |
cat <<EOF >examples/starknet-react-next/.env
BRANCH_NAME=${{ github.head_ref }}
EOF
pnpm e2e:ci
- uses: actions/upload-artifact@v4
if: always()
with:
Expand Down
3 changes: 2 additions & 1 deletion examples/starknet-react-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"dev": "next dev -p 3002",
"build": "next build",
"e2e:deps": "npx playwright install --with-deps",
"e2e:deps": "pnpm playwright install --with-deps",
"e2e": "playwright test",
"e2e:ui": "pnpm e2e --ui",
"start": "next start -p 3002",
Expand All @@ -32,6 +32,7 @@
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"autoprefixer": "^10.4.18",
"dotenv": "^16.4.5",
"eslint": "^8.23.0",
"eslint-config-next": "^12.2.5",
"postcss": "^8.4.35",
Expand Down
11 changes: 9 additions & 2 deletions examples/starknet-react-next/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { defineConfig, devices } from "@playwright/test";
import { KEYCHAIN_URL } from "components/providers/StarknetProvider";
import dotenv from "dotenv";
import path from "path";

dotenv.config({ path: path.resolve(__dirname, ".env") });

const CI_BASE_URL = process.env.BRANCH_NAME
? `https://cartridge-starknet-react-next-git-${process.env.BRANCH_NAME}.preview.cartridge.gg`
: "https://cartridge-starknet-react-next.preview.cartridge.gg";

export default defineConfig({
testDir: "./tests",
Expand All @@ -8,7 +15,7 @@ export default defineConfig({
retries: process.env.CI ? 2 : 0,
reporter: process.env.CI ? "dot" : "list",
use: {
baseURL: process.env.CI ? KEYCHAIN_URL : "http://localhost:3002",
baseURL: process.env.CI ? CI_BASE_URL : "http://localhost:3002",
trace: "on-first-retry",
},
projects: [
Expand Down
20 changes: 14 additions & 6 deletions examples/starknet-react-next/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use client'
"use client";

import { TransferEth } from "components/TransferEth";
import { ConnectWallet } from "components/ConnectWallet";
Expand All @@ -13,8 +13,8 @@ import { useEffect, useState } from "react";
export default function Home() {
const [debug, setDebug] = useState(false);
useEffect(() => {
setDebug(!!new URLSearchParams(window.location.search).get("debug"))
}, [])
setDebug(!!new URLSearchParams(window.location.search).get("debug"));
}, []);

return (
<div className="flex flex-col p-4 gap-4">
Expand All @@ -28,9 +28,17 @@ export default function Home() {
{debug && (
<div>
<p>Keychain URL: {KEYCHAIN_URL}</p>
<p>NEXT_PUBLIC_VERCEL_ENV: {String(process.env.NEXT_PUBLIC_VERCEL_ENV)}</p>
<p>NEXT_PUBLIC_VERCEL_BRANCH_URL: {String(process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL)}</p>
<p>NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL: {String(process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL)}</p>
<p>
NEXT_PUBLIC_VERCEL_ENV: {String(process.env.NEXT_PUBLIC_VERCEL_ENV)}
</p>
<p>
NEXT_PUBLIC_VERCEL_BRANCH_URL:{" "}
{String(process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL)}
</p>
<p>
NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL:{" "}
{String(process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL)}
</p>
</div>
)}

Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"dependsOn": ["^build:deps"]
},
"e2e:ui": {
"dependsOn": ["^build:deps"],
"persistent": true
"persistent": true,
"dependsOn": ["^build:deps"]
}
}
}

0 comments on commit 38182fa

Please sign in to comment.