fix: 修复 Windows CI 两个单元测试失败

after-pack-signing:断言改用 POSIX 归一化,消除同一文件里 join() 与硬编码斜杠混用
voice-recognition:用例改用内存库与纯字符串路径,去掉落盘 SQLite 与临时目录删除
This commit is contained in:
Wxw-Gu committed 2026-10-14 11:35:16 +08:00
1 parent eaa25cd29e
commit 72812447fd
2 files changed
+26 -15

No files matched your search

+12 -3
View File
@@ -1,7 +1,7 @@
import { createRequire } from 'module'
import { mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from 'fs'
import { tmpdir } from 'os'
import { join } from 'path'
import { join, sep } from 'path'
import { afterAll, describe, expect, it } from 'vitest'
const nodeRequire = createRequire(import.meta.url)
@@ -94,7 +94,16 @@ function fixtureApp(): string {
}
const app = fixtureApp()
const relative = (target: string): string => target.slice(app.length + 1)
/**
* 归一化成 POSIX 风格再断言。
*
* `findNestedMacosCodePaths()` 返回的是**平台原生路径**(Windows runner 上是反斜杠),
* 而这一组用例验证的是**签名顺序算法** —— 谁必须排在谁前面 —— 跟分隔符毫无关系。
* 归一化之后,层次可以直接用 `Contents/Frameworks/...` 这样的字面量表达,
* 既读得懂,也不会再出现"同一文件里一半 `join()`、一半硬编码斜杠"的混用。
*/
const relative = (target: string): string =>
target.slice(app.length + 1).split(sep).join('/')
describe('macOS nested code signing order', () => {
afterAll(() => rmSync(root, { recursive: true, force: true }))
@@ -102,7 +111,7 @@ describe('macOS nested code signing order', () => {
it('signs nested code inside-out and ignores resources and symlinks', () => {
const paths = findNestedMacosCodePaths(app).map(relative)
expect(paths).toContain(join('Contents', 'MacOS', 'TraceMemo'))
expect(paths).toContain('Contents/MacOS/TraceMemo')
expect(paths).not.toContain(app)
expect(paths.some((entry) => entry.includes('Resources'))).toBe(false)
expect(paths.some((entry) => entry.endsWith('.md'))).toBe(false)
+14 -12
View File
@@ -1,17 +1,23 @@
import { mkdtempSync, rmSync } from 'fs'
import { tmpdir } from 'os'
import { join } from 'path'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { describe, expect, it, vi } from 'vitest'
import { VoiceRecognitionUseCase } from '../../src/main/voice-pipeline/voice-recognition-use-case'
const roots: string[] = []
/**
* 这组用例验证的是**转写更新的编排**:命中缓存/新识别是否走同一条 update path、
* 账号代号中途变化时是否取消发布、force 是否透传给 pipeline。真正的
* `pipeline.run` 与 `modelManager.getStatus` 都被 mock,所以**不需要真实的
* 文件系统或 SQLite**。
*
* 用内存库 + 纯字符串路径(不建目录、不落盘、不删除):
* `SqliteTranscriptRepository` 一旦落盘就会连带生成 `-wal` / `-shm`,
* 每个用例还要 `rmSync` 整棵临时树 —— 这些在 Windows runner 上(Defender 实时扫描
* 每次文件创建/删除)会放大到秒级,而对被测行为零贡献。
*/
function createUseCase(): VoiceRecognitionUseCase {
const root = mkdtempSync(join(tmpdir(), 'wxe-voice-use-case-'))
roots.push(root)
const root = join('wxe-voice-use-case-fixture', 'account-a')
const useCase = new VoiceRecognitionUseCase({
modelRoot: join(root, 'model'),
databasePath: join(root, 'transcripts.sqlite'),
databasePath: ':memory:',
workerPath: join(root, 'unused-worker.js')
})
const state = useCase as unknown as {
@@ -36,10 +42,6 @@ function createUseCase(): VoiceRecognitionUseCase {
return useCase
}
afterEach(async () => {
for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true })
})
describe('VoiceRecognitionUseCase transcript updates', () => {
it('publishes a successful cache hit through the same update path as fresh recognition', async () => {
const useCase = createUseCase()