test(updater): 覆盖调度、自动下载、同版本抑制与气泡

updater-fallback 从 82 扩到 150 断言(新增 11 节):周期节拍与关闭、重排、
启动检查只武装一次、并发检查共用同一 promise、自动下载开关、同版本去重、
换版本恢复、手动检查不被抑制、已下载状态保持(含不卡 checking 与
fetchHandled/downloaded 区分)、气泡的窗口可见性守卫。electron-stub 的
Tray 补 displayBalloon 记录、BrowserWindow.getAllWindows 可注入假窗口。

AGENTS.md 更新机制一节补录三条来源、注入式调度、自动下载、同版本抑制与
气泡守卫。
This commit is contained in:
Bill committed 2026-10-10 13:36:55 +08:00
1 parent bf79036599
commit c94e3358ea
3 files changed
+527 -6

No files matched your search

+18 -1
View File
@@ -46,7 +46,10 @@ const fakeSession = (name) => {
module.exports = {
BrowserWindow: {
getAllWindows: () => []
// Configurable so a test can drive the "is a window visible?" guards (the
// update balloons, the session snapshot). Like the rest of the stub state
// this lives on the shared global, and the default is "no window open".
getAllWindows: () => state.windows ?? []
},
app: {
getPath: (name) => {
@@ -110,6 +113,16 @@ module.exports = {
setContextMenu() {}
on() {}
destroy() {}
/**
* Balloons (`notifyUpdate`, the minimize hint) have no other observable
* effect, so they are recorded instead of dropped. The sink is a global for
* the same reason as the rest of the state: the bundle inlines this file, so
* a test's require of this path is a different module instance.
*/
displayBalloon(options) {
const sink = (globalThis.__otBalloons ??= [])
sink.push(options)
}
static getBounds() {
return { x: 0, y: 0, width: 0, height: 0 }
}
@@ -123,6 +136,10 @@ module.exports = {
__setPackaged: (v) => {
state.isPackaged = v
},
/** Fake window list `BrowserWindow.getAllWindows()` hands the bundled code. */
__setWindows: (wins) => {
state.windows = wins
},
/** channel -> listener (invoke), `on:<channel>` -> listener (send). */
get __handlers() {
return state.handlers