fix: harden reminders and state handling

This commit is contained in:
Codex
2026-06-06 02:27:04 +07:00
parent ad000c722e
commit ffe80b62c4
17 changed files with 1752 additions and 288 deletions

View File

@@ -21,6 +21,8 @@ const h = vi.hoisted(() => ({
log: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() }
}))
const originalPlatform = process.platform
vi.mock('node:child_process', () => ({
exec: (cmd: string, opts: unknown, cb: ExecCb) => {
h.calls += 1
@@ -39,8 +41,16 @@ async function load(): Promise<typeof import('./meeting-detect')> {
return import('./meeting-detect')
}
function setPlatform(platform: NodeJS.Platform): void {
Object.defineProperty(process, 'platform', {
value: platform,
configurable: true
})
}
beforeEach(() => {
vi.resetModules()
setPlatform('win32')
h.calls = 0
h.execImpl = (_cmd, _opts, cb) => cb(null, { stdout: '' })
h.log.info.mockClear()
@@ -48,6 +58,7 @@ beforeEach(() => {
})
afterEach(() => {
setPlatform(originalPlatform)
vi.restoreAllMocks()
})
@@ -96,14 +107,9 @@ describe('isMeetingActive', () => {
})
it('на не-Windows возвращает false без вызова tasklist', async () => {
const original = process.platform
Object.defineProperty(process, 'platform', { value: 'linux' })
try {
const { isMeetingActive } = await load()
expect(await isMeetingActive()).toBe(false)
expect(h.calls).toBe(0)
} finally {
Object.defineProperty(process, 'platform', { value: original })
}
setPlatform('linux')
const { isMeetingActive } = await load()
expect(await isMeetingActive()).toBe(false)
expect(h.calls).toBe(0)
})
})