Skip to content

Commit

Permalink
Use playwright for e2e testing in event schedule app (#1412)
Browse files Browse the repository at this point in the history
  • Loading branch information
noshiro-pf authored Jan 21, 2025
1 parent 78bf820 commit 5035cd2
Show file tree
Hide file tree
Showing 70 changed files with 848 additions and 623 deletions.
45 changes: 13 additions & 32 deletions .github/workflows/e2e-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,9 @@ jobs:
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

cypress-run-event-schedule-app:
e2e-event-schedule-app:
timeout-minutes: 30
runs-on: ubuntu-latest
container:
image: cypress/browsers:node-20.14.0-chrome-126.0.6478.114-1-ff-127.0.1-edge-126.0.2592.61-1
options: --user 1001

steps:
- uses: actions/[email protected]

Expand All @@ -117,14 +114,12 @@ jobs:
cache: 'yarn'
cache-dependency-path: yarn.lock

# Set up GitHub Actions caching for Wireit.
# - uses: google/wireit@setup-github-actions-caching/v1.0.2

# - run: echo '${{ toJSON(steps.setup_node_id.outputs) }}'
# - if: ${{ steps.setup_node_id.outputs.cache-hit != 'true' }}
- name: yarn install
run: yarn --frozen-lockfile

- name: Install Playwright Browsers
run: yarn playwright install --with-deps

- name: Build dependencies
run: yarn zz:wsrun-stages --recursive -p @noshiro/event-schedule-app -c build

Expand All @@ -134,26 +129,12 @@ jobs:
# - name: create runtimeconfig
# run: yarn workspace @noshiro/event-schedule-app z:setup:fb:emulators:gen-dummy-runtimeconfig

- name: Cypress run on Chrome
uses: cypress-io/[email protected]
- name: Run Playwright tests
run: yarn workspace @noshiro/event-schedule-app e2e

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
# group: 'UI - Chrome'
browser: chrome
install: false
working-directory: packages/apps/event-schedule-app/cypress
# spec: cypress/e2e/**/*.cy.ts
spec: cypress/e2e/display-create-event-page.cy.ts
start: |
yarn start:emulators:e2e
yarn start:dev-server
# wait-on: 'http://localhost:8080, http://localhost:8081, http://localhost:5001'
wait-on: 'http://[::1]:5180'
wait-on-timeout: 120
# headless: true
# record: true
# parallel: true
env:
# CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY_FOR_EVENT_SCHEDULE_APP }}
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: playwright-report
path: packages/apps/event-schedule-app/playwright-report/
retention-days: 30
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,10 @@ build/Release
*.sw?

rollup.config-*.mjs

# playwright

**/test-results/
**/playwright-report/
**/blob-report/
**/playwright/.cache/
89 changes: 89 additions & 0 deletions configs/define-playwright-config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { castMutable } from '@noshiro/mono-utils';
import { defineConfig, devices } from '@playwright/test';

/** Read environment variables from file. https://github.com/motdotla/dotenv */
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/** See https://playwright.dev/docs/test-configuration. */
export const definePlaywrightConfig = ({
baseURL,
testDir,
webServer,
}: Readonly<{
baseURL: string;
testDir: string;
// webServer?: readonly PlaywrightTestConfig['webServer'][];
webServer?: readonly Readonly<{ command: string; url: string }>[];
}>) =>
defineConfig({
testDir,
/* 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'] !== undefined,
/* Retry on CI only */
retries: process.env['CI'] !== undefined ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env['CI'] !== undefined ? 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. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL,

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',

testIdAttribute: 'data-e2e',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* 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' },
// },
],

/* Run your local dev server before starting the tests */
webServer: castMutable(
webServer?.map(({ url, command }) => ({
url,
command,
reuseExistingServer: process.env['CI'] === undefined,
})) ?? [],
),
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@
"@google/clasp": "^2.4.2",
"@mdx-js/rollup": "^3.1.0",
"@noshiro/strict-typescript-lib-branded": "*",
"@playwright/test": "^1.49.1",
"@preact/preset-vite": "^2.9.2",
"@rollup/plugin-inject": "^5.0.5",
"@rollup/plugin-replace": "^6.0.2",
"@rollup/plugin-typescript": "^12.1.2",
"@types/argparse": "^2.0.16",
"@types/google-apps-script": "^1.0.83",
"@types/jest": "^29.5.12",
"@types/node": "22.7",
"@types/node": "^22.10.6",
"@types/nodemailer": "^6.4.4",
"@types/react": "^18.2.61",
"@types/react-dom": "^18.3.1",
Expand Down
14 changes: 7 additions & 7 deletions packages/apps/algo-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"fb:login:ci": "firebase login:ci",
"fmt": "yarn zz:prettier .",
"gi": "bash ../../../scripts/bash/index_ts_generator.sh ./src --min-depth 1 --ignore assets",
"lint": "run-p lint:src lint:cy",
"lint:cy": "yarn zz:eslint:cy",
"lint:fix": "run-p lint:fix:src lint:fix:cy",
"lint:fix:cy": "yarn zz:eslint:cy --fix",
"lint": "run-p lint:src lint:e2e",
"lint:e2e": "yarn zz:eslint:e2e",
"lint:fix": "run-p lint:fix:src lint:fix:e2e",
"lint:fix:e2e": "yarn zz:eslint:e2e --fix",
"lint:fix:src": "yarn zz:eslint:src --fix",
"lint:src": "yarn zz:eslint:src",
"preview": "yarn zz:vite:preview",
Expand All @@ -40,13 +40,13 @@
"testw": "yarn zz:vitest watch",
"tsc": "yarn type-check",
"tscw": "tsc --noEmit --watch",
"type-check": "run-p type-check:src type-check:cy",
"type-check:cy": "tsc --noEmit -p ./cypress/tsconfig.json",
"type-check": "run-p type-check:src type-check:e2e",
"type-check:e2e": "tsc --noEmit -p ./cypress/tsconfig.json",
"type-check:src": "wireit",
"z:setup": "run-p z:setup:gen-global-dts",
"z:setup:gen-global-dts": "node ./scripts/gen-global-dts.mjs",
"zz:eslint": "ESLINT_USE_FLAT_CONFIG=true TIMING=1 eslint",
"zz:eslint:cy": "yarn zz:eslint --config ./cypress/eslint.config.js './cypress/**/*.ts'",
"zz:eslint:e2e": "yarn zz:eslint --config ./cypress/eslint.config.js './cypress/**/*.ts'",
"zz:eslint:print-config": "yarn zz:eslint --print-config src/main.tsx",
"zz:eslint:src": "yarn zz:eslint --config eslint.config.js './src/**/*'",
"zz:prettier": "prettier --cache --cache-strategy content --ignore-path ../../../.prettierignore --write",
Expand Down
14 changes: 7 additions & 7 deletions packages/apps/annotation-tool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"fb:login:ci": "firebase login:ci",
"fmt": "yarn zz:prettier .",
"gi": "bash ../../../scripts/bash/index_ts_generator.sh ./src --min-depth 1 --ignore assets",
"lint": "run-p lint:src lint:cy",
"lint:cy": "yarn zz:eslint:cy",
"lint:fix": "run-p lint:fix:src lint:fix:cy",
"lint:fix:cy": "yarn zz:eslint:cy --fix",
"lint": "run-p lint:src lint:e2e",
"lint:e2e": "yarn zz:eslint:e2e",
"lint:fix": "run-p lint:fix:src lint:fix:e2e",
"lint:fix:e2e": "yarn zz:eslint:e2e --fix",
"lint:fix:src": "yarn zz:eslint:src --fix",
"lint:src": "yarn zz:eslint:src",
"preview": "yarn zz:vite:preview",
Expand All @@ -40,13 +40,13 @@
"testw": "yarn zz:vitest watch",
"tsc": "yarn type-check",
"tscw": "tsc --noEmit --watch",
"type-check": "run-p type-check:src type-check:cy",
"type-check:cy": "tsc --noEmit -p ./cypress/tsconfig.json",
"type-check": "run-p type-check:src type-check:e2e",
"type-check:e2e": "tsc --noEmit -p ./cypress/tsconfig.json",
"type-check:src": "wireit",
"z:setup": "run-p z:setup:gen-global-dts",
"z:setup:gen-global-dts": "node ./scripts/gen-global-dts.mjs",
"zz:eslint": "ESLINT_USE_FLAT_CONFIG=true TIMING=1 eslint",
"zz:eslint:cy": "yarn zz:eslint --config ./cypress/eslint.config.js './cypress/**/*.ts'",
"zz:eslint:e2e": "yarn zz:eslint --config ./cypress/eslint.config.js './cypress/**/*.ts'",
"zz:eslint:print-config": "yarn zz:eslint --print-config src/main.tsx",
"zz:eslint:src": "yarn zz:eslint --config eslint.config.js './src/**/*'",
"zz:prettier": "prettier --cache --cache-strategy content --ignore-path ../../../.prettierignore --write",
Expand Down
14 changes: 7 additions & 7 deletions packages/apps/blueprintjs-playground-styled/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"fb:login:ci": "firebase login:ci",
"fmt": "yarn zz:prettier .",
"gi": "bash ../../../scripts/bash/index_ts_generator.sh ./src --min-depth 1 --ignore assets",
"lint": "run-p lint:src lint:cy",
"lint:cy": "yarn zz:eslint:cy",
"lint:fix": "run-p lint:fix:src lint:fix:cy",
"lint:fix:cy": "yarn zz:eslint:cy --fix",
"lint": "run-p lint:src lint:e2e",
"lint:e2e": "yarn zz:eslint:e2e",
"lint:fix": "run-p lint:fix:src lint:fix:e2e",
"lint:fix:e2e": "yarn zz:eslint:e2e --fix",
"lint:fix:src": "yarn zz:eslint:src --fix",
"lint:src": "yarn zz:eslint:src",
"preview": "yarn zz:vite:preview",
Expand All @@ -40,13 +40,13 @@
"testw": "yarn zz:vitest watch",
"tsc": "yarn type-check",
"tscw": "tsc --noEmit --watch",
"type-check": "run-p type-check:src type-check:cy",
"type-check:cy": "tsc --noEmit -p ./cypress/tsconfig.json",
"type-check": "run-p type-check:src type-check:e2e",
"type-check:e2e": "tsc --noEmit -p ./cypress/tsconfig.json",
"type-check:src": "wireit",
"z:setup": "run-p z:setup:gen-global-dts",
"z:setup:gen-global-dts": "node ./scripts/gen-global-dts.mjs",
"zz:eslint": "ESLINT_USE_FLAT_CONFIG=true TIMING=1 eslint",
"zz:eslint:cy": "yarn zz:eslint --config ./cypress/eslint.config.js './cypress/**/*.ts'",
"zz:eslint:e2e": "yarn zz:eslint --config ./cypress/eslint.config.js './cypress/**/*.ts'",
"zz:eslint:print-config": "yarn zz:eslint --print-config src/main.tsx",
"zz:eslint:src": "yarn zz:eslint --config eslint.config.js './src/**/*'",
"zz:prettier": "prettier --cache --cache-strategy content --ignore-path ../../../.prettierignore --write",
Expand Down
14 changes: 7 additions & 7 deletions packages/apps/blueprintjs-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"fb:login:ci": "firebase login:ci",
"fmt": "yarn zz:prettier .",
"gi": "bash ../../../scripts/bash/index_ts_generator.sh ./src --min-depth 1 --ignore assets",
"lint": "run-p lint:src lint:cy",
"lint:cy": "yarn zz:eslint:cy",
"lint:fix": "run-p lint:fix:src lint:fix:cy",
"lint:fix:cy": "yarn zz:eslint:cy --fix",
"lint": "run-p lint:src lint:e2e",
"lint:e2e": "yarn zz:eslint:e2e",
"lint:fix": "run-p lint:fix:src lint:fix:e2e",
"lint:fix:e2e": "yarn zz:eslint:e2e --fix",
"lint:fix:src": "yarn zz:eslint:src --fix",
"lint:src": "yarn zz:eslint:src",
"preview": "yarn zz:vite:preview",
Expand All @@ -40,13 +40,13 @@
"testw": "yarn zz:vitest watch",
"tsc": "yarn type-check",
"tscw": "tsc --noEmit --watch",
"type-check": "run-p type-check:src type-check:cy",
"type-check:cy": "tsc --noEmit -p ./cypress/tsconfig.json",
"type-check": "run-p type-check:src type-check:e2e",
"type-check:e2e": "tsc --noEmit -p ./cypress/tsconfig.json",
"type-check:src": "wireit",
"z:setup": "run-p z:setup:gen-global-dts",
"z:setup:gen-global-dts": "node ./scripts/gen-global-dts.mjs",
"zz:eslint": "ESLINT_USE_FLAT_CONFIG=true TIMING=1 eslint",
"zz:eslint:cy": "yarn zz:eslint --config ./cypress/eslint.config.js './cypress/**/*.ts'",
"zz:eslint:e2e": "yarn zz:eslint --config ./cypress/eslint.config.js './cypress/**/*.ts'",
"zz:eslint:print-config": "yarn zz:eslint --print-config src/main.tsx",
"zz:eslint:src": "yarn zz:eslint --config eslint.config.js './src/**/*'",
"zz:prettier": "prettier --cache --cache-strategy content --ignore-path ../../../.prettierignore --write",
Expand Down
14 changes: 7 additions & 7 deletions packages/apps/cant-stop-probability-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"fb:login:ci": "firebase login:ci",
"fmt": "yarn zz:prettier .",
"gi": "bash ../../../scripts/bash/index_ts_generator.sh ./src --min-depth 1 --ignore assets",
"lint": "run-p lint:src lint:cy",
"lint:cy": "yarn zz:eslint:cy",
"lint:fix": "run-p lint:fix:src lint:fix:cy",
"lint:fix:cy": "yarn zz:eslint:cy --fix",
"lint": "run-p lint:src lint:e2e",
"lint:e2e": "yarn zz:eslint:e2e",
"lint:fix": "run-p lint:fix:src lint:fix:e2e",
"lint:fix:e2e": "yarn zz:eslint:e2e --fix",
"lint:fix:src": "yarn zz:eslint:src --fix",
"lint:src": "yarn zz:eslint:src",
"preview": "yarn zz:vite:preview",
Expand All @@ -40,13 +40,13 @@
"testw": "yarn zz:vitest watch",
"tsc": "yarn type-check",
"tscw": "tsc --noEmit --watch",
"type-check": "run-p type-check:src type-check:cy",
"type-check:cy": "tsc --noEmit -p ./cypress/tsconfig.json",
"type-check": "run-p type-check:src type-check:e2e",
"type-check:e2e": "tsc --noEmit -p ./cypress/tsconfig.json",
"type-check:src": "wireit",
"z:setup": "run-p z:setup:gen-global-dts",
"z:setup:gen-global-dts": "node ./scripts/gen-global-dts.mjs",
"zz:eslint": "ESLINT_USE_FLAT_CONFIG=true TIMING=1 eslint",
"zz:eslint:cy": "yarn zz:eslint --config ./cypress/eslint.config.js './cypress/**/*.ts'",
"zz:eslint:e2e": "yarn zz:eslint --config ./cypress/eslint.config.js './cypress/**/*.ts'",
"zz:eslint:print-config": "yarn zz:eslint --print-config src/main.tsx",
"zz:eslint:src": "yarn zz:eslint --config eslint.config.js './src/**/*'",
"zz:prettier": "prettier --cache --cache-strategy content --ignore-path ../../../.prettierignore --write",
Expand Down
14 changes: 7 additions & 7 deletions packages/apps/catan-dice-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"fb:login:ci": "firebase login:ci",
"fmt": "yarn zz:prettier .",
"gi": "bash ../../../scripts/bash/index_ts_generator.sh ./src --min-depth 1 --ignore assets",
"lint": "run-p lint:src lint:cy",
"lint:cy": "yarn zz:eslint:cy",
"lint:fix": "run-p lint:fix:src lint:fix:cy",
"lint:fix:cy": "yarn zz:eslint:cy --fix",
"lint": "run-p lint:src lint:e2e",
"lint:e2e": "yarn zz:eslint:e2e",
"lint:fix": "run-p lint:fix:src lint:fix:e2e",
"lint:fix:e2e": "yarn zz:eslint:e2e --fix",
"lint:fix:src": "yarn zz:eslint:src --fix",
"lint:src": "yarn zz:eslint:src",
"preview": "yarn zz:vite:preview",
Expand All @@ -40,13 +40,13 @@
"testw": "yarn zz:vitest watch",
"tsc": "yarn type-check",
"tscw": "tsc --noEmit --watch",
"type-check": "run-p type-check:src type-check:cy",
"type-check:cy": "tsc --noEmit -p ./cypress/tsconfig.json",
"type-check": "run-p type-check:src type-check:e2e",
"type-check:e2e": "tsc --noEmit -p ./cypress/tsconfig.json",
"type-check:src": "wireit",
"z:setup": "run-p z:setup:gen-global-dts",
"z:setup:gen-global-dts": "node ./scripts/gen-global-dts.mjs",
"zz:eslint": "ESLINT_USE_FLAT_CONFIG=true TIMING=1 eslint",
"zz:eslint:cy": "yarn zz:eslint --config ./cypress/eslint.config.js './cypress/**/*.ts'",
"zz:eslint:e2e": "yarn zz:eslint --config ./cypress/eslint.config.js './cypress/**/*.ts'",
"zz:eslint:print-config": "yarn zz:eslint --print-config src/main.tsx",
"zz:eslint:src": "yarn zz:eslint --config eslint.config.js './src/**/*'",
"zz:prettier": "prettier --cache --cache-strategy content --ignore-path ../../../.prettierignore --write",
Expand Down
Loading

0 comments on commit 5035cd2

Please sign in to comment.