Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(web): expose the voice recording timer (#40205)

yyh47835e6b25d3
diff --git a/e2e/features/step-definitions/agent-v2/speech-to-text.steps.ts b/e2e/features/step-definitions/agent-v2/speech-to-text.steps.ts
index b0a0d36afbc..07187edf69d 100644
--- a/e2e/features/step-definitions/agent-v2/speech-to-text.steps.ts
+++ b/e2e/features/step-definitions/agent-v2/speech-to-text.steps.ts
@@ -50,10 +50,9 @@ When(
const page = this.getPage()
const agentId = getCurrentAgentId(this)
- await expect(page.getByTestId('voice-input-timer')).toHaveText(
- voiceInputTestMaterial.recordingDuration,
- { timeout: 15_000 },
- )
+ await expect(page.getByRole('timer')).toHaveText(voiceInputTestMaterial.recordingDuration, {
+ timeout: 15_000,
+ })
const responsePromise = page.waitForResponse(
(response) =>
diff --git a/web/app/components/base/voice-input/__tests__/index.spec.tsx b/web/app/components/base/voice-input/__tests__/index.spec.tsx
index 699d78f6076..10548b08e22 100644
--- a/web/app/components/base/voice-input/__tests__/index.spec.tsx
+++ b/web/app/components/base/voice-input/__tests__/index.spec.tsx
@@ -101,7 +101,7 @@ describe('VoiceInput', () => {
expect(await screen.findByText('common.voiceInput.speaking')).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'common.voiceInput.stop' })).toBeInTheDocument()
- expect(screen.getByTestId('voice-input-timer')).toHaveTextContent('00:00')
+ expect(screen.getByRole('timer')).toHaveTextContent('00:00')
expect(getByteFrequencyData).toHaveBeenCalledTimes(1)
})
@@ -301,7 +301,7 @@ describe('VoiceInput', () => {
act(() => vi.advanceTimersByTime(1000))
- expect(screen.getByTestId('voice-input-timer')).toHaveTextContent('00:01')
+ expect(screen.getByRole('timer')).toHaveTextContent('00:01')
})
it('should stop automatically at ten minutes', async () => {
@@ -312,7 +312,7 @@ describe('VoiceInput', () => {
await act(async () => {})
expect(recorderStop).toHaveBeenCalledTimes(1)
- expect(screen.getByTestId('voice-input-timer')).toHaveTextContent('10:00')
+ expect(screen.getByRole('timer')).toHaveTextContent('10:00')
})
})
})
diff --git a/web/app/components/base/voice-input/index.tsx b/web/app/components/base/voice-input/index.tsx
index e86c3101806..8620127a708 100644
--- a/web/app/components/base/voice-input/index.tsx
+++ b/web/app/components/base/voice-input/index.tsx
@@ -249,11 +249,11 @@ function VoiceInput({
</button>
)}
<div
+ role="timer"
className={cn(
'w-11.25 pl-1 text-xs font-medium',
duration > 500 ? 'text-text-destructive' : 'text-text-secondary',
)}
- data-testid="voice-input-timer"
>
{`${minutes}:${seconds}`}
</div>