From 907e977fe7d1b13303984211767b5182c54f3b96 Mon Sep 17 00:00:00 2001 From: Carsten Bach Date: Thu, 22 Aug 2024 14:54:15 +0200 Subject: [PATCH] TRY FIX // webkit // Gutenberg: "Headless webkit won't receive dataTransfer with custom types in the drop event on Linux. The solution is to use `xvfb-run` to run the tests." --- .github/workflows/e2e-tests.yml | 27 ++++++++++++++++++--- test/e2e/playwright.config.ts | 42 +++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 16 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index de067bfac..3853ac5db 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -79,11 +79,32 @@ jobs: - run: npx playwright install-deps if: steps.playwright-cache.outputs.cache-hit == 'true' - - name: Starting Playwright & Running the tests + # - name: Starting Playwright & Running the tests + # env: + # WP_BASE_URL: 'http://127.0.0.1:9400' + # run: | + # npm run test:e2e + + # - name: Run the tests + # env: + # WP_BASE_URL: 'http://127.0.0.1:9400' + # PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 + # run: | + # xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test:e2e + + + - name: Start the server + run: | + npm run playground -- & + + - name: Run the tests env: - WP_BASE_URL: 'http://127.0.0.1:9400' + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 run: | - npm run test:e2e + WP_BASE_URL=http://127.0.0.1:9400/ \ + xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- \ + npm run test:e2e + - name: Retain failed test results uses: actions/upload-artifact@v4 diff --git a/test/e2e/playwright.config.ts b/test/e2e/playwright.config.ts index 701358f3a..f9f701baf 100644 --- a/test/e2e/playwright.config.ts +++ b/test/e2e/playwright.config.ts @@ -1,6 +1,7 @@ /** * External dependencies */ +import os from 'os'; import { defineConfig, devices } from '@playwright/test'; /** @@ -39,7 +40,18 @@ export default defineConfig({ { name: 'webkit', - use: { ...devices['Desktop Safari'] }, + use: { + ...devices[ 'Desktop Safari' ], + /** + * Headless webkit won't receive dataTransfer with custom types in the + * drop event on Linux. The solution is to use `xvfb-run` to run the tests. + * ```sh + * xvfb-run npm run test:e2e + * ``` + * See `.github/workflows/e2e-tests.yml` for advanced usages. + */ + headless: os.type() !== 'Linux', + }, }, /* Test against mobile viewports. */ @@ -64,16 +76,20 @@ export default defineConfig({ ], // Don't report slow test "files", as we will be running our tests in serial. reportSlowTests: null, - webServer: { - ...baseConfig.webServer, - command: 'set WP_BASE_URL=http://127.0.0.1:9400/ && npm run playground', - // timeout: 180_000, // 180 seconds. - port: 9400, - reuseExistingServer: !process.env.CI, - }, - use: { - ...baseConfig.use, - baseURL: 'http://127.0.0.1:9400', - actionTimeout: 15_000, // 10 seconds +5 seconds to help webkit tests pass. - }, + // webServer: { + // ...baseConfig.webServer, + // command: 'set WP_BASE_URL=http://127.0.0.1:9400/ && npm run playground', + // // timeout: 180_000, // 180 seconds. + // port: 9400, + // reuseExistingServer: !process.env.CI, + // // reuseExistingServer: true, + // // reuseExistingServer: false, + // }, + // use: { + // ...baseConfig.use, + // baseURL: 'http://127.0.0.1:9400', + // actionTimeout: 15_000, // 10 seconds +5 seconds to help webkit tests pass. + // }, + retries: 0, + webServer: undefined, });