Files
new-markdown/tests/info-modal.test.tsx
Muse c300b4c8db feat(app): 支持设置 .md 默认打开方式(docs/32)
三条链路:①tauri.conf bundle.fileAssociations 注册 md/markdown,
新版安装包重装后出现在「打开方式」候选;②文件菜单「设为 .md
默认打开方式…」:Rust 命令经 reg.exe 写 HKCU 的 ProgID
NewMarkdown.md/OpenWithProgids/SupportedTypes(免管理员、指向
当前 exe),再打开系统默认应用设置让用户确认一次(Windows 不许
程序直接抢默认);③双击打开:单实例插件转发第二实例参数到待
打开队列+聚焦主窗口,冷启动读 env args,共用 md_files_from_args
过滤;前端 take_pending_open_files 取走逐个打开,只由 main 窗口
消费防子窗口抢文件。命令数 31→33 对账,参数过滤纯函数已抽 crate
实测,vitest 154+2、构建通过;Windows 构建与双击全流程待真机验。
2026-11-15 13:57:31 +08:00

25 lines
1.1 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 通用信息弹窗(docs/32 文件关联引导用):标题/正文渲染,点「知道了」关闭。
import { describe, it, expect, vi } from 'vitest'
import { createRoot } from 'react-dom/client'
import { act } from 'react-dom/test-utils'
import { InfoModal } from '../src/components/Modals'
describe('InfoModal', () => {
it('渲染标题与正文,点知道了回调关闭', async () => {
const container = document.createElement('div')
document.body.appendChild(container)
const root = createRoot(container)
const onClose = vi.fn()
await act(async () => {
root.render(<InfoModal title="文件关联" message="已注册为候选打开方式。" onClose={onClose} />)
})
expect(container.textContent).toContain('文件关联')
expect(container.textContent).toContain('已注册为候选打开方式。')
const btn = [...container.querySelectorAll('button')].find((b) => b.textContent === '知道了')!
await act(async () => { btn.dispatchEvent(new MouseEvent('click', { bubbles: true })) })
expect(onClose).toHaveBeenCalledTimes(1)
await act(async () => { root.unmount() })
container.remove()
})
})