Skip to content

⚡️ 加速 GM_xhr E2E 测试 - #1749

Open
cyfung1031 wants to merge 1 commit into
scriptscat:mainfrom
cyfung1031:codex/speed-up-gm-xhr-e2e
Open

cyfung1031 wants to merge 1 commit into
scriptscat:mainfrom
cyfung1031:codex/speed-up-gm-xhr-e2e

Conversation

@cyfung1031

@cyfung1031 cyfung1031 commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Checklist / 检查清单

  • Fixes mentioned issues / 修复已提及的问题
  • Code reviewed by human / 代码通过人工检查
  • Changes tested / 已完成测试

N/A — no issue was linked to this performance request.

背景

e2e/gm-api.spec.ts:1021:3 runs 138 sequential GM request cases. The local mock already avoids ordinary external requests, but its timeout, abort, and streaming cases still waited for multi-second server delays, making the test take 38.8s locally.

本次改动

  • Add a local /hang response that keeps a request in flight for timeout and abort assertions without sleeping for a real remote delay.
  • In the E2E-only source patch, compress timeout/abort thresholds and the streaming interval while preserving the same request lifecycle and event-order assertions.
  • Keep the shared example/tests/gm_xhr_test.js and production code unchanged.

实现考虑

The timeout and abort contracts require an unfinished request and the matching callback sequence, not a specific three-, five-, or ten-second wall-clock delay. The progress cases still send eight chunks and retain the progressEvents >= 4 assertion. Requests still cross the real browser → extension → local HTTP server boundary; only the mock server response timing is shortened.

已知限制

The compressed timings apply only to this committed E2E harness patch. The example test keeps its original timings for manual or other callers.

建议审查重点

  • /hang must remain an open local request until the extension timeout or explicit abort closes it.
  • All 138 cases and their existing assertions must remain active; only the mock timing inputs are changed in memory.

验证

  • Baseline: time pnpm exec playwright test e2e/gm-api.spec.ts -g 'GM_xhr tests \(gm_xhr_test.js\)' --reporter=line — 138/138 passed, 38.8s wall time.
  • Focused optimized run: same command — 138/138 passed, 22.4s wall time; repeat 138/138 passed, 23.2s wall time.
  • Broader E2E: time pnpm exec playwright test e2e/gm-api.spec.ts --reporter=line — 12/12 passed, 38.2s.
  • pnpm run build — passed; existing bundle-size/Monaco warnings remain.
  • pnpm run lint — passed (Prettier, TypeScript, i18n, issue-template checks, ESLint).

@cyfung1031

Copy link
Copy Markdown
Collaborator Author

Before

✓ e2e/gm-api.spec.ts:1010:3 › GM API › GM_xhr tests (gm_xhr_test.js) (39.8s)

After

✓ e2e/gm-api.spec.ts:1021:3 › GM API › GM_xhr tests (gm_xhr_test.js) (14.9s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant