|
16 | 16 | Test: Mute/Unmute functionality for Speech-to-Speech |
17 | 17 | |
18 | 18 | This test validates: |
19 | | - 1. Mute is allowed from all state except idle |
20 | | - 2. When muted during listening, chunks contain all zeros (silent audio) |
21 | | - 3. When unmuted, chunks contain real audio |
22 | | - 4. Mute resets to false when recording stops |
23 | | - 5. Stopping while muted does NOT re-acquire microphone (cleanup order test) |
24 | | - 6. Uses useVoiceRecordingMuted hook for mute/unmute control |
| 19 | + 1. Mute is independent of voiceState - can be toggled anytime |
| 20 | + 2. Starting recording while muted should reset and start recording always unmuted. |
| 21 | + 3. When muted during listening, chunks contain all zeros (silent audio) |
| 22 | + 4. When unmuted, chunks contain real audio |
| 23 | + 5. Mute resets to false when recording stops |
| 24 | + 6. Stopping while muted does NOT re-acquire microphone (cleanup order test) |
| 25 | + 7. Uses useVoiceRecordingMuted hook for mute/unmute control |
25 | 26 | --> |
26 | 27 | <script type="module"> |
27 | 28 | import { setupMockMediaDevices } from '/assets/esm/speechToSpeech/mockMediaDevices.js'; |
|
123 | 124 | const micButton = document.querySelector(`[data-testid="${testIds.sendBoxMicrophoneButton}"]`); |
124 | 125 | expect(micButton).toBeTruthy(); |
125 | 126 |
|
126 | | - // ===== TEST 1: Muting from idle state should be no-op ===== |
| 127 | + // ===== TEST 1: Muting from idle state should work as independent from voice state ===== |
127 | 128 | expect(getVoiceState()).toBe('idle'); |
128 | 129 | expect(muteControlRef.muted).toBe(false); |
129 | 130 |
|
130 | 131 | muteControlRef.setMuted(true); |
131 | 132 | await new Promise(r => setTimeout(r, 100)); |
132 | 133 |
|
133 | 134 | expect(getVoiceState()).toBe('idle'); // Still idle, not muted |
134 | | - expect(muteControlRef.muted).toBe(false); |
| 135 | + expect(muteControlRef.muted).toBe(true); |
135 | 136 |
|
136 | | - // ===== TEST 2: Start recording → listening state ===== |
| 137 | + // ===== TEST 2: Start recording → listening state, microphoneMuted resets to false ===== |
137 | 138 | await host.click(micButton); |
138 | 139 |
|
139 | 140 | await pageConditions.became( |
|
142 | 143 | 2000 |
143 | 144 | ); |
144 | 145 |
|
| 146 | + // Starting recording resets microphoneMuted to false. |
| 147 | + // This ensures a clean slate - recording always starts unmuted. |
| 148 | + expect(muteControlRef.muted).toBe(false); |
| 149 | + |
145 | 150 | // Wait for some listening chunks |
146 | 151 | await pageConditions.became( |
147 | 152 | 'At least 2 listening chunks received', |
|
0 commit comments