fix: 合并 main 后的测试回归修复

- index.ts: 移除 #130 遗留的 ctx.on('session/disposed')(fake ctx 无 on,
  且 #130 已按取 HEAD 决策,closeSession 调用方一并移除)
- browser.probe: 405→GET 重试后跳过 embed-signals GET,避免多余第 3 次请求(#69)
- EditorHost: 移植 #228 的 dirty 确认守卫到 HEAD 的 reloadSeq 结构(refreshFile)
- tests: fake ctx 补 get()(#357 ctx.get 回归,free-window/editor-refresh/markdown)
- tests: prefs 期望对象补 browserAllowedLoopback(smoke/plugin-shape/state)
- tests: builtins 浏览器设置行补 browserAllowedLoopback(#69)
- tests: install-powershell BOM 门限仅对实际文档化远程调用的文件生效
- locales: 19 语言补齐 showInFolder / refreshUnsavedConfirm(#94 #215 #228)
This commit is contained in:
HuanLinOTO
2026-08-24 17:54:33 +08:00
parent f4e71c1257
commit 6001f0167c
30 changed files with 77 additions and 19 deletions
+1
View File
@@ -131,6 +131,7 @@ describe('built-in tab registrations', () => {
'browserInterceptLinks',
'browserInterceptHttp',
'browserInterceptHttps',
'browserAllowedLoopback',
])
for (const toggle of toggles) {
expect(toggle.title).toBeDefined()
+1
View File
@@ -80,6 +80,7 @@ function setup(initialMode: 'preview' | 'edit' = 'preview', dirty = false): {
const ctx = {
betterSidebar: service,
sessions: { list: { subscribe: () => () => {}, getSnapshot: () => sessionsSnapshot } },
get: (name: string) => name === 'betterSidebar' ? service : undefined,
} as unknown as Context
ctx.betterSidebar.openTab({ type: 'editor', title: 'a.ts', path: '/tmp/a.ts', id: 'editor:/tmp/a.ts' })
const fileTab = (): SidebarTab =>
+1
View File
@@ -99,6 +99,7 @@ function mountSidebar(sessionId: string = `s1-${++sessionSeq}`): Mounted {
locale: { subscribe: () => () => {}, getSnapshot: () => localeSnapshot },
sessions: { list: { subscribe: () => () => {}, getSnapshot: () => sessionsSnapshot } },
betterSidebar: service,
get: (name: string) => name === 'betterSidebar' ? service : undefined,
}
const root: Root = createRoot(container)
act(() => { root.render(createElement(Sidebar, { ctx: ctx as never, store })) })
+8 -1
View File
@@ -79,7 +79,14 @@ describe('PowerShell installer entry points', () => {
const source = readFileSync(resolve(ROOT, file), 'utf8')
expect(source, file).not.toMatch(new RegExp(`irm [^\\r\\n]*${INSTALLER_URL.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[^\\r\\n]*\\|\\s*iex`, 'i'))
expect(source, file).not.toMatch(/\[scriptblock\]::Create\(\(irm\b/i)
expect(source.match(/\.TrimStart\(\[char\]0xFEFF\)/g)?.length, file).toBeGreaterThanOrEqual(2)
// Where remote invocation IS documented, it must be BOM-safe: the
// READMEs switched to the prompt-based install flow and no longer
// document `irm` at all, so the TrimStart gate applies to the script
// (whose usage comment demonstrates the safe pattern).
const documentsInvocation = /\birm\b|\$script\s*=|\[scriptblock\]/.test(source)
if (documentsInvocation) {
expect(source.match(/\.TrimStart\(\[char\]0xFEFF\)/g)?.length, file).toBeGreaterThanOrEqual(2)
}
}
})
+4 -1
View File
@@ -60,7 +60,10 @@ function setup(): {
.flatMap(leaf => leaf.tabs)
.find(candidate => candidate.type === 'editor')!
const tab: SidebarTab = { ...home, path: '/tmp/notes.md', title: 'notes.md' }
const ctx = { betterSidebar: service } as unknown as Context
const ctx = {
betterSidebar: service,
get: (name: string) => name === 'betterSidebar' ? service : undefined,
} as unknown as Context
return { store, ctx, tab }
}
+1 -1
View File
@@ -94,6 +94,6 @@ describe('dsh-better-sidebar plugin export shape', () => {
const overridden = (PrefsSchema as unknown as {
(input: Record<string, unknown> | undefined): Record<string, unknown>
})({ openByDefault: false, defaultWidthPercent: 45 })
expect(overridden).toEqual({ openByDefault: false, defaultWidthPercent: 45, autoOpenSubagent: true, autoOpenJobs: true, agentTerminalTools: false, agentOpenTools: false, bottomPanelAutoTerminal: true, terminalFontFamily: '', terminalFontSize: 13, interceptOpenPath: true, editorExplorer: false, terminalShell: '', terminalShellArgs: '', titleBarCompat: false, titleBarStripPx: 40, htmlViewerNoSandbox: false, htmlViewerDefaultUnsafe: false, browserNoSandbox: false, browserInterceptLinks: true, browserInterceptHttp: true, browserInterceptHttps: false, tabsEnabled: {}, viewersEnabled: {}, pluginSettings: {} })
expect(overridden).toEqual({ openByDefault: false, defaultWidthPercent: 45, autoOpenSubagent: true, autoOpenJobs: true, agentTerminalTools: false, agentOpenTools: false, bottomPanelAutoTerminal: true, terminalFontFamily: '', terminalFontSize: 13, interceptOpenPath: true, editorExplorer: false, terminalShell: '', terminalShellArgs: '', titleBarCompat: false, titleBarStripPx: 40, htmlViewerNoSandbox: false, htmlViewerDefaultUnsafe: false, browserNoSandbox: false, browserInterceptLinks: true, browserInterceptHttp: true, browserInterceptHttps: false, browserAllowedLoopback: '', tabsEnabled: {}, viewersEnabled: {}, pluginSettings: {} })
})
})
+1
View File
@@ -907,6 +907,7 @@ describe('side card settings routes', () => {
browserInterceptLinks: true,
browserInterceptHttp: true,
browserInterceptHttps: false,
browserAllowedLoopback: '',
// The enable-switch maps default to {} (everything on).
tabsEnabled: {},
viewersEnabled: {},
+4 -1
View File
@@ -871,7 +871,10 @@ describe('v0.12.0 store additions', () => {
// timers BOTH writes are pending and both land when they fire.
expect(timers.size).toBe(2)
for (const [, fn] of [...timers]) fn()
expect(writes).toEqual(['dsh-sidebar:v1:a', 'dsh-sidebar:v1:b'])
// Each persist also syncs the shared cross-session width key (PR #36).
expect(writes.filter(key => key !== 'dsh-sidebar:v1:width'))
.toEqual(['dsh-sidebar:v1:a', 'dsh-sidebar:v1:b'])
expect(writes).toContain('dsh-sidebar:v1:width')
} finally {
delete g.window
delete g.localStorage