@jieay/dsh-tester 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/lib/report.js +3 -0
- package/lib/run.js +3 -2
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -139,6 +139,22 @@ pnpm test # 启动本地夹具服务,在真实浏览器里跑这两个工
|
|
|
139
139
|
的情况非常常见——HTTP 状态码不能证明前端可用。只读取证可以用 HTTP 请求,但不能据此得结论。
|
|
140
140
|
2. **每次前端测试必须留截图。** 这是判断「页面到底长什么样」的唯一可靠证据。
|
|
141
141
|
|
|
142
|
+
### 真实项目冒烟脚本
|
|
143
|
+
|
|
144
|
+
仓库里带了一个针对禅道的回归脚本,用来在真实系统上验证插件本身:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
ZENTAO_ACCOUNT=xiaoming ZENTAO_PASSWORD=*** pnpm smoke:zentao
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
它会用真实浏览器登录 → **从左侧导航自动发现页面**(不猜 URL)→ 全量审计 →
|
|
151
|
+
打印每个页面的结论,并在 `.dsh-tester/test-reports/<时间>_audit/` 留下截图、`audit.json` 和 `report.md`。
|
|
152
|
+
全部通过退出码为 0,有失败页面为 1,登录失败为 2,可以直接接进 CI 或本地回归。
|
|
153
|
+
|
|
154
|
+
可选环境变量:`ZENTAO_BASE`(站点地址)、`ZENTAO_LIMIT`(最多审几页)、`ZENTAO_CHANNEL`(浏览器通道)。
|
|
155
|
+
|
|
156
|
+
凭据只从环境变量读取,不写进任何文件。
|
|
157
|
+
|
|
142
158
|
### 两条必须知道的约束
|
|
143
159
|
|
|
144
160
|
1. **插件不导入任何 `@deepseek-ai/*`。** 以 `link:` 方式安装的工作区 bundle,Node 会按真实路径解析,`@deepseek-ai/*` 无法解析,激活时报 `tester-tools ...: never started`。工具 schema 因此预编译在 `lib/schemas.json`,改动时直接维护这个文件,不要指望运行时 `import`。
|
package/lib/report.js
CHANGED
|
@@ -74,6 +74,9 @@ export function auditReportMarkdown(report, options = {}) {
|
|
|
74
74
|
if (page.navigationError) problems.push('导航失败')
|
|
75
75
|
if (page.redirectedToLogin) problems.push('跳到登录页(会话未登录)')
|
|
76
76
|
if (page.consoleErrors.length) problems.push(`console.error ${page.consoleErrors.length}`)
|
|
77
|
+
// 失败请求也算证据:哪怕是被导航打断的 ERR_ABORTED,也不该在摘要里显示为「—」,
|
|
78
|
+
// 否则读者会以为这页毫无异常,而 audit.json 里其实有记录。
|
|
79
|
+
if (page.failedRequests.length) problems.push(`失败请求 ${page.failedRequests.length}`)
|
|
77
80
|
const cells = [page.url, page.status, page.ok ? '通过' : '失败', problems.join(';') || '—']
|
|
78
81
|
if (inFolder) cells.push(page.screenshot ? `[查看](${basename(page.screenshot)})` : '—')
|
|
79
82
|
lines.push(`| ${cells.join(' | ')} |`)
|
package/lib/run.js
CHANGED
|
@@ -103,7 +103,8 @@ export async function auditPages(request) {
|
|
|
103
103
|
const urls = request.urls.slice(0, PAGE_CAP)
|
|
104
104
|
const settleMs = Number.isFinite(request.settleMs) ? request.settleMs : SETTLE_MS
|
|
105
105
|
const timeoutMs = Number.isFinite(request.timeoutMs) ? request.timeoutMs : NAV_TIMEOUT_MS
|
|
106
|
-
|
|
106
|
+
// 调用方可以省略 artifactsDir;缺省时用插件默认根目录,避免直接崩在 path.join
|
|
107
|
+
const dir = await prepareArtifacts(request.artifactsDir ?? artifactDir(undefined, process.cwd()), 'audit')
|
|
107
108
|
const setupSteps = asSteps(request.setupSteps)
|
|
108
109
|
|
|
109
110
|
const { browser, channel } = await launchBrowser({ channel: request.channel, headless: request.headless })
|
|
@@ -217,7 +218,7 @@ export async function runFlow(request) {
|
|
|
217
218
|
const steps = asSteps(request.steps)
|
|
218
219
|
const settleMs = Number.isFinite(request.settleMs) ? request.settleMs : SETTLE_MS
|
|
219
220
|
const timeoutMs = Number.isFinite(request.timeoutMs) ? request.timeoutMs : 15000
|
|
220
|
-
const dir = await prepareArtifacts(request.artifactsDir, 'flow')
|
|
221
|
+
const dir = await prepareArtifacts(request.artifactsDir ?? artifactDir(undefined, process.cwd()), 'flow')
|
|
221
222
|
|
|
222
223
|
const { browser, channel } = await launchBrowser({ channel: request.channel, headless: request.headless })
|
|
223
224
|
const context = await browser.newContext({ viewport: { width: 1440, height: 900 }, ignoreHTTPSErrors: true })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jieay/dsh-tester",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "给 DeepSeek Harness 用的测试工程师角色:预设角色 + 可委派的测试子代理 + 真实浏览器页面/旅程审计工具,专抓接口测试发现不了的前端故障。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|
|
@@ -46,8 +46,9 @@
|
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"test": "node --test",
|
|
49
|
-
"check": "node
|
|
50
|
-
"prepublishOnly": "npm run check && npm test"
|
|
49
|
+
"check": "node -e \"const{execFileSync}=require('node:child_process');const fs=require('node:fs');const files=['index.js',...fs.readdirSync('lib').filter(f=>f.endsWith('.js')).map(f=>'lib/'+f),...fs.readdirSync('scripts').filter(f=>f.endsWith('.mjs')).map(f=>'scripts/'+f)];for(const f of files) execFileSync(process.execPath,['--check',f],{stdio:'inherit'});console.log('checked '+files.length+' files')\"",
|
|
50
|
+
"prepublishOnly": "npm run check && npm test",
|
|
51
|
+
"smoke:zentao": "node scripts/smoke-zentao.mjs"
|
|
51
52
|
},
|
|
52
53
|
"publishConfig": {
|
|
53
54
|
"access": "public"
|