From ab3a3b3c764405ccdf4fa91d1727b85107c73ce8 Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Thu, 9 Jan 2025 12:36:32 +0100 Subject: [PATCH] chore: Move playwright tests to tests/local-studio-tests (#21488) * Move the playwright package to tests folder. * Update the workspace list. * Change the name of the playwright tests to local studio tests. --- .../{playwright.yml => local-studio-tests.yml} | 10 ++++++---- package.json | 2 +- pnpm-lock.yaml | 2 +- pnpm-workspace.yaml | 2 +- .../local-studio-tests}/.gitignore | 0 .../local-studio-tests}/README.md | 0 .../local-studio-tests}/package.json | 2 +- .../local-studio-tests}/playwright.config.ts | 4 ++-- .../local-studio-tests}/scripts/generate-env.js | 2 +- .../local-studio-tests}/supabase/.gitignore | 0 .../local-studio-tests}/supabase/config.toml | 2 +- .../local-studio-tests}/supabase/seed.sql | 0 .../tests/snapshot/spec/table-editor.spec.ts | 0 13 files changed, 14 insertions(+), 12 deletions(-) rename .github/workflows/{playwright.yml => local-studio-tests.yml} (81%) rename {playwright-tests => tests/local-studio-tests}/.gitignore (100%) rename {playwright-tests => tests/local-studio-tests}/README.md (100%) rename {playwright-tests => tests/local-studio-tests}/package.json (95%) rename {playwright-tests => tests/local-studio-tests}/playwright.config.ts (97%) rename {playwright-tests => tests/local-studio-tests}/scripts/generate-env.js (97%) rename {playwright-tests => tests/local-studio-tests}/supabase/.gitignore (100%) rename {playwright-tests => tests/local-studio-tests}/supabase/config.toml (99%) rename {playwright-tests => tests/local-studio-tests}/supabase/seed.sql (100%) rename {playwright-tests => tests/local-studio-tests}/tests/snapshot/spec/table-editor.spec.ts (100%) diff --git a/.github/workflows/playwright.yml b/.github/workflows/local-studio-tests.yml similarity index 81% rename from .github/workflows/playwright.yml rename to .github/workflows/local-studio-tests.yml index 015031e3153..9c64715b1e0 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/local-studio-tests.yml @@ -1,14 +1,16 @@ -name: Playwright Tests +name: Local Studio Tests on: push: branches: [master] paths: - 'apps/studio/**' + - 'tests/local-studio-tests/**' - 'pnpm-lock.yaml' pull_request: branches: [master] paths: - 'apps/studio/**' + - 'tests/local-studio-tests/**' - 'pnpm-lock.yaml' # Cancel old builds on new commit for same workflow + branch/PR @@ -37,14 +39,14 @@ jobs: - name: Install dependencies run: pnpm i - name: Install Playwright Browsers - run: pnpm -C playwright-tests exec playwright install --with-deps + run: pnpm -C tests/local-studio-tests exec playwright install --with-deps - name: Run Playwright tests - run: pnpm run test:playwright + run: pnpm test:local-studio # mark the action as succeeded even if the tests failed. This is temporarily until we make the tests more stable. # continue-on-error: true - uses: actions/upload-artifact@v4 if: always() with: name: playwright-report - path: playwright-tests/playwright-report/ + path: tests/local-studio-tests/playwright-report/ retention-days: 7 diff --git a/package.json b/package.json index 20584e4137e..910c69d43fb 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "test:ui-patterns": "turbo run test --filter=ui-patterns", "test:studio": "turbo run test --filter=studio", "test:studio:watch": "turbo run test --filter=studio -- watch", - "test:playwright": "pnpm --prefix playwright-tests run test", + "test:local-studio": "pnpm --prefix tests/local-studio-tests run test", "perf:kong": "ab -t 5 -c 20 -T application/json http://localhost:8000/", "perf:meta": "ab -t 5 -c 20 -T application/json http://localhost:5555/tables", "generate:types": "supabase gen types typescript --local > ./supabase/functions/common/database-types.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5def67e2b75..d73f05dd8ff 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1911,7 +1911,7 @@ importers: specifier: ^2.0.3 version: 2.1.8(@types/node@20.12.11)(jsdom@20.0.3(supports-color@8.1.1))(msw@2.4.11(typescript@5.5.2))(sass@1.72.0)(supports-color@8.1.1)(terser@5.32.0) - playwright-tests: + tests/local-studio-tests: devDependencies: '@playwright/test': specifier: ^1.41.2 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index cb315b73f4c..b5304a2d449 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,7 +1,7 @@ packages: - "apps/*" - "packages/*" - - "playwright-tests" + - "tests/*" catalog: '@types/node': ^20.0.0 diff --git a/playwright-tests/.gitignore b/tests/local-studio-tests/.gitignore similarity index 100% rename from playwright-tests/.gitignore rename to tests/local-studio-tests/.gitignore diff --git a/playwright-tests/README.md b/tests/local-studio-tests/README.md similarity index 100% rename from playwright-tests/README.md rename to tests/local-studio-tests/README.md diff --git a/playwright-tests/package.json b/tests/local-studio-tests/package.json similarity index 95% rename from playwright-tests/package.json rename to tests/local-studio-tests/package.json index 5fae3769ec1..74671d01b25 100644 --- a/playwright-tests/package.json +++ b/tests/local-studio-tests/package.json @@ -1,5 +1,5 @@ { - "name": "playwright-tests", + "name": "local-studio-tests", "version": "1.0.0", "description": "", "main": "index.js", diff --git a/playwright-tests/playwright.config.ts b/tests/local-studio-tests/playwright.config.ts similarity index 97% rename from playwright-tests/playwright.config.ts rename to tests/local-studio-tests/playwright.config.ts index c75031d9658..2568a2cdcee 100644 --- a/playwright-tests/playwright.config.ts +++ b/tests/local-studio-tests/playwright.config.ts @@ -73,8 +73,8 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { // using npm run dev instead of turbo because turbo doesn't stop the server after a test (doesn't handle SIGTERM). - command: 'npm run dev', - cwd: '../apps/studio', + command: 'pnpm dev', + cwd: '../../apps/studio', url: 'http://localhost:8082', reuseExistingServer: !process.env.CI, env: { diff --git a/playwright-tests/scripts/generate-env.js b/tests/local-studio-tests/scripts/generate-env.js similarity index 97% rename from playwright-tests/scripts/generate-env.js rename to tests/local-studio-tests/scripts/generate-env.js index 8c091e98d10..5804e6a5222 100644 --- a/playwright-tests/scripts/generate-env.js +++ b/tests/local-studio-tests/scripts/generate-env.js @@ -30,7 +30,7 @@ const defaultEnv = { const environment = { ...generatedEnv, ...defaultEnv } fs.writeFileSync( - '../apps/studio/.env.test', + '../../apps/studio/.env.test', Object.keys(environment) .map((key) => `${key}=${environment[key]}`) .join('\n') diff --git a/playwright-tests/supabase/.gitignore b/tests/local-studio-tests/supabase/.gitignore similarity index 100% rename from playwright-tests/supabase/.gitignore rename to tests/local-studio-tests/supabase/.gitignore diff --git a/playwright-tests/supabase/config.toml b/tests/local-studio-tests/supabase/config.toml similarity index 99% rename from playwright-tests/supabase/config.toml rename to tests/local-studio-tests/supabase/config.toml index f4c757c0299..82774ab1abb 100644 --- a/playwright-tests/supabase/config.toml +++ b/tests/local-studio-tests/supabase/config.toml @@ -1,6 +1,6 @@ # A string used to distinguish different Supabase projects on the same host. Defaults to the # working directory name when running `supabase init`. -project_id = "playwright-tests" +project_id = "local-studio-tests" [api] enabled = true diff --git a/playwright-tests/supabase/seed.sql b/tests/local-studio-tests/supabase/seed.sql similarity index 100% rename from playwright-tests/supabase/seed.sql rename to tests/local-studio-tests/supabase/seed.sql diff --git a/playwright-tests/tests/snapshot/spec/table-editor.spec.ts b/tests/local-studio-tests/tests/snapshot/spec/table-editor.spec.ts similarity index 100% rename from playwright-tests/tests/snapshot/spec/table-editor.spec.ts rename to tests/local-studio-tests/tests/snapshot/spec/table-editor.spec.ts