Skip to content

fix: add e2e test #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 22

- name: Cache npm dependencies
uses: actions/cache@v4
Expand All @@ -57,7 +57,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 22

- name: Cache npm dependencies
uses: actions/cache@v4
Expand All @@ -82,10 +82,46 @@ jobs:
name: viewer
path: viewer/dist/browser

e2e:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22

- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: viewer/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
run: cd viewer && npm ci

- name: Install Playwright Browsers
run: cd viewer && npx playwright install --with-deps

- name: Run Playwright End-to-End Tests
run: cd viewer && npm run e2e

- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: viewer/playwright-report/
retention-days: 30

publish:
# only run on the main branch
if: github.ref == 'refs/heads/main'
needs: [validate, build]
needs: e2e
runs-on: ubuntu-latest
environment:
name: github-pages
Expand All @@ -112,7 +148,7 @@ jobs:
docker:
# only run on the main branch
if: github.ref == 'refs/heads/main'
needs: [validate, build]
needs: e2e
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand Down
5 changes: 5 additions & 0 deletions viewer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ testem.log
# System files
.DS_Store
Thumbs.db

# Playwright
/test-results/
/playwright-report/
/playwright/.cache/
44 changes: 36 additions & 8 deletions viewer/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,22 @@
"outputPath": "dist",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": ["zone.js"],
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": ["src/assets"],
"assets": [
"src/assets"
],
"styles": [
"src/theme.scss",
"src/styles.scss",
"node_modules/prismjs/themes/prism-okaidia.css"
],
"scripts": ["node_modules/prismjs/prism.js"],
"scripts": [
"node_modules/prismjs/prism.js"
],
"server": "src/main.server.ts",
"prerender": true,
"ssr": {
Expand Down Expand Up @@ -148,10 +154,16 @@
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": ["zone.js", "zone.js/testing"],
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": ["src/favicon.ico", "src/assets"],
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.scss"
Expand All @@ -162,14 +174,30 @@
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
"lintFilePatterns": [
"src/**/*.ts",
"src/**/*.html"
]
}
},
"e2e": {
"builder": "playwright-ng-schematics:playwright",
"options": {
"devServerTarget": "viewer:serve"
},
"configurations": {
"production": {
"devServerTarget": "viewer:serve:production"
}
}
}
}
}
},
"cli": {
"analytics": false,
"schematicCollections": ["@angular-eslint/schematics"]
"schematicCollections": [
"@angular-eslint/schematics"
]
}
}
}
8 changes: 8 additions & 0 deletions viewer/e2e/example.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { expect, test } from '@playwright/test';

test('has title', async ({ page }) => {
await page.goto('/');

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Wallet and Agent Overview/);
});
82 changes: 82 additions & 0 deletions viewer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"newsletter": "node scripts/newsletter.mjs",
"serve:ssr:viewer": "node dist/server/server.mjs",
"docker:build": "docker build -t wallet-agent-overview .",
"docker:run": "docker run -p 4000:4000 wallet-agent-overview"
"docker:run": "docker run -p 4000:4000 wallet-agent-overview",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
Expand Down Expand Up @@ -47,6 +48,7 @@
"@angular-devkit/build-angular": "^19.2.7",
"@angular/cli": "^19.2.7",
"@angular/compiler-cli": "^19.2.6",
"@playwright/test": "1.51.1",
"@types/express": "^5.0.1",
"@types/jasmine": "~5.1.0",
"@types/node": "^22.10.2",
Expand All @@ -63,8 +65,9 @@
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"nodemailer": "^6.9.14",
"playwright-ng-schematics": "^2.0.2",
"sharp": "^0.34.1",
"typescript": "~5.8.3",
"typescript-eslint": "^8.18.1"
}
}
}
70 changes: 70 additions & 0 deletions viewer/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
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',
/* 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: process.env['CI'] ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env['CI'] ? 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: process.env['PLAYWRIGHT_TEST_BASE_URL'] ?? 'http://localhost:4200',

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

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