feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes
This commit is contained in:
parent
01ef3293cf
commit
66b6b45ba9
399 changed files with 17828 additions and 11330 deletions
|
|
@ -0,0 +1,138 @@
|
|||
import React from 'react'
|
||||
import { act, create, type ReactTestRenderer } from 'react-test-renderer'
|
||||
|
||||
const mockCancelSession = jest.fn(async () => undefined)
|
||||
const mockRequestPermission = jest.fn(async () => false)
|
||||
const mockAcquire = jest.fn(async () => ({
|
||||
restore: async () => ({ state: 'idle', recording: null, meetingId: null, interruptionReason: null }),
|
||||
start: jest.fn(async () => undefined),
|
||||
stop: jest.fn(),
|
||||
cleanup: jest.fn(async () => undefined),
|
||||
cancel: mockCancelSession,
|
||||
pause: jest.fn(async () => undefined),
|
||||
resume: jest.fn(async () => undefined),
|
||||
}))
|
||||
|
||||
const mockAuthValue = { user: { id: '11111111-1111-4111-8111-111111111111' } }
|
||||
const mockT = (key: string): string => key
|
||||
const { d3roNativeDarkPalette } = jest.requireActual('@d3ro/ui-native') as typeof import('@d3ro/ui-native')
|
||||
const mockPreferencesValue = { palette: d3roNativeDarkPalette }
|
||||
|
||||
jest.mock('@react-navigation/native', () => ({
|
||||
useNavigation: () => ({ goBack: jest.fn(), getParent: () => null, setParams: jest.fn() }),
|
||||
}))
|
||||
jest.mock('react-native-safe-area-context', () => ({
|
||||
useSafeAreaInsets: () => ({ top: 0, bottom: 0, left: 0, right: 0 }),
|
||||
}))
|
||||
jest.mock('../src/components/ScreenHeader', () => ({ ScreenHeader: () => null }))
|
||||
jest.mock('@d3ro/i18n', () => ({
|
||||
useI18n: () => ({ t: mockT, locale: 'ko' }),
|
||||
}))
|
||||
jest.mock('../src/lib/auth-context', () => ({
|
||||
useAuth: () => mockAuthValue,
|
||||
}))
|
||||
jest.mock('../src/lib/preferences-context', () => ({
|
||||
useMobilePreferences: () => mockPreferencesValue,
|
||||
}))
|
||||
jest.mock('@d3ro/ui-native', () => {
|
||||
const { Pressable, Text, View } = require('react-native') as typeof import('react-native')
|
||||
const Passthrough = ({ children }: React.PropsWithChildren<Record<string, unknown>>) => <View>{children}</View>
|
||||
return {
|
||||
Led: () => null,
|
||||
WaveBars: () => null,
|
||||
NativeThemeProvider: Passthrough,
|
||||
PhosphorText: ({ children, ...props }: React.PropsWithChildren<Record<string, unknown>>) => (
|
||||
<Text {...props}>{children}</Text>
|
||||
),
|
||||
PhysicalButton: ({ label, onPress, disabled, testID }: {
|
||||
label: string
|
||||
onPress?: () => void
|
||||
disabled?: boolean
|
||||
testID?: string
|
||||
}) => (
|
||||
<Pressable testID={testID} disabled={disabled} onPress={onPress}>
|
||||
<Text>{label}</Text>
|
||||
</Pressable>
|
||||
),
|
||||
d3roNativeFonts: { sans: 'sans' },
|
||||
d3roNativeNumerals: {},
|
||||
}
|
||||
})
|
||||
jest.mock('../src/lib/audio-recorder', () => {
|
||||
class RecorderBusyError extends Error {}
|
||||
return {
|
||||
RecorderBusyError,
|
||||
audioRecorder: {
|
||||
acquire: () => mockAcquire(),
|
||||
requestPermission: () => mockRequestPermission(),
|
||||
},
|
||||
}
|
||||
})
|
||||
jest.mock('../src/features/import/audio-file-picker', () => ({
|
||||
pickAudioFile: jest.fn(),
|
||||
}))
|
||||
jest.mock('../src/features/import/incoming-media-intent', () => ({
|
||||
consumeIncomingMediaAudio: jest.fn(),
|
||||
}))
|
||||
jest.mock('../src/features/notifications/notification-native', () => ({
|
||||
showLocalTranscriptionCompleted: jest.fn(async () => true),
|
||||
}))
|
||||
jest.mock('../src/features/recording/durable-processing-queue', () => {
|
||||
class QueuedAudioPendingError extends Error {}
|
||||
return {
|
||||
QueuedAudioPendingError,
|
||||
discardQueuedAudio: jest.fn(async () => undefined),
|
||||
enqueueAudioProcessing: jest.fn(),
|
||||
processQueuedAudioNow: jest.fn(),
|
||||
retryQueuedAudio: jest.fn(async () => undefined),
|
||||
subscribeToDurableQueue: () => () => undefined,
|
||||
}
|
||||
})
|
||||
jest.mock('../src/features/meetings/meetings-service', () => ({
|
||||
beginMeetingRecording: jest.fn(),
|
||||
cancelMeetingRecording: jest.fn(),
|
||||
failMeetingRecording: jest.fn(),
|
||||
getMeetingRecordingLanguage: jest.fn(async () => 'ko'),
|
||||
}))
|
||||
|
||||
import RecordScreen from '../src/screens/RecordScreen'
|
||||
|
||||
describe('RecordScreen permission denial session cleanup', () => {
|
||||
let renderer: ReactTestRenderer | null = null
|
||||
|
||||
beforeEach(() => {
|
||||
mockCancelSession.mockClear()
|
||||
mockAcquire.mockClear()
|
||||
mockRequestPermission.mockReset().mockResolvedValue(false)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
if (renderer !== null) {
|
||||
act(() => renderer!.unmount())
|
||||
renderer = null
|
||||
}
|
||||
})
|
||||
|
||||
test('startRecording_마이크권한거부시_acquire한세션을cancel하여리스를반환', async () => {
|
||||
await act(async () => {
|
||||
renderer = create(
|
||||
<RecordScreen
|
||||
navigation={{ goBack: jest.fn(), getParent: () => null, setParams: jest.fn() } as never}
|
||||
route={{ params: {} } as never}
|
||||
/>,
|
||||
)
|
||||
await Promise.resolve()
|
||||
})
|
||||
|
||||
mockAcquire.mockClear()
|
||||
await act(async () => {
|
||||
renderer!.root.findByProps({ testID: 'record-start' }).props.onPress()
|
||||
await Promise.resolve()
|
||||
await Promise.resolve()
|
||||
})
|
||||
|
||||
expect(mockAcquire).toHaveBeenCalledTimes(1)
|
||||
expect(mockCancelSession).toHaveBeenCalledTimes(1)
|
||||
expect(JSON.stringify(renderer!.toJSON())).toContain('mobile.rec.micDenied')
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue