Skip to content

Commit 04ce14b

Browse files
committed
修复bug
1 parent 15b314a commit 04ce14b

31 files changed

Lines changed: 2261 additions & 340 deletions
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Live Regression
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 3 * * 1'
7+
8+
jobs:
9+
live-regression:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v5
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v5
18+
with:
19+
node-version: 22.x
20+
cache: npm
21+
22+
- name: Install
23+
run: npm ci
24+
25+
- name: Run Live Regression Tests
26+
run: npm run test:live

‎.github/workflows/release.yml‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,20 @@ jobs:
2525
- name: Setup Node.js
2626
uses: actions/setup-node@v5
2727
with:
28-
node-version: 24.x
28+
node-version: 22.x
2929
cache: npm
3030

3131
- name: Install
3232
run: npm ci
3333

34-
- name: Test
35-
run: npm run test:reg
34+
- name: Install Playwright Browser
35+
run: npx playwright install --with-deps chromium
36+
37+
- name: Run Regression Tests
38+
run: npm run test:run
39+
40+
- name: Run Popup E2E Tests
41+
run: npm run test:e2e
3642

3743
- name: Build
3844
run: npm run build

‎.github/workflows/webpack.yml‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ on:
99
jobs:
1010
test-and-build:
1111
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
node-version: [22.x, 24.x]
1512

1613
steps:
1714
- name: Checkout
@@ -20,14 +17,20 @@ jobs:
2017
- name: Setup Node.js
2118
uses: actions/setup-node@v5
2219
with:
23-
node-version: ${{ matrix.node-version }}
20+
node-version: 22.x
2421
cache: npm
2522

2623
- name: Install
2724
run: npm ci
2825

26+
- name: Install Playwright Browser
27+
run: npx playwright install --with-deps chromium
28+
2929
- name: Run Regression Tests
30-
run: npm run test:reg
30+
run: npm run test:run
31+
32+
- name: Run Popup E2E Tests
33+
run: npm run test:e2e
3134

3235
- name: Build Extension
3336
run: npm run build

‎.gitignore‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ node_modules
88
build
99
dist
1010
.rpt2_cache
11+
output/playwright
12+
.playwright
13+
.playwright-cli
1114

1215
# misc
1316
.DS_Store
@@ -32,4 +35,4 @@ yarn-error.log*
3235
*.jar
3336
*.rar
3437
*.tar
35-
*.zip
38+
*.zip

‎docs/testing.md‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Testing
2+
3+
Azusa Player now uses three testing layers:
4+
5+
- `npm run test:run`
6+
Runs the default Vitest regression suite for data utilities, storage flows, and popup components.
7+
- `npm run test:e2e`
8+
Runs Playwright popup end-to-end tests against the Vite-served popup page with mocked Bilibili and QQ APIs.
9+
- `npm run test:live`
10+
Runs the live network snapshot checks only. This is intentionally separated from PR gating so normal CI stays deterministic.
11+
12+
## Local Workflow
13+
14+
Use the fast regression suite while iterating on logic or UI state:
15+
16+
```bash
17+
npm run test:run
18+
```
19+
20+
Use the browser suite when you touch popup flows such as search, playlist persistence, or theme state:
21+
22+
```bash
23+
npm run test:e2e
24+
```
25+
26+
If Chromium is not installed yet for Playwright, run:
27+
28+
```bash
29+
npx playwright install chromium
30+
```
31+
32+
## E2E Design
33+
34+
- Playwright serves `src/popup/index.html` through Vite instead of relying on `build:web`.
35+
- Browser tests seed `localStorage` using the web fallback in `src/platform/browserApi.ts`.
36+
- Bilibili and QQ requests are mocked in `tests/e2e/helpers/popup-fixtures.ts`, so PR runs do not depend on CORS or external API stability.
37+
- Playwright artifacts are stored under `output/playwright/`.
38+
39+
## Live Regression
40+
41+
The live suite keeps a thin real-network signal for upstream API drift. It is wired into a dedicated GitHub Actions workflow and should only be used for scheduled checks or manual verification:
42+
43+
```bash
44+
npm run test:live
45+
```
46+
47+
## Playwright Skill
48+
49+
The repository Playwright tests are the official CI layer. The Codex `playwright` skill is still useful for manual debugging, snapshots, and reproducing UI issues quickly. A typical local debug loop looks like:
50+
51+
```bash
52+
npx --package @playwright/cli playwright-cli open http://127.0.0.1:4173/src/popup/index.html
53+
npx --package @playwright/cli playwright-cli snapshot
54+
```

‎package-lock.json‎

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

‎package.json‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "azusa-player",
3-
"description": "azusa-player: \u7b2c\u4e09\u65b9 Bilibili \u97f3\u9891\u64ad\u653e\u5668 / A 3rd party Bilibili audio player.",
4-
"version": "2.0.1",
3+
"description": "azusa-player: 第三方 Bilibili 音频播放器 / A 3rd party Bilibili audio player.",
4+
"version": "2.0.2",
55
"main": "index.js",
66
"author": "Ken Wang",
77
"private": true,
@@ -15,8 +15,12 @@
1515
"build:extension": "tsc && vite build --mode extension",
1616
"preview": "vite preview",
1717
"test": "vitest",
18-
"test:run": "vitest run",
19-
"test:reg": "vitest run --reporter=verbose"
18+
"test:run": "vitest run --reporter=basic",
19+
"test:reg": "vitest run --reporter=verbose",
20+
"test:live": "vitest run --config vitest.live.config.ts --reporter=verbose",
21+
"test:e2e": "playwright test",
22+
"test:e2e:headed": "playwright test --headed",
23+
"test:ci": "npm run test:run && npm run test:e2e && npm run build"
2024
},
2125
"dependencies": {
2226
"@emotion/react": "^11.11.1",
@@ -39,6 +43,7 @@
3943
},
4044
"devDependencies": {
4145
"@crxjs/vite-plugin": "^2.0.0-beta.19",
46+
"@playwright/test": "^1.59.1",
4247
"@testing-library/jest-dom": "^6.9.1",
4348
"@testing-library/react": "^16.3.2",
4449
"@testing-library/user-event": "^14.6.1",

‎playwright.config.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
export default defineConfig({
4+
testDir: './tests/e2e',
5+
outputDir: 'output/playwright/test-results',
6+
fullyParallel: true,
7+
forbidOnly: !!process.env.CI,
8+
retries: process.env.CI ? 2 : 0,
9+
reporter: [
10+
['list'],
11+
['html', { open: 'never', outputFolder: 'output/playwright/report' }],
12+
],
13+
use: {
14+
baseURL: 'http://127.0.0.1:4173',
15+
trace: 'retain-on-failure',
16+
screenshot: 'only-on-failure',
17+
video: 'retain-on-failure',
18+
...devices['Desktop Chrome'],
19+
},
20+
webServer: {
21+
command: 'npm run dev:web -- --host 127.0.0.1 --port 4173',
22+
url: 'http://127.0.0.1:4173/src/popup/index.html',
23+
reuseExistingServer: !process.env.CI,
24+
timeout: 120_000,
25+
},
26+
});

‎public/assets/player-bg3.png‎

220 KB
Loading

‎public/manifest.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "\u7535\u6893\u64ad\u653e\u5668 - \u7b2c\u4e09\u65b9 Bilibili \u97f3\u9891\u64ad\u653e\u5668",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "azusa-player: \u7b2c\u4e09\u65b9 Bilibili \u97f3\u9891\u64ad\u653e\u5668 / A 3rd party Bilibili audio player.",
55
"manifest_version": 3,
66
"background": {
@@ -29,6 +29,7 @@
2929
},
3030
"permissions": [
3131
"declarativeNetRequest",
32+
"scripting",
3233
"storage",
3334
"contextMenus",
3435
"notifications"

0 commit comments

Comments
 (0)