Skip to content

Commit 766acb9

Browse files
antfuCopilot
andauthored
test: add playwright e2e suite for files-inspector and streaming-chat (#14)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 97bc45b commit 766acb9

24 files changed

Lines changed: 377 additions & 154 deletions

.github/workflows/ci.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Unit Test
1+
name: CI
22

33
on:
44
push:
@@ -13,6 +13,31 @@ jobs:
1313
unit-test:
1414
uses: sxzz/workflows/.github/workflows/unit-test.yml@main
1515

16+
e2e:
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 15
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: pnpm/action-setup@v4
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: 22
25+
cache: pnpm
26+
- run: pnpm install --frozen-lockfile
27+
- name: Cache Playwright browsers
28+
uses: actions/cache@v4
29+
with:
30+
path: ~/.cache/ms-playwright
31+
key: playwright-${{ hashFiles('pnpm-lock.yaml') }}
32+
- run: pnpm exec playwright install --with-deps chromium
33+
- run: pnpm test:e2e
34+
- if: failure()
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: playwright-report
38+
path: playwright-report/
39+
retention-days: 7
40+
1641
# coverage:
1742
# uses: sxzz/workflows/.github/workflows/coverage.yml@main
1843
# needs: unit-test

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ temp
1515
**/.vitepress/cache
1616
**/.vitepress/dist
1717
packages/devframe/skills
18+
test-results
19+
playwright-report
20+
playwright/.cache
21+
blob-report

docs/guide/built-with.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ Real-world devtools shipping on Devframe:
1212

1313
End-to-end examples in this repo, exercising the full adapter surface:
1414

15-
- [**counter**](https://github.com/devframes/devframe/tree/main/examples/counter) — smallest possible demo, exercises all adapters.
1615
- [**files-inspector**](https://github.com/devframes/devframe/tree/main/examples/files-inspector) — lists files in cwd via RPC; exercises CLI dev/build/spa surfaces.
1716
- [**streaming-chat**](https://github.com/devframes/devframe/tree/main/examples/streaming-chat) — streams synthetic chat tokens from server to client via `ctx.rpc.streaming`.

examples/counter/bin.mjs

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/counter/package.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

examples/counter/src/client/index.html

Lines changed: 0 additions & 13 deletions
This file was deleted.

examples/counter/src/client/main.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/counter/src/devframe.ts

Lines changed: 0 additions & 77 deletions
This file was deleted.

examples/files-inspector/src/devframe.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import process from 'node:process'
12
import { fileURLToPath } from 'node:url'
23
import { defineRpcFunction } from 'devframe'
34
import { defineDevframe } from 'devframe/types'
@@ -18,19 +19,21 @@ export default defineDevframe({
1819
},
1920
spa: { loader: 'none' },
2021
async setup(ctx) {
22+
const targetCwd = process.env.DEVFRAME_E2E_CWD || ctx.cwd
23+
2124
ctx.rpc.register(defineRpcFunction({
2225
name: 'devframe-files-inspector:get-cwd',
2326
type: 'static',
2427
jsonSerializable: true,
25-
handler: () => ({ cwd: ctx.cwd }),
28+
handler: () => ({ cwd: targetCwd }),
2629
}))
2730

2831
ctx.rpc.register(defineRpcFunction({
2932
name: 'devframe-files-inspector:list-files',
3033
type: 'query',
3134
jsonSerializable: true,
3235
handler: async () => {
33-
const files = await glob(['*'], { cwd: ctx.cwd, onlyFiles: true, dot: false })
36+
const files = await glob(['*'], { cwd: targetCwd, onlyFiles: true, dot: false })
3437
return files.map(f => f.replace(/\\/g, '/')).sort()
3538
},
3639
snapshot: true,

examples/streaming-chat/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"scripts": {
1212
"build": "vite build --config src/client/vite.config.ts",
13+
"cli:build": "node bin.mjs build --out-dir dist/static",
1314
"dev": "node bin.mjs",
1415
"test": "vitest run"
1516
},

0 commit comments

Comments
 (0)