The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(voiceNotes): cover mascot viseme ownership and playback sampling
Steven Enamakel3f9a5d1be111
diff --git a/app/src/features/human/chatMascot/ChatMascotOverlay.test.tsx b/app/src/features/human/chatMascot/ChatMascotOverlay.test.tsxindex 5c1f0ef55b..57ff8903ea 100644--- a/app/src/features/human/chatMascot/ChatMascotOverlay.test.tsx+++ b/app/src/features/human/chatMascot/ChatMascotOverlay.test.tsx@@ -207,6 +207,23 @@ describe('ChatMascotOverlay', () => {expect(screen.getAllByTestId('mascot-rive')).toHaveLength(1);});+ it('ignores cleanup from an older replay owner after another reply takes over', () => {+ renderOverlay(true);+ const publish = (owner: string, active: boolean, viseme: string) =>+ window.dispatchEvent(+ new CustomEvent('voice-note-mascot', { detail: { owner, active, viseme } })+ );++ act(() => publish('reply-a', true, 'aa'));+ expect(screen.getByTestId('mascot-rive')).toHaveAttribute('data-viseme', 'aa');+ act(() => publish('reply-b', true, 'PP'));+ expect(screen.getByTestId('mascot-rive')).toHaveAttribute('data-viseme', 'PP');+ act(() => publish('reply-a', false, 'sil'));+ expect(screen.getByTestId('mascot-rive')).toHaveAttribute('data-viseme', 'PP');+ act(() => publish('reply-b', false, 'sil'));+ expect(screen.getByTestId('mascot-rive')).toHaveAttribute('data-viseme', 'sil');+ });+it('stays hidden until an anchor is measurable, then lands on it', () => {// The dock can mount after the overlay. A ResizeObserver can only watch// elements that already exist, so without the poll a late anchor woulddiff --git a/app/src/features/voiceNotes/VoiceNotePlayer.test.tsx b/app/src/features/voiceNotes/VoiceNotePlayer.test.tsxindex 7cb4a79e8c..541bc6c499 100644--- a/app/src/features/voiceNotes/VoiceNotePlayer.test.tsx+++ b/app/src/features/voiceNotes/VoiceNotePlayer.test.tsx@@ -1,4 +1,4 @@-import { fireEvent, render, screen, waitFor } from '@testing-library/react';+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { VoiceNotePlayer } from './VoiceNotePlayer';@@ -109,6 +109,57 @@ describe('VoiceNotePlayer', () => {window.removeEventListener('voice-note-mascot', onPlayback);});+ it('keeps mascot playback silenced if a paused audio element reports a late timeupdate', async () => {+ const onPlayback = vi.fn();+ window.addEventListener('voice-note-mascot', onPlayback);+ render(+ <VoiceNotePlayer+ src="blob:reply"+ mascotPlayback+ visemes={[{ viseme: 'aa', start_ms: 0, end_ms: 500 }]}+ />+ );+ fireEvent.click(screen.getByTestId('voice-note-toggle'));+ await waitFor(() => expect(onPlayback.mock.calls.at(-1)?.[0].detail.active).toBe(true));+ const audio = FakeAudio.last!;+ audio.pause();+ audio.currentTime = 0.2;+ audio.emit('timeupdate');+ expect(onPlayback.mock.calls.at(-1)?.[0].detail.active).toBe(false);+ window.removeEventListener('voice-note-mascot', onPlayback);+ });++ it('samples reply visemes during playback between media timeupdate events', async () => {+ let frame: FrameRequestCallback | undefined;+ const cancel = vi.fn();+ vi.stubGlobal('requestAnimationFrame', (callback: FrameRequestCallback) => {+ frame = callback;+ return 1;+ });+ vi.stubGlobal('cancelAnimationFrame', cancel);+ const onPlayback = vi.fn();+ window.addEventListener('voice-note-mascot', onPlayback);+ render(+ <VoiceNotePlayer+ src="blob:reply"+ mascotPlayback+ visemes={[+ { viseme: 'aa', start_ms: 0, end_ms: 100 },+ { viseme: 'PP', start_ms: 100, end_ms: 500 },+ ]}+ />+ );+ fireEvent.click(screen.getByTestId('voice-note-toggle'));+ await waitFor(() => expect(frame).toBeTypeOf('function'));+ const audio = FakeAudio.last!;+ audio.currentTime = 0.25;+ act(() => frame?.(16));+ expect(onPlayback.mock.calls.at(-1)?.[0].detail).toMatchObject({ active: true, viseme: 'PP' });+ audio.pause();+ expect(cancel).toHaveBeenCalled();+ window.removeEventListener('voice-note-mascot', onPlayback);+ });+it('shows an error when the core has no audio for the note', async () => {api.readVoiceNote.mockResolvedValue(null);render(<VoiceNotePlayer noteId="missing" />);diff --git a/app/test/e2e/specs/chat-voice-note.spec.ts b/app/test/e2e/specs/chat-voice-note.spec.tsindex 7e4f5791a5..fd6f938dbc 100644--- a/app/test/e2e/specs/chat-voice-note.spec.ts+++ b/app/test/e2e/specs/chat-voice-note.spec.ts@@ -13,6 +13,7 @@ import {countTestId,textExists,waitForTestId,+ waitForTestIdAtIndex,} from '../helpers/element-helpers';import { resetApp } from '../helpers/reset-app';import { navigateViaHash } from '../helpers/shared-flows';@@ -158,11 +159,7 @@ describe('Chat voice notes', () => {await clickTestIdAtIndex('voice-note-toggle', 1);await browser.waitUntil(async () =>- (await (await (await import('../helpers/element-helpers')).waitForTestIdAtIndex(- 'voice-note-toggle',- 1- )).getAttribute('aria-label'))- ?.getAttribute('aria-label')+ (await (await waitForTestIdAtIndex('voice-note-toggle', 1)).getAttribute('aria-label'))?.toLowerCase().includes('pause'),{ timeout: 5_000 }