Skip to content

test(amp-usage): cover auto-refresh default - #1006

Merged
yetone merged 1 commit into
magpie-community:mainfrom
overstarry:test/amp-usage-auto-refresh
Nov 11, 2026
Merged

yetone merged 1 commit into
magpie-community:mainfrom
overstarry:test/amp-usage-auto-refresh

Conversation

@overstarry

Copy link
Copy Markdown
Contributor

补上 #1000 合并评论中提到的遗留项:自动刷新默认值没有测试(https://github.com/magpie-community/plugins/pull/1000#issuecomment-6797679377)。

ui.test.mjs 新增一个测试:在最小的浏览器替身(DOM、fetch、localStorage)上运行 ui/app.js,状态接口返回一次 N 分钟前完成的扫描。未保存过设置时,4 分钟只请求 /api/status,6 分钟会再请求 /api/refresh。只改测试,不改代码。

验证:

  • node --test packages/amp-usage/test/*.test.mjs:48/48 通过。
  • bun test(packages/amp-usage):48 pass,0 fail。
  • bun scripts/check.mjs:通过。
  • 手动改坏:把 ui/app.js 中 kept("auto", 300) 改为 60、600、0,node 下新测试均失败;改为 60 时 bun 下同样失败。

With nothing kept, the open page refreshes once a scan is 5 minutes
old: 4 minutes polls status only, 6 minutes also refreshes. Changing
the default in ui/app.js to 60, 600, or 0 now fails the test.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1caea-5f86-7654-b535-fbec8b66ad64
Co-authored-by: Amp <amp@ampcode.com>
@yetone
yetone merged commit a69931e into magpie-community:main Nov 11, 2026
2 checks passed
@overstarry
overstarry deleted the test/amp-usage-auto-refresh branch November 11, 2026 14:50
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.

2 participants