diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3000d9..27e2afa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,28 +19,41 @@ jobs: with: fetch-depth: 2 - # 1️⃣ Upgrade to Node 22 (Required for MCP) + # 1 Upgrade to Node 22 (Required for MCP) - name: Setup Node.js 22 uses: actions/setup-node@v4 with: node-version: 22 cache: "npm" - # 2️⃣ Install Dependencies (With Dummy Env) + # 2 Install Dependencies (With Dummy Env) - name: Install Dependencies run: npm ci env: DATABASE_URL: "postgresql://dummy:password@localhost:5432/mydb" BETTER_AUTH_SECRET: "dummy_secret_for_install" - # 3️⃣ Generate Prisma Client (Direct Command) + # 3 Generate Prisma Client (Direct Command) # ⚠️ FIX: We run prisma directly here instead of via Turbo - name: Generate Prisma Client run: npx prisma generate --schema=apps/api/prisma/schema.prisma env: DATABASE_URL: "postgresql://dummy:password@localhost:5432/mydb" - # 4️⃣ Run Turbo Pipeline (Build & Lint only) + # 4 e2e Tests + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright Tests + run: npx playwright test + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 + + + # 5 Run Turbo Pipeline (Build & Lint only) - name: Run Turbo Pipeline # ⚠️ FIX: Pass DATABASE_URL directly in the command line run: DATABASE_URL="postgresql://dummy:password@localhost:5432/mydb" npx turbo run build lint diff --git a/.gitignore b/.gitignore index ee99180..6a419e3 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,10 @@ build/ #turbo repo .turbo + +# Playwright +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ +/playwright/.auth/ diff --git a/package-lock.json b/package-lock.json index 17f5a83..ca437a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,8 @@ ], "devDependencies": { "@changesets/cli": "^2.27.0", + "@playwright/test": "^1.58.0", + "@types/node": "^25.0.10", "prettier": "^3.0.0", "turbo": "^2.3.0" } @@ -4096,6 +4098,22 @@ "node": ">=14" } }, + "node_modules/@playwright/test": { + "version": "1.58.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.58.0.tgz", + "integrity": "sha512-fWza+Lpbj6SkQKCrU6si4iu+fD2dD3gxNHFhUPxsfXBPhnv3rRSQVd0NtBUT9Z/RhF/boCBcuUaMUSTRTopjZg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.58.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@posthog/core": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/@posthog/core/-/core-1.11.0.tgz", @@ -6658,9 +6676,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "25.0.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.3.tgz", - "integrity": "sha512-W609buLVRVmeW693xKfzHeIV6nJGGz98uCPfeXI1ELMLXVeKYZ9m15fAMSaUPBHYLGFsVRcMmSCksQOrZV9BYA==", + "version": "25.0.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.0.10.tgz", + "integrity": "sha512-zWW5KPngR/yvakJgGOmZ5vTBemDoSqF3AcV/LrO5u5wTWyEAVVh+IT39G4gtyAkh3CtTZs8aX/yRM82OfzHJRg==", "license": "MIT", "dependencies": { "undici-types": "~7.16.0" @@ -14309,6 +14327,53 @@ "pathe": "^2.0.3" } }, + "node_modules/playwright": { + "version": "1.58.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.58.0.tgz", + "integrity": "sha512-2SVA0sbPktiIY/MCOPX8e86ehA/e+tDNq+e5Y8qjKYti2Z/JG7xnronT/TXTIkKbYGWlCbuucZ6dziEgkoEjQQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.58.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.58.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.58.0.tgz", + "integrity": "sha512-aaoB1RWrdNi3//rOeKuMiS65UCcgOVljU46At6eFcOFPFHWtd2weHRRow6z/n+Lec0Lvu0k9ZPKJSjPugikirw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/points-on-curve": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/points-on-curve/-/points-on-curve-0.2.0.tgz", diff --git a/package.json b/package.json index 5a22724..0a88702 100644 --- a/package.json +++ b/package.json @@ -12,18 +12,22 @@ "lint": "turbo lint", "clean": "turbo clean", "format": "prettier --write \"**/*.{ts,tsx,md}\"", + "test:e2e": "npx playwright test", + "test:e2e:watch": "npx playwright test --watch", + "show-report:e2e": "npx playwright show-report", "changeset": "changeset", "version-packages": "changeset version", "publish-packages": "changeset publish" }, "devDependencies": { - "turbo": "^2.3.0", "@changesets/cli": "^2.27.0", - "prettier": "^3.0.0" - } - , + "@playwright/test": "^1.58.0", + "@types/node": "^25.0.10", + "prettier": "^3.0.0", + "turbo": "^2.3.0" + }, "overrides": { "react": "19.2.3", "react-dom": "19.2.3" } -} \ No newline at end of file +} diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000..1169a89 --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,94 @@ +import { defineConfig, devices } from '@playwright/test'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// import dotenv from 'dotenv'; +// import path from 'path'; +// dotenv.config({ path: path.resolve(__dirname, '.env') }); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: './tests', + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'html', + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Base URL to use in actions like `await page.goto('')`. */ + baseURL: 'http://localhost:3000', + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace:'on', + video: 'on', + screenshot: 'only-on-failure', + connectOptions: process.env.CI ? undefined : { + wsEndpoint: 'ws://127.0.0.1:3000/', + }, + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'API', + testDir: './tests/api', + use:{ + + } + }, + { + name: 'web-chrome', + testDir: './tests/web', + use: { ...devices['Desktop Chrome'] }, + }, + + { + name: 'web-firefox', + testDir: './tests/web', + use: { ...devices['Desktop Firefox'] }, + }, + + { + name: 'web-webkit', + testDir: './tests/web', + use: { ...devices['Desktop Safari'] }, + }, + + /* Test against mobile viewports. */ + // { + // name: 'Mobile Chrome', + // use: { ...devices['Pixel 5'] }, + // }, + // { + // name: 'Mobile Safari', + // use: { ...devices['iPhone 12'] }, + // }, + + /* Test against branded browsers. */ + // { + // name: 'Microsoft Edge', + // use: { ...devices['Desktop Edge'], channel: 'msedge' }, + // }, + // { + // name: 'Google Chrome', + // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, + // }, + ], + + /* Run your local dev server before starting the tests */ + // webServer: { + // command: 'npm run start', + // url: 'http://localhost:3000', + // reuseExistingServer: !process.env.CI, + // }, +});