mirror of
https://github.com/Melorise/TamaASR.git
synced 2026-11-07 14:39:32 +00:00
停止请求早于网页录音状态落地时,等待实际进入录音后再点击一次停止;网页仍在录音或尚未点击停止时不再完成外部会话。 AI-assisted-by: Codex AI-model: gpt-5.6-sol AI-reasoning-effort: medium Co-authored-by: Codex <codex@openai.com>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { shouldFinishAfterStop } from '../src/preload/stop-completion';
|
|
|
|
const base = {
|
|
elapsedMs: 700,
|
|
quietMs: 500,
|
|
stopClicked: true,
|
|
isRecording: false,
|
|
minimumWaitMs: 250,
|
|
quietWindowMs: 450,
|
|
timeoutMs: 4_500
|
|
};
|
|
|
|
test('网页仍在录音时不得提前提交', () => {
|
|
assert.equal(shouldFinishAfterStop({ ...base, isRecording: true }), false);
|
|
});
|
|
|
|
test('尚未点击停止时不得提交', () => {
|
|
assert.equal(shouldFinishAfterStop({ ...base, stopClicked: false }), false);
|
|
});
|
|
|
|
test('网页结束且最终文本静默窗口满足时立即提交', () => {
|
|
assert.equal(shouldFinishAfterStop(base), true);
|
|
});
|
|
|
|
test('网页结束后仍有文本修正时继续等待', () => {
|
|
assert.equal(shouldFinishAfterStop({ ...base, quietMs: 120 }), false);
|
|
});
|
|
|
|
test('网页仍在录音时超时也不得提交', () => {
|
|
assert.equal(shouldFinishAfterStop({ ...base, elapsedMs: 4_500, isRecording: true }), false);
|
|
});
|
|
|
|
test('网页已停止时超时可以结束静默等待', () => {
|
|
assert.equal(shouldFinishAfterStop({ ...base, elapsedMs: 4_500, quietMs: 120 }), true);
|
|
});
|