Skip to content

Commit e764f44

Browse files
committed
FIX: 稳定 TTS 预览竞态测试
1 parent febe6e6 commit e764f44

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

TASKS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118

119119
## 最近完成(保留近两周)
120120

121+
- [x] 2026-07-20 23:04:修复 CI 中 TTS controller 预览竞态单测偶发失败。`previewVoice 同一 speakingKey 连续发音` 用例不再依赖固定 `pumpEventQueue()` 次数,而是等待 fake engine 收到指定数量的合成 gate,避免 CI 机器调度较慢时在首个合成请求入队前误判失败;补跑相关 analyze 与单测。
121122
- [x] 2026-07-20 21:39:补充 AI 转录远程时长限制业务入口回归测试,验证默认允许的 2 分钟音频在远程 1 分钟限制下会被字幕管理弹窗正确拦截并展示远程限制值。
122123
- [x] 2026-07-20 21:12:AI 转录音频限制接入 remote app config。后端 `/api/v1/client/config` 新增 `limits.transcription.maxDurationSeconds/maxUploadBytes` resolved 配置,默认 30 分钟 / 50MB;Flutter remote config 新增 `RemoteTranscriptionLimits``remoteTranscriptionLimitsProvider`,AI 转录入口的时长和文件大小预校验改为读取远程配置,缺失或非法值回退本地默认;补充 remote config 解析、provider 和后端 route 回归测试。
123124
- [x] 2026-07-20 16:37:CI 测试结果判定改按 `testDone` 明细。GitHub Actions 全量测试继续保留 JSON reporter,但不再把 `done.success` 作为唯一失败依据;脚本逐条解析 `testDone`,只有存在 `failure` / `error` 用例才失败,并按 `error` 事件关联打印测试名称、错误和堆栈;没有失败用例且存在 `done` 事件时允许通过,同时上传 `test-results.json` artifact 便于后续排查 Flutter runner 收尾误报。

test/providers/tts/tts_controller_preview_test.dart

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ class _GateEngine implements TtsEngine {
103103
Future<void> dispose() async {}
104104
}
105105

106+
/// 等待 fake 引擎收到指定数量的合成请求,避免测试依赖固定 event queue 次数。
107+
Future<void> _waitForGateCount(_GateEngine engine, int count) async {
108+
await expectLater(
109+
Stream<void>.periodic(
110+
const Duration(milliseconds: 1),
111+
).map((_) => engine.gates.length),
112+
emitsThrough(count),
113+
);
114+
}
115+
106116
class _FakeTtsCacheDao implements TtsCacheDao {
107117
@override
108118
Future<TtsCacheData?> getByKey(String cacheKey, {Duration? slideTtl}) async =>
@@ -219,8 +229,7 @@ void main() {
219229
final notifier = c.read(ttsControllerProvider.notifier);
220230
await Future<void>(() {}); // 等首次 configure 落定
221231
final first = notifier.speak('first text', key: 'same_voice');
222-
await pumpEventQueue();
223-
expect(engine.gates, hasLength(1));
232+
await _waitForGateCount(engine, 1);
224233

225234
final second = notifier.speak('second text', key: 'same_voice');
226235
await pumpEventQueue();
@@ -229,8 +238,7 @@ void main() {
229238
expect(c.read(ttsControllerProvider).speakingKey, 'same_voice');
230239

231240
engine.gates[0].complete();
232-
await pumpEventQueue();
233-
expect(engine.gates, hasLength(2));
241+
await _waitForGateCount(engine, 2);
234242
await first;
235243
expect(c.read(ttsControllerProvider).speakingKey, 'same_voice');
236244

0 commit comments

Comments
 (0)