Skip to content

Commit 539b072

Browse files
committed
fix code
1 parent c19aaa2 commit 539b072

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,20 @@
2323
"test:frontend:ui": "vitest --ui --config vitest.frontend.config.ts",
2424
"test:frontend:coverage": "vitest run --coverage --config vitest.frontend.config.ts",
2525
"test:e2e": "vitest run --config vitest.e2e.config.ts",
26+
"test:integration": "vitest run \"test/integration/**/*.test.ts\"",
27+
"test:performance": "vitest run \"test/performance/**/*.test.ts\"",
2628
"test:e2e:watch": "vitest --config vitest.e2e.config.ts",
2729
"test:e2e:ui": "vitest --ui --config vitest.e2e.config.ts",
2830
"test:e2e:coverage": "vitest run --coverage --config vitest.e2e.config.ts",
29-
"test:all": "pnpm test:backend && pnpm test:frontend && pnpm test:e2e && pnpm test:coverage",
31+
"test:all": "pnpm test:backend && pnpm test:frontend && pnpm test:integration && pnpm test:performance && pnpm test:e2e && pnpm test:coverage",
3032
"test:generate": "ts-node scripts/test-generator.ts",
3133
"test:orchestrate": "ts-node scripts/test-orchestrator.ts",
3234
"test:ci": "pnpm test:all --reporter=verbose --reporter=json --outputFile=test-results.json",
3335
"postinstall": "electron-builder install-app-deps",
34-
"gen": "openapi --input http://127.0.0.1:3007/api-json --output ./src/frontend/generated --useOptions --name=Play"
36+
"gen": "openapi --input http://127.0.0.1:3007/api-json --output ./src/frontend/generated --useOptions --name=Play",
37+
"playwright:install": "npx playwright install --with-deps",
38+
"test:playwright": "playwright test",
39+
"test:playwright:report": "playwright show-report"
3540
},
3641
"dependencies": {
3742
"@doubleshot/nest-electron": "^0.2.5",
@@ -69,6 +74,7 @@
6974
"devDependencies": {
7075
"@lightwing/eslint-config": "^0.0.24",
7176
"@nestjs/testing": "^10.2.8",
77+
"@playwright/test": "^1.48.0",
7278
"@testing-library/user-event": "^14.5.1",
7379
"@testing-library/vue": "^8.0.1",
7480
"@types/echarts": "^4.9.21",
@@ -103,13 +109,16 @@
103109
"vue-tsc": "1.8.19"
104110
},
105111
"simple-git-hooks": {
106-
"pre-commit": "npx lint-staged"
112+
"pre-commit": "npx lint-staged && pnpm -s test:playwright || true"
107113
},
108114
"lint-staged": {
109115
"*.{js,ts,tsx,vue}": [
110116
"eslint --fix",
111117
"vitest related --run"
112118
],
119+
"tests/playwright/**/*.ts": [
120+
"node -e \"console.log('Playwright specs staged, will run in hook')\""
121+
],
113122
"*.{md,json,yml}": [
114123
"eslint --fix"
115124
]

playwright.config.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { defineConfig, devices } from '@playwright/test'
2+
3+
export default defineConfig({
4+
testDir: 'tests/playwright',
5+
timeout: 30_000,
6+
expect: { timeout: 10_000 },
7+
retries: 1,
8+
reporter: [['list'], ['html', { outputFolder: 'playwright-report', open: 'never' }]],
9+
use: {
10+
actionTimeout: 10_000,
11+
navigationTimeout: 20_000,
12+
baseURL: 'https://ljluestc.github.io',
13+
trace: 'on-first-retry',
14+
},
15+
projects: [
16+
{
17+
name: 'chromium',
18+
use: { ...devices['Desktop Chrome'] },
19+
},
20+
],
21+
})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test('site-wide link crawler returns 2xx for internal links', async ({ page, request }) => {
4+
await page.goto('/')
5+
6+
const anchors = await page.locator('a').all()
7+
const hrefs = new Set<string>()
8+
for (const a of anchors) {
9+
const href = await a.getAttribute('href')
10+
if (!href)
11+
continue
12+
if (href.startsWith('http') && !href.startsWith('https://ljluestc.github.io'))
13+
continue
14+
const resolved = href.startsWith('http') ? href : new URL(href, 'https://ljluestc.github.io').toString()
15+
hrefs.add(resolved)
16+
}
17+
18+
for (const url of hrefs) {
19+
const res = await request.get(url)
20+
expect(res.ok()).toBe(true)
21+
}
22+
})

vitest.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ export default defineConfig({
88
globals: true,
99
environment: 'happy-dom',
1010
setupFiles: ['./test/setup.ts'],
11+
exclude: [
12+
'tests/playwright/**',
13+
'node_modules/**',
14+
'dist/**',
15+
],
1116
coverage: {
1217
provider: 'v8',
1318
reporter: ['text', 'json', 'html', 'lcov'],

0 commit comments

Comments
 (0)