Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit b2e2714

Browse files
committed
integration-test: Initialize Playwright
1 parent 7217353 commit b2e2714

File tree

8 files changed

+664
-10
lines changed

8 files changed

+664
-10
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ jobs:
158158
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
159159
with:
160160
images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
161+
tags:
161162
- name: Extract metadata (tags, labels) for DockerHub image
162163
id: dh-meta
163164
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7

.github/workflows/playwright.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [ main, master ]
5+
pull_request:
6+
branches: [ main, master ]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: lts/*
16+
- name: Install dependencies
17+
run: npm ci
18+
- name: Install Playwright Browsers
19+
run: npx playwright install --with-deps
20+
- name: Run Playwright tests
21+
run: npx playwright test
22+
- uses: actions/upload-artifact@v4
23+
if: always()
24+
with:
25+
name: playwright-report
26+
path: playwright-report/
27+
retention-days: 30

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ images/app-icons/png/16x16.png
2222
images/app-icons/png/32x32.png
2323
images/app-icons/png/512x512.png
2424
images/app-icons/png/1024x1024.png
25-
images/app-icons/mac/*.png
25+
images/app-icons/mac/*.png
26+
/test-results/
27+
/playwright-report/
28+
/blob-report/
29+
/playwright/.cache/

integration-tests/example.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('has title', async ({ page }) => {
4+
await page.goto('https://playwright.dev/');
5+
6+
// Expect a title "to contain" a substring.
7+
await expect(page).toHaveTitle(/Playwright/);
8+
});
9+
10+
test('get started link', async ({ page }) => {
11+
await page.goto('https://playwright.dev/');
12+
13+
// Click the get started link.
14+
await page.getByRole('link', { name: 'Get started' }).click();
15+
16+
// Expects page to have a heading with the name of Installation.
17+
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
18+
});

package-lock.json

Lines changed: 96 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
"@electron-forge/cli": "^6.4.2",
129129
"@electron-forge/maker-squirrel": "^6.4.2",
130130
"@electron-forge/plugin-auto-unpack-natives": "^6.4.2",
131+
"@playwright/test": "^1.46.0",
131132
"@types/archiver": "^6.0.2",
132133
"@types/better-sqlite3": "^7.6.9",
133134
"@types/cls-hooked": "^4.3.8",
@@ -145,6 +146,7 @@
145146
"@types/jsdom": "^21.1.6",
146147
"@types/mime-types": "^2.1.4",
147148
"@types/multer": "^1.4.11",
149+
"@types/node": "^22.1.0",
148150
"@types/safe-compare": "^1.1.2",
149151
"@types/sanitize-html": "^2.11.0",
150152
"@types/sax": "^1.2.7",

playwright.config.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
/**
4+
* Read environment variables from file.
5+
* https://github.com/motdotla/dotenv
6+
*/
7+
// import dotenv from 'dotenv';
8+
// dotenv.config({ path: path.resolve(__dirname, '.env') });
9+
10+
/**
11+
* See https://playwright.dev/docs/test-configuration.
12+
*/
13+
export default defineConfig({
14+
testDir: './integration-tests',
15+
/* Run tests in files in parallel */
16+
fullyParallel: true,
17+
/* Fail the build on CI if you accidentally left test.only in the source code. */
18+
forbidOnly: !!process.env.CI,
19+
/* Retry on CI only */
20+
retries: process.env.CI ? 2 : 0,
21+
/* Opt out of parallel tests on CI. */
22+
workers: process.env.CI ? 1 : undefined,
23+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
24+
reporter: 'html',
25+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
26+
use: {
27+
/* Base URL to use in actions like `await page.goto('/')`. */
28+
// baseURL: 'http://127.0.0.1:3000',
29+
30+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
31+
trace: 'on-first-retry',
32+
},
33+
34+
/* Configure projects for major browsers */
35+
projects: [
36+
{
37+
name: 'chromium',
38+
use: { ...devices['Desktop Chrome'] },
39+
},
40+
41+
{
42+
name: 'firefox',
43+
use: { ...devices['Desktop Firefox'] },
44+
},
45+
46+
{
47+
name: 'webkit',
48+
use: { ...devices['Desktop Safari'] },
49+
},
50+
51+
/* Test against mobile viewports. */
52+
// {
53+
// name: 'Mobile Chrome',
54+
// use: { ...devices['Pixel 5'] },
55+
// },
56+
// {
57+
// name: 'Mobile Safari',
58+
// use: { ...devices['iPhone 12'] },
59+
// },
60+
61+
/* Test against branded browsers. */
62+
// {
63+
// name: 'Microsoft Edge',
64+
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
65+
// },
66+
// {
67+
// name: 'Google Chrome',
68+
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
69+
// },
70+
],
71+
72+
/* Run your local dev server before starting the tests */
73+
// webServer: {
74+
// command: 'npm run start',
75+
// url: 'http://127.0.0.1:3000',
76+
// reuseExistingServer: !process.env.CI,
77+
// },
78+
});

0 commit comments

Comments
 (0)