diff --git a/.github/workflows/buildAndDeploy.yml b/.github/workflows/buildAndDeploy.yml index 4acbc2e..0e00e9b 100644 --- a/.github/workflows/buildAndDeploy.yml +++ b/.github/workflows/buildAndDeploy.yml @@ -4,7 +4,7 @@ on: push: branches: - master - workflow_dispatch: {} + workflow_dispatch: { } jobs: build_and_deploy: @@ -13,6 +13,9 @@ jobs: group: build-and-deploy cancel-in-progress: true runs-on: ubuntu-24.04 + env: + # https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/ + FORCE_JAVASCRIPT_ACTIONS_TO_NODE20: true steps: - uses: actions/checkout@v3 @@ -43,7 +46,7 @@ jobs: run: npx playwright install --with-deps - name: Run e2e tests - run: npm run test:e2e + run: PLAYWRIGHT_USE_BUILD=1 npm run test:e2e - name: Deploy uses: peaceiris/actions-gh-pages@v3 diff --git a/.github/workflows/checkPullRequests.yml b/.github/workflows/checkPullRequests.yml index f993848..a6ff738 100644 --- a/.github/workflows/checkPullRequests.yml +++ b/.github/workflows/checkPullRequests.yml @@ -2,7 +2,7 @@ name: "Check Pull Requests" on: pull_request: - types: ["opened", "edited", "reopened", "synchronize"] + types: [ "opened", "edited", "reopened", "synchronize" ] jobs: check_pull_request: @@ -11,6 +11,9 @@ jobs: group: ${{ github.head_ref }} cancel-in-progress: true runs-on: ubuntu-24.04 + env: + # https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/ + FORCE_JAVASCRIPT_ACTIONS_TO_NODE20: true steps: - uses: actions/checkout@v3 @@ -38,4 +41,4 @@ jobs: run: npx playwright install --with-deps - name: Run e2e tests - run: PLAYWRIGHT_DEV_SERVER=1 npm run test:e2e + run: npm run test:e2e diff --git a/.github/workflows/makeArtifactWithTestScreenshots.yml b/.github/workflows/makeArtifactWithTestScreenshots.yml index 8c03fd5..8f4f339 100644 --- a/.github/workflows/makeArtifactWithTestScreenshots.yml +++ b/.github/workflows/makeArtifactWithTestScreenshots.yml @@ -6,6 +6,9 @@ jobs: make_artifact_with_test_screenshots: name: Make artifact with Test Screenshots runs-on: ubuntu-24.04 + env: + # https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/ + FORCE_JAVASCRIPT_ACTIONS_TO_NODE20: true steps: - uses: actions/checkout@v3 @@ -20,8 +23,8 @@ jobs: - name: Install Playwright Browsers run: npx playwright install --with-deps - - name: Run e2e tests - run: PLAYWRIGHT_DEV_SERVER=1 npm run test:e2e:update-snapshots + - name: Run e2e tests with snapshots update + run: npm run test:e2e:update-snapshots - name: Upload test screenshots uses: actions/upload-artifact@v4 diff --git a/playwright.config.ts b/playwright.config.ts index a6abdc6..1e261d9 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,11 +1,7 @@ import type { PlaywrightTestConfig } from "@playwright/test"; import { devices } from "@playwright/test"; -/** - * Read environment variables from file. - * https://github.com/motdotla/dotenv - */ -// require('dotenv').config(); +const useExistedBuild = !!process.env.PLAYWRIGHT_USE_BUILD; /** * See https://playwright.dev/docs/test-configuration. @@ -63,39 +59,8 @@ const config: PlaywrightTestConfig = { ...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: { - // channel: 'msedge', - // }, - // }, - // { - // name: 'Google Chrome', - // use: { - // channel: 'chrome', - // }, - // }, ], - /* Folder for test artifacts such as screenshots, videos, traces, etc. */ - // outputDir: 'test-results/', - /* Run your local dev server before starting the tests */ webServer: { /** @@ -103,12 +68,9 @@ const config: PlaywrightTestConfig = { * Use the preview server on CI for more realistic testing. Playwright will re-use the local server if there is already a dev-server running. */ - command: - process.env.CI && !process.env.PLAYWRIGHT_DEV_SERVER - ? "vite preview --port 5173" - : "vite dev", + command: useExistedBuild ? "vite preview --port 5173" : "vite dev", port: 5173, - reuseExistingServer: !process.env.CI || !!process.env.PLAYWRIGHT_DEV_SERVER, + reuseExistingServer: useExistedBuild, }, }; diff --git a/vite.config.mts b/vite.config.mts index cb70c4c..1e781e9 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -13,7 +13,7 @@ export default defineConfig({ outlierSupport: ["vue"], }, policy: { - "style-src": ["'unsafe-inline'"], // todo remove when naive-ui will be fixed + "style-src": ["'self'", "'unsafe-inline'"], // todo remove when naive-ui will be fixed "style-src-elem": ["'unsafe-inline'"], // todo remove when naive-ui will be fixed "img-src": ["data:", "blob:"], "script-src": ["'wasm-unsafe-eval'"],