diff --git a/.github/actions/playwright-atomic/action.yml b/.github/actions/playwright-atomic/action.yml new file mode 100644 index 00000000000..5350cef54a9 --- /dev/null +++ b/.github/actions/playwright-atomic/action.yml @@ -0,0 +1,18 @@ +name: 'Playwright Atomic' +description: 'Run Playwright tests for Atomic' +runs: + using: composite + steps: + - name: Install Playwright Browsers + run: npx playwright install --with-deps + shell: bash + - name: Run Playwright tests + run: npx playwright test + working-directory: packages/atomic + shell: bash + - uses: actions/upload-artifact@v4 + if: always() + with: + name: atomic-playwright-report + path: packages/atomic/playwright-report/ + retention-days: 30 diff --git a/.github/actions/publish-pr-review-site/action.yml b/.github/actions/publish-pr-review-site/action.yml index dc139eab6fc..7d75f0ecad8 100644 --- a/.github/actions/publish-pr-review-site/action.yml +++ b/.github/actions/publish-pr-review-site/action.yml @@ -38,6 +38,7 @@ runs: if: ${{inputs.copy}} run: | cp -R packages/atomic/dist-storybook prs/${{github.event.pull_request.number}} + cp -R packages/atomic/playwright-report prs/${{github.event.pull_request.number}} shell: bash - name: 'Commit/Push' run: | diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml deleted file mode 100644 index d1f2bf18042..00000000000 --- a/.github/workflows/playwright.yml +++ /dev/null @@ -1,29 +0,0 @@ -#TODO: Merge into ci. - -name: Playwright Tests -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] -jobs: - test: - timeout-minutes: 60 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: lts/* - - name: Install dependencies - run: npm ci - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - name: Run Playwright tests - run: npx playwright test - - uses: actions/upload-artifact@v4 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 diff --git a/.github/workflows/prbot.yml b/.github/workflows/prbot.yml index 4d460b776db..51d5fa6a702 100644 --- a/.github/workflows/prbot.yml +++ b/.github/workflows/prbot.yml @@ -29,11 +29,6 @@ jobs: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 - uses: ./.github/actions/build - uses: ./.github/actions/commit-generated-files - - uses: ./.github/actions/publish-pr-review-site - if: github.event_name == 'pull_request' - with: - token: ${{ secrets.GH_PUBLISH_TOKEN }} - copy: true lint-check: name: 'Check with linter' needs: build @@ -58,6 +53,19 @@ jobs: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 - uses: ./.github/actions/setup - uses: ./.github/actions/e2e-atomic-csp + playwright-atomic: + name: 'Run Playwright tests for Atomic' + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 + - uses: ./.github/actions/setup + - uses: ./.github/actions/playwright-atomic + - uses: ./.github/actions/publish-pr-review-site + if: ${{ always() && github.event_name == 'pull_request'}} + with: + token: ${{ secrets.GH_PUBLISH_TOKEN }} + copy: true e2e-atomic-test: name: 'Run e2e tests on Atomic' needs: build @@ -268,6 +276,7 @@ jobs: - 'build' - 'lint-check' - 'unit-test' + - 'playwright-atomic' - 'e2e-atomic-test' - 'e2e-atomic-csp-test' - 'e2e-quantic' @@ -302,6 +311,7 @@ jobs: - 'build' - 'lint-check' - 'unit-test' + - 'playwright-atomic' - 'e2e-atomic-test' - 'e2e-atomic-screenshots' - 'e2e-atomic-react-test' diff --git a/packages/atomic/playwright.config.ts b/packages/atomic/playwright.config.ts index 60eca7d7cdb..83693229573 100644 --- a/packages/atomic/playwright.config.ts +++ b/packages/atomic/playwright.config.ts @@ -1,42 +1,23 @@ import {defineConfig, devices} from '@playwright/test'; -/** - * Read environment variables from file. - * https://github.com/motdotla/dotenv - */ -// require('dotenv').config(); - const DEFAULT_DESKTOP_VIEWPORT = { width: 1920, height: 1080, }; -/** - * See https://playwright.dev/docs/test-configuration. - */ export default defineConfig({ testDir: './src', testMatch: '*.e2e.ts', - /* 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. */ + reporter: process.env.CI + ? [['html'], ['list'], ['github']] + : [['html'], ['list']], use: { - /* Base URL to use in actions like `await page.goto('/')`. */ - // baseURL: 'http://127.0.0.1:3000', - - /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ - trace: 'on-first-retry', + trace: 'retain-on-failure', }, - - /* Configure projects for major browsers */ projects: [ { name: 'chromium', @@ -45,36 +26,14 @@ export default defineConfig({ viewport: DEFAULT_DESKTOP_VIEWPORT, }, }, - { name: 'firefox', use: {...devices['Desktop Firefox'], viewport: DEFAULT_DESKTOP_VIEWPORT}, }, - { name: 'webkit', use: {...devices['Desktop Safari'], viewport: DEFAULT_DESKTOP_VIEWPORT}, }, - - /* 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' }, - // }, ], expect: { timeout: 20 * 1000, diff --git a/scripts/reports/live-examples/live-examples.mjs b/scripts/reports/live-examples/live-examples.mjs index 353df1c1033..fac6260c041 100644 --- a/scripts/reports/live-examples/live-examples.mjs +++ b/scripts/reports/live-examples/live-examples.mjs @@ -4,4 +4,5 @@ export const buildLiveExampleReport = async () => [ '## Live demo links', `* [Storybook](https://coveo.github.io/ui-kit-prs/${context.payload.pull_request.number}/dist-storybook/)`, + `* [Playwright report](https://coveo.github.io/ui-kit-prs/${context.payload.pull_request.number}/playwright-report/)`, ].join('\n\n');