/** * 07-notify: 通知系统(不触发 Sys/Dock) */ import { describe, it, expect, beforeEach, beforeAll } from 'vitest' import { Notify, setSysForNotify } from '../../src/composables/useNotify' // Mock minimal Sys const mockSys = { settings: { notificationsEnabled: true, notifAllow: {} as Record, focus: false, } } setSysForNotify(mockSys) describe('07-notify — 通知系统', () => { beforeAll(() => { // 渲染通知中心 DOM document.body.innerHTML = '' }) beforeEach(() => { Notify.list = [] }) it('初始列表为空', () => { expect(Notify.list.length).toBe(0) }) it('send 添加通知', () => { const n = Notify.send({ appId: 'finder', title: 'T', body: 'B', silent: true }) expect(n).not.toBeNull() expect(Notify.list.length).toBe(1) }) it('总开关关闭返回 null', () => { mockSys.settings.notificationsEnabled = false expect(Notify.send({ appId: 'f', title: 'T', body: 'B', silent: true })).toBeNull() mockSys.settings.notificationsEnabled = true }) it('per-app 关闭返回 null', () => { mockSys.settings.notifAllow['finder'] = false expect(Notify.send({ appId: 'finder', title: 'T', body: 'B', silent: true })).toBeNull() mockSys.settings.notifAllow['finder'] = true }) it('markRead 标记已读', () => { const n = Notify.send({ appId: 'f', title: 'T', body: 'B', silent: true }) expect(n!.read).toBe(false) Notify.markRead(n!.id) expect(n!.read).toBe(true) }) it('clearAll 清空', () => { Notify.send({ appId: 'f', title: 'T', body: 'B', silent: true }) Notify.clearAll() expect(Notify.list.length).toBe(0) }) })