Skip to content

Commit 066bd61

Browse files
committed
chore: add playwright and add e2e tests
1 parent b80ea4d commit 066bd61

40 files changed

+419
-48
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ dist
55
.gitignore
66
.eslint.config.mjs
77
.data
8+
tests
9+
test-results
810
*.md
11+
*.spec.ts

.github/workflows/main.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,30 @@ jobs:
3535
path: ./.eslintcache
3636
key: ${{ runner.os }}-eslint-${{ hashFiles('**/pnpm-lock.yaml', '**/eslint.config.mjs') }}
3737

38-
- name: Lint
38+
- name: Run eslint
3939
run: pnpm lint
4040

41-
- name: Build
41+
- name: Build app
4242
run: pnpm build
43+
env:
4344

44-
- name: Test
45+
46+
- name: Run unit tests
4547
run: pnpm test
4648

47-
- name: Upload artifact
48-
if: success()
49-
uses: actions/upload-artifact@v4
49+
- name: Install playwright browsers
50+
run: pnpm exec playwright install --with-deps firefox
51+
52+
- name: Run e2e tests
53+
run: pnpm test:e2e
54+
55+
- uses: actions/upload-artifact@v4
56+
if: ${{ !cancelled() }}
5057
with:
51-
name: app
52-
path: dist
58+
name: test-results
59+
path: test-results/
60+
retention-days: 30
61+
5362

5463
publish_release:
5564
if: startsWith(github.event.ref, 'refs/tags/v')

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ dist-ssr
2828
.env
2929
.data
3030
.eslintcache
31+
32+
# Playwright
33+
/test-results/
34+
/blob-report/

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"lint:fix": "pnpm lint --fix",
2020
"test": "vitest run",
2121
"test:watch": "vitest",
22-
"test:ci": "pnpm lint:fix && pnpm build && pnpm test"
22+
"test:e2e": "playwright test",
23+
"test:e2e:ui": "playwright test --ui",
24+
"test:ci": "pnpm lint:fix && pnpm build && pnpm test && pnpm test:e2e"
2325
},
2426
"dependencies": {
2527
"@popperjs/core": "2.11.8",
@@ -34,6 +36,7 @@
3436
"devDependencies": {
3537
"@eslint/js": "9.20.0",
3638
"@intlify/eslint-plugin-vue-i18n": "^3.2.0",
39+
"@playwright/test": "1.50.1",
3740
"@types/ackee-tracker": "5.0.4",
3841
"@types/html-minifier-terser": "7.0.2",
3942
"@types/node": "22.13.1",
@@ -42,6 +45,7 @@
4245
"@vitejs/plugin-vue": "5.2.1",
4346
"@vue/eslint-config-prettier": "10.2.0",
4447
"@vue/eslint-config-typescript": "14.3.0",
48+
"dotenv": "16.4.7",
4549
"eslint": "9.20.0",
4650
"eslint-config-prettier": "10.0.1",
4751
"eslint-import-resolver-typescript": "3.7.0",

playwright.config.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
import { config } from 'dotenv';
3+
4+
config();
5+
6+
export default defineConfig({
7+
testDir: './test',
8+
outputDir: './test-results',
9+
fullyParallel: true,
10+
forbidOnly: !!process.env.CI,
11+
retries: process.env.CI ? 2 : 0,
12+
reporter: process.env.CI ? 'github' : 'list',
13+
projects: [
14+
{
15+
name: 'firefox',
16+
use: {
17+
...devices['Desktop Firefox'],
18+
contextOptions: { reducedMotion: 'reduce', serviceWorkers: 'block' }
19+
}
20+
}
21+
],
22+
webServer: {
23+
command: 'pnpm preview',
24+
url: 'http://localhost:3000',
25+
timeout: 120 * 1000,
26+
reuseExistingServer: !process.env.CI
27+
},
28+
use: {
29+
baseURL: 'http://localhost:3000',
30+
video: 'retain-on-failure'
31+
}
32+
});

pnpm-lock.yaml

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

src/app/components/base/button/Button.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<button
33
v-tooltip="{ text: tooltip, position: tooltipPosition }"
44
:class="classes"
5+
:data-testid="testId"
56
:disabled="disabled"
67
:type="type"
78
@click="emit('click', $event)"
@@ -36,6 +37,7 @@ const props = withDefaults(
3637
textual?: boolean;
3738
rounded?: boolean;
3839
disabled?: boolean;
40+
testId?: string;
3941
}>(),
4042
{
4143
color: 'primary',

src/app/components/base/check-box/CheckBox.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</label>
77

88
<div :class="$style.box">
9-
<input :id="inputId" v-model="modelValue" :class="$style.input" type="checkbox" />
9+
<input :id="inputId" v-model="modelValue" :data-testid="testId" :class="$style.input" type="checkbox" />
1010
<RiCheckLine size="16" :class="$style.icon" />
1111
</div>
1212
</div>
@@ -21,6 +21,7 @@ const modelValue = defineModel<boolean>();
2121
defineProps<{
2222
label: string;
2323
subLabel?: string;
24+
testId?: string;
2425
}>();
2526
2627
const inputId = uuid();

src/app/components/base/context-menu/ContextMenu.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<ContextMenuButton
1010
v-for="option of options"
1111
:key="option.id"
12+
:testId="`${testId}-${option.id}`"
1213
:padIcon="hasOptionWithIcon"
1314
:text="option.label ?? option.id"
1415
:icon="option.icon"
@@ -46,6 +47,7 @@ const props = withDefaults(
4647
position?: Placement;
4748
options?: ContextMenuOption[];
4849
highlight?: ContextMenuOptionId;
50+
testId?: string;
4951
}>(),
5052
{
5153
position: 'right-end'

src/app/components/base/context-menu/ContextMenuButton.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<li :class="$style.item">
3-
<button :class="classes" @click="onClick">
3+
<button :data-testid="testId" type="button" :class="classes" @click="onClick">
44
<component :is="icon" v-if="icon" :class="$style.icon" />
55
<span>{{ text }}</span>
66
</button>
@@ -25,6 +25,7 @@ const props = withDefaults(
2525
muted?: boolean;
2626
padIcon?: boolean;
2727
highlight?: boolean;
28+
testId?: string;
2829
}>(),
2930
{
3031
highlight: false,

0 commit comments

Comments
 (0)