mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Added CI for running Playwright tests
🚧
This commit is contained in:
parent
668e523ab4
commit
bc0b1f6adc
5 changed files with 32 additions and 10 deletions
22
.github/workflows/browser-tests.yml
vendored
22
.github/workflows/browser-tests.yml
vendored
|
@ -1,15 +1,20 @@
|
|||
name: Browser Tests
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
site_url:
|
||||
description: 'Site URL to test'
|
||||
required: true
|
||||
description: 'Site URL to test, or blank for local'
|
||||
required: false
|
||||
type: string
|
||||
jobs:
|
||||
test:
|
||||
timeout-minutes: 60
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'renovate/'))
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ghost/core
|
||||
|
@ -20,12 +25,25 @@ jobs:
|
|||
node-version: '16.x'
|
||||
cache: yarn
|
||||
|
||||
- name: Install Stripe-CLI
|
||||
run: |
|
||||
export VERSION=1.13.5
|
||||
wget "https://github.com/stripe/stripe-cli/releases/download/v$VERSION/stripe_${VERSION}_linux_x86_64.tar.gz"
|
||||
tar -zxvf "stripe_${VERSION}_linux_x86_64.tar.gz"
|
||||
mv stripe /usr/local/bin
|
||||
stripe -v
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Install Playwright
|
||||
run: npx playwright install --with-deps
|
||||
|
||||
- name: Build Admin
|
||||
if: github.event.inputs.site_url == ''
|
||||
working-directory: ghost/admin
|
||||
run: yarn build:prod
|
||||
|
||||
- name: Run Playwright tests
|
||||
run: yarn test:browser
|
||||
env:
|
||||
|
|
3
ghost/core/.gitignore
vendored
3
ghost/core/.gitignore
vendored
|
@ -135,3 +135,6 @@ test/coverage
|
|||
|
||||
# Caddyfile - for local development with ssl + caddy
|
||||
Caddyfile
|
||||
|
||||
# Playwright state with cookies it keeps across tests
|
||||
playwright-state.json
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"test:integration": "mocha --require=./test/utils/overrides.js --exit --trace-warnings --recursive --extension=test.js './test/integration' --timeout=10000",
|
||||
"test:e2e": "mocha --require=./test/utils/overrides.js --exit --trace-warnings --recursive --extension=test.js './test/e2e-api' './test/e2e-frontend' './test/e2e-server' './test/e2e-webhooks' --timeout=15000",
|
||||
"test:regression": "mocha --require=./test/utils/overrides.js --exit --trace-warnings --recursive --extension=test.js './test/regression' --timeout=60000",
|
||||
"test:browser": "NODE_ENV=development playwright test --browser=chromium test/e2e-browser",
|
||||
"test:browser": "playwright test test/e2e-browser",
|
||||
"test:browser:record": "NODE_ENV=development yarn start record-test",
|
||||
"test:ci": "c8 -c ./.c8rc.e2e.json yarn test:ci:base",
|
||||
"test:ci:base": "yarn test:e2e -b && yarn test:integration -b && yarn test:regression -b",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const {execSync} = require('child_process');
|
||||
|
||||
const getWebhookSecret = () => {
|
||||
const webhookSecret = execSync('stripe listen --print-secret');
|
||||
const webhookSecret = execSync(`stripe listen --print-secret --api-key ${process.env.STRIPE_API_KEY}`);
|
||||
return webhookSecret.toString().trim();
|
||||
};
|
||||
|
||||
|
@ -13,9 +13,10 @@ const config = {
|
|||
use: {
|
||||
// Use a single browser since we can't simultaneously test multiple browsers
|
||||
browserName: 'chromium',
|
||||
headless: !process.env.PLAYWRIGHT_DEBUG,
|
||||
baseURL: process.env.TEST_URL ?? 'http://localhost:2368',
|
||||
// TODO: Where to put this
|
||||
storageState: 'state.json'
|
||||
storageState: 'playwright-state.json'
|
||||
},
|
||||
globalSetup: './test/e2e-browser/utils/global-setup'
|
||||
};
|
||||
|
|
|
@ -15,15 +15,15 @@ const setupStripeKeys = async () => {
|
|||
const stripeDatabaseKeys = {
|
||||
publishableKey: 'stripe_connect_publishable_key',
|
||||
secretKey: 'stripe_connect_secret_key',
|
||||
testMode: 'stripe_connect_test_mode'
|
||||
liveMode: 'stripe_connect_livemode'
|
||||
};
|
||||
const publishableKey = (await knex('settings').select('value').where('key', stripeDatabaseKeys.publishableKey).first())?.value
|
||||
const publishableKey = process.env.STRIPE_PUBLISHABLE_KEY ?? (await knex('settings').select('value').where('key', stripeDatabaseKeys.publishableKey).first())?.value
|
||||
?? (await inquirer.prompt([{
|
||||
message: 'Stripe publishable key (starts "pk_test_")',
|
||||
type: 'password',
|
||||
name: 'value'
|
||||
}])).value;
|
||||
const secretKey = (await knex('settings').select('value').where('key', stripeDatabaseKeys.secretKey).first())?.value
|
||||
const secretKey = process.env.STRIPE_SECRET_KEY ?? (await knex('settings').select('value').where('key', stripeDatabaseKeys.secretKey).first())?.value
|
||||
?? (await inquirer.prompt([{
|
||||
message: 'Stripe secret key (starts "sk_test_")',
|
||||
type: 'password',
|
||||
|
@ -37,8 +37,8 @@ const setupStripeKeys = async () => {
|
|||
await knex('settings').where('key', stripeDatabaseKeys.secretKey).update({
|
||||
value: secretKey
|
||||
});
|
||||
await knex('settings').where('key', stripeDatabaseKeys.testMode).update({
|
||||
value: `${true}`
|
||||
await knex('settings').where('key', stripeDatabaseKeys.liveMode).update({
|
||||
value: `false`
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue