Skip to content

test: align websocket handler tests with session pipeline#10

Merged
ailuckly merged 1 commit into
developfrom
feat/realtime-voice-stt-p0-p1
Apr 11, 2026
Merged

test: align websocket handler tests with session pipeline#10
ailuckly merged 1 commit into
developfrom
feat/realtime-voice-stt-p0-p1

Conversation

@ailuckly
Copy link
Copy Markdown
Owner

📌 变更内容

  • 如:新增用户登录 API
  • 如:修复登录失败时错误提示

✅ 测试验证

  • 本地运行通过
  • 自测通过
  • CI 流水线通过

PR 提交规范提醒:

  • 确保提交主题信息符合约定式提交规范 (feat/fix/docs/style/refactor/test/chore)
  • 确保代码已经通过本地测试
  • 确保没有提交敏感信息(密码、密钥等)

Copilot AI review requested due to automatic review settings April 11, 2026 03:56
@ailuckly ailuckly merged commit f086e0f into develop Apr 11, 2026
2 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the AiChatWebSocketHandler unit tests to match the new session-based streaming pipeline (StreamingPipelineOrchestrator + PipelineEvent) rather than the legacy AiStreamingService/voiceSessions flow.

Changes:

  • Refactors tests to mock StreamingPipelineOrchestrator.processVoiceMessage(...) and assert PipelineEvent-driven behavior.
  • Updates session lifecycle assertions to align with the handler’s sessions + SessionState model.
  • Adds coverage for forwarding binary WebSocket frames into the active audio sink.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +258 to +263
private void assertSessionAudioClosed() {
Object sessionState = sessions().get(SESSION_ID);
Object audioSink = ReflectionTestUtils.getField(sessionState, "audioSink");
Object pipelineSubscription = ReflectionTestUtils.getField(sessionState, "pipelineSubscription");
assertEquals(null, audioSink);
assertEquals(null, pipelineSubscription);
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use assertNull(...) (and optionally an assertion message) instead of assertEquals(null, ...) for clearer intent and better failure output when checking that audioSink / pipelineSubscription have been cleared.

Copilot uses AI. Check for mistakes.
Comment on lines +247 to +252
private void installSessionState(WebSocketSession session, StreamingPipelineOrchestrator orchestrator) throws Exception {
Class<?> sessionStateClass = Class.forName("com.vocata.ai.websocket.AiChatWebSocketHandler$SessionState");
Constructor<?> constructor = sessionStateClass.getDeclaredConstructor(StreamingPipelineOrchestrator.class);
constructor.setAccessible(true);
Object sessionState = constructor.newInstance(orchestrator);

Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test setup currently constructs the private inner class AiChatWebSocketHandler$SessionState via reflection (Class.forName + setAccessible). This couples the tests to handler internals and makes them brittle under refactors. If feasible, consider adding a small package-private/@VisibleForTesting hook on AiChatWebSocketHandler to register a mocked StreamingPipelineOrchestrator for a session (or extracting SessionState into a package-private type) so tests can avoid reflective access.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants