feat(profile): avatar presets, upload, nickname editing

- FastAPI: preset assets 01–08, GET list/static, PUT /me/avatar/preset,
  safer uploaded-avatar path validation, preset_avatars + HTTP tests.
- Expo: personal-info (library + presets), profile tab avatar,
  resolveApiMediaUrl, auth hooks cache sync, Web multipart helper,
  partial-save messaging + profile i18n.
- Includes existing edits to conversation screen and voice use-player.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Kevin
2026-05-06 13:51:43 +08:00
parent 59d4b19d7d
commit 7ad52fce89
27 changed files with 1271 additions and 270 deletions

View File

@@ -1,5 +1,6 @@
import { renderHook } from '@testing-library/react-native';
import { act, renderHook } from '@testing-library/react-native';
import { audioFocus } from '@/core/audio/audio-focus';
import { usePlayer } from '@/features/voice/hooks/use-player';
const mockUseAudioPlayer = jest.fn();
@@ -34,6 +35,8 @@ describe('usePlayer', () => {
currentTime: 0,
duration: 0,
});
jest.mocked(audioFocus.acquireForPlayback).mockResolvedValue(true);
jest.mocked(audioFocus.releaseIfOwnedBy).mockResolvedValue(undefined);
});
test('keeps the native audio session active while app-level audio focus owns teardown', () => {
@@ -47,4 +50,81 @@ describe('usePlayer', () => {
}),
);
});
test('pausePlayback toggles playing→paused and invokes native pause', async () => {
mockUseAudioPlayerStatus.mockReturnValue({
isLoaded: true,
playing: true,
currentTime: 0.1,
duration: 10,
});
const pause = jest.fn();
const play = jest.fn();
mockUseAudioPlayer.mockReturnValue({ pause, play });
const { result } = renderHook(() => usePlayer());
await act(async () => {
await result.current.enqueueExclusive({
uri: 'file:///fixture.mp3',
kind: 'voice',
});
});
expect(result.current.status).toBe('playing');
act(() => {
result.current.pausePlayback();
});
expect(pause).toHaveBeenCalled();
expect(result.current.status).toBe('paused');
});
test('resumePlayback toggles paused→playing and invokes native play', async () => {
mockUseAudioPlayerStatus.mockReturnValue({
isLoaded: true,
playing: false,
currentTime: 0.1,
duration: 10,
});
const pause = jest.fn();
const play = jest.fn();
mockUseAudioPlayer.mockReturnValue({ pause, play });
const { result } = renderHook(() => usePlayer());
await act(async () => {
await result.current.enqueueExclusive({
uri: 'file:///fixture.mp3',
kind: 'voice',
});
});
act(() => {
result.current.pausePlayback();
});
expect(result.current.status).toBe('paused');
await act(async () => {
await result.current.resumePlayback();
});
expect(play).toHaveBeenCalled();
expect(result.current.status).toBe('playing');
});
test('pausePlayback is a no-op while idle', async () => {
const pause = jest.fn();
mockUseAudioPlayer.mockReturnValue({ pause, play: jest.fn() });
const { result } = renderHook(() => usePlayer());
act(() => {
result.current.pausePlayback();
});
expect(pause).not.toHaveBeenCalled();
expect(result.current.status).toBe('idle');
});
});