From 625c89e37f2c1b6827cf5d7a2759077e5d83fff1 Mon Sep 17 00:00:00 2001 From: Sam Lord Date: Thu, 12 Sep 2024 15:55:47 +0100 Subject: [PATCH] Added the ability to run browser tests using local Portal (#20990) ref DOGM-32 Using the dev script as a template, this script runs the tests with local copies of the applications needed instead of the released CDN versions --- .github/scripts/dev.js | 10 ++++++++++ .github/workflows/ci.yml | 1 - package.json | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/scripts/dev.js b/.github/scripts/dev.js index 83c9f30c95..573ede8fa8 100644 --- a/.github/scripts/dev.js +++ b/.github/scripts/dev.js @@ -58,6 +58,14 @@ const COMMAND_ADMIN = { env: {} }; +const COMMAND_BROWSERTESTS = { + name: 'browser-tests', + command: 'nx run ghost:test:browser', + cwd: path.resolve(__dirname, '../../ghost/core'), + prefixColor: 'blue', + env: {} +}; + const COMMAND_TYPESCRIPT = { name: 'ts', command: `while [ 1 ]; do nx watch --projects=${tsPackages} -- nx run \\$NX_PROJECT_NAME:build:ts; done`, @@ -86,6 +94,8 @@ if (DASH_DASH_ARGS.includes('ghost')) { commands = [COMMAND_GHOST, COMMAND_TYPESCRIPT]; } else if (DASH_DASH_ARGS.includes('admin')) { commands = [COMMAND_ADMIN, ...COMMANDS_ADMINX]; +} else if (DASH_DASH_ARGS.includes('browser-tests')) { + commands = [COMMAND_BROWSERTESTS, COMMAND_TYPESCRIPT]; } else { commands = [COMMAND_GHOST, COMMAND_TYPESCRIPT, COMMAND_ADMIN, ...COMMANDS_ADMINX]; } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e09d3b804c..74328bab4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -343,7 +343,6 @@ jobs: run: yarn nx run ghost-admin:build:dev - name: Run Playwright tests locally - working-directory: ghost/core run: yarn test:browser env: CI: true diff --git a/package.json b/package.json index 08045561cd..b20c4e289e 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "lint": "nx run-many -t lint", "test": "nx run-many -t test", "test:unit": "nx run-many -t test:unit", + "test:browser": "node .github/scripts/dev.js --browser-tests --all", "main": "yarn main:monorepo && yarn main:submodules", "main:monorepo": "git checkout main && git pull ${GHOST_UPSTREAM:-origin} main && yarn", "main:submodules": "git submodule sync && git submodule update && git submodule foreach \"git checkout main && git pull ${GHOST_UPSTREAM:-origin} main\"",