From cd5ac89f3432121789f283b5cb66d80a7bb73434 Mon Sep 17 00:00:00 2001 From: Olaf Alders Date: Sat, 3 May 2025 05:22:49 -0400 Subject: [PATCH 1/7] npm install --save-dev @playwright/test --- package-lock.json | 64 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 65 insertions(+) diff --git a/package-lock.json b/package-lock.json index e12d6920ec..6b3be1655e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,6 +28,7 @@ }, "devDependencies": { "@eslint/js": "^9.5.0", + "@playwright/test": "^1.52.0", "eslint": "^9.25.1", "globals": "^16.0.0", "js-beautify": "^1.15.4", @@ -684,6 +685,22 @@ "node": ">=14" } }, + "node_modules/@playwright/test": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.52.0.tgz", + "integrity": "sha512-uh6W7sb55hl7D6vsAeA+V2p5JnlAqzhqFyF0VcJkKZXkgnFcVG9PziERRHQfPLfNGx1C292a4JqbWzhR8L4R1g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.52.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@types/estree": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", @@ -1404,6 +1421,21 @@ "url": "https://github.com/sponsors/isaacs" } }, + "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/glob": { "version": "10.4.5", "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", @@ -2013,6 +2045,38 @@ "node": ">=6" } }, + "node_modules/playwright": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.52.0.tgz", + "integrity": "sha512-JAwMNMBlxJ2oD1kce4KPtMkDeKGHQstdpFPcPH3maElAXon/QZeTvtsfXmTMRyO9TslfoYOXkSsvao2nE1ilTw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.52.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.52.0.tgz", + "integrity": "sha512-l2osTgLXSMeuLZOML9qYODUQoPPnUsKsb5/P6LJ2e6uPKXUdPK5WYhN4z03G+YNbWmGDY4YENauNu4ZKczreHg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", diff --git a/package.json b/package.json index b23cc5da0a..511236c8a7 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "homepage": "https://github.com/metacpan/metacpanweb#readme", "devDependencies": { "@eslint/js": "^9.5.0", + "@playwright/test": "^1.52.0", "eslint": "^9.25.1", "globals": "^16.0.0", "js-beautify": "^1.15.4", From 8046d9252b6d1c9f13fa87f338e7459d9d4d16c9 Mon Sep 17 00:00:00 2001 From: Olaf Alders Date: Sat, 3 May 2025 05:32:58 -0400 Subject: [PATCH 2/7] Add a script to install Playwright --- bin/install-playwright | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 bin/install-playwright diff --git a/bin/install-playwright b/bin/install-playwright new file mode 100755 index 0000000000..4ee76d3fb7 --- /dev/null +++ b/bin/install-playwright @@ -0,0 +1,5 @@ +#!/bin/bash + +set -eu -o pipefail +npm i +npx playwright install --with-deps From c7a9b2fc3af45a705e46ec58f356837f57312634 Mon Sep 17 00:00:00 2001 From: Olaf Alders Date: Sat, 3 May 2025 05:33:42 -0400 Subject: [PATCH 3/7] Add playwright config --- playwright.config.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 playwright.config.ts diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000000..9760fdfdca --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,52 @@ +import { defineConfig, devices } from "@playwright/test"; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: "./e2e", + outputDir: "./playwright/test-results", + /* 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: 0, + /* Opt out of parallel tests on CI. */ + // workers: process.env.CI ? 1 : undefined, + workers: 1, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: [["html", { outputFolder: "./playwright/report" }]], + /* 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://127.0.0.1:8000", + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: "on-first-retry", + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: "chromium", + use: { ...devices["Desktop Chrome"] }, + }, + + // { + // name: 'firefox', + // use: { ...devices['Desktop Firefox'] }, + // }, + // + // { + // name: 'webkit', + // use: { ...devices['Desktop Safari'] }, + // }, + ], +}); From a10e6b95512416022c76a00bb3c1dee78dabb725 Mon Sep 17 00:00:00 2001 From: Olaf Alders Date: Sat, 3 May 2025 05:34:17 -0400 Subject: [PATCH 4/7] Add a very basic Playwright test --- e2e/home.spec.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 e2e/home.spec.ts diff --git a/e2e/home.spec.ts b/e2e/home.spec.ts new file mode 100644 index 0000000000..de6db7db7c --- /dev/null +++ b/e2e/home.spec.ts @@ -0,0 +1,6 @@ +import { test, expect } from '@playwright/test'; + +test('home page', async ({ page }) => { + await page.goto('/'); + await expect(page).toHaveTitle(/Search the CPAN - metacpan.org/, { timeout: 10 }); +}); From 849c37ecdca8caac49cdc74e1d6a89de7f949cfb Mon Sep 17 00:00:00 2001 From: Olaf Alders Date: Sat, 3 May 2025 05:34:31 -0400 Subject: [PATCH 5/7] Add Playwright testing to test workflow --- .github/workflows/test.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0fae0c610b..66c057811d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -62,6 +62,29 @@ jobs: load: true - name: Run Perl tests run: docker run -i ${{ steps.docker-build-test.outputs.imageid }} + playwright: + runs-on: ubuntu-24.04 + name: playwright test + steps: + - uses: actions/checkout@v4 + - name: Build test image + id: docker-build-test + uses: docker/build-push-action@v6 + with: + target: server + push: false + load: true + - name: Run Perl tests + run: > + docker run -d -i -p 8000:80 + ${{ steps.docker-build-test.outputs.imageid }} + - uses: actions/setup-node@v4 + with: + node-version: 22 + - name: Install Playwright Browsers + run: ./bin/install-playwright + - name: Run Playwright tests + run: npx playwright test test: runs-on: ubuntu-24.04 name: Dockerless From 9106894dcf8340445c72de2e91ee7bd4478e12d6 Mon Sep 17 00:00:00 2001 From: Olaf Alders Date: Sat, 3 May 2025 06:11:06 -0400 Subject: [PATCH 6/7] Tidy .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9aa7ed82f0..4a83d65ecc 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ /metacpan_web_local.* /node_modules/ /perltidy.LOG +/playwright /pm_to_blib /tidyall.ERR /var From 364d5ae2b9a6f067159fded60bf9d9bcfc5ef07e Mon Sep 17 00:00:00 2001 From: Olaf Alders Date: Sat, 3 May 2025 06:38:06 -0400 Subject: [PATCH 7/7] Install only Chromium for now --- bin/install-playwright | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install-playwright b/bin/install-playwright index 4ee76d3fb7..f1cc458308 100755 --- a/bin/install-playwright +++ b/bin/install-playwright @@ -2,4 +2,4 @@ set -eu -o pipefail npm i -npx playwright install --with-deps +npx playwright install chromium --with-deps