feat(mobile): share history as Markdown or original audio and harden the E2E gate
Adds history share (Markdown file / original audio) with 12-locale strings, pins Maestro to the target device with --udid, allows cleartext only for explicit local E2E artifacts, and fixes small-screen scroll/keyboard races in the Maestro flows. Evidence: docs/evidence/2026-11-17-backlog-operations.md.
This commit is contained in:
parent
e0b1ceaa75
commit
8d8aaf5794
29 changed files with 627 additions and 26 deletions
|
|
@ -69,6 +69,28 @@ jest.mock('../src/features/history/history-service', () => {
|
|||
}
|
||||
})
|
||||
|
||||
const mockPrepareTranscriptShareFile = jest.fn()
|
||||
const mockPrepareAudioShareFile = jest.fn()
|
||||
const mockSharePreparedPortableFile = jest.fn()
|
||||
const mockDisposePreparedFile = jest.fn(async () => undefined)
|
||||
const PREPARED_FILE = {
|
||||
path: '/cache/portable_exports/transcript.md',
|
||||
uri: 'file:///cache/portable_exports/transcript.md',
|
||||
fileName: 'transcript.md',
|
||||
mimeType: 'text/markdown',
|
||||
format: 'md',
|
||||
textContent: 'transcript',
|
||||
dispose: mockDisposePreparedFile,
|
||||
}
|
||||
|
||||
jest.mock('../src/features/history/history-share', () => ({
|
||||
prepareTranscriptShareFile: (...args: unknown[]) => mockPrepareTranscriptShareFile(...args),
|
||||
prepareAudioShareFile: (...args: unknown[]) => mockPrepareAudioShareFile(...args),
|
||||
}))
|
||||
jest.mock('../src/features/data-portability/portable-file', () => ({
|
||||
sharePreparedPortableFile: (...args: unknown[]) => mockSharePreparedPortableFile(...args),
|
||||
}))
|
||||
|
||||
import HistoryDetailScreen from '../src/screens/HistoryDetailScreen'
|
||||
|
||||
const SAMPLE_DETAIL: HistoryDetail = {
|
||||
|
|
@ -129,7 +151,11 @@ describe('HistoryDetailScreen unmount audio & async cleanup', () => {
|
|||
mockPausePlayer.mockClear()
|
||||
mockResumePlayer.mockClear()
|
||||
mockGetHistoryDetail.mockReset().mockResolvedValue(SAMPLE_DETAIL)
|
||||
mockCreateAudioPlaybackUrl.mockReset()
|
||||
mockCreateAudioPlaybackUrl.mockReset().mockResolvedValue('https://storage.example/signed.wav')
|
||||
mockPrepareTranscriptShareFile.mockReset().mockResolvedValue(PREPARED_FILE)
|
||||
mockPrepareAudioShareFile.mockReset().mockResolvedValue(PREPARED_FILE)
|
||||
mockSharePreparedPortableFile.mockReset().mockResolvedValue(undefined)
|
||||
mockDisposePreparedFile.mockClear()
|
||||
mockGoBack.mockClear()
|
||||
})
|
||||
|
||||
|
|
@ -181,4 +207,85 @@ describe('HistoryDetailScreen unmount audio & async cleanup', () => {
|
|||
})
|
||||
expect(mockStartPlayer).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('HistoryDetailScreen_Markdown버튼_파일생성및공유호출', async () => {
|
||||
let renderer!: ReactTestRenderer
|
||||
await act(async () => {
|
||||
renderer = create(
|
||||
<HistoryDetailScreen
|
||||
route={{ key: 'HistoryDetail-2', name: 'HistoryDetail', params: { historyId: HISTORY_ID } }}
|
||||
navigation={{ goBack: mockGoBack } as never}
|
||||
/>,
|
||||
)
|
||||
})
|
||||
|
||||
await act(async () => {
|
||||
renderer.root.findByProps({ testID: 'history-detail-share-markdown' }).props.onPress()
|
||||
await Promise.resolve()
|
||||
})
|
||||
|
||||
expect(mockPrepareTranscriptShareFile).toHaveBeenCalledWith(
|
||||
SAMPLE_DETAIL.entry,
|
||||
'md',
|
||||
'mobile.hist.summaryLabel',
|
||||
)
|
||||
expect(mockSharePreparedPortableFile).toHaveBeenCalledWith(PREPARED_FILE, 'mobile.hist.shareMarkdown')
|
||||
act(() => renderer.unmount())
|
||||
})
|
||||
|
||||
test('HistoryDetailScreen_원본오디오버튼_서명URL다운로드후공유', async () => {
|
||||
let renderer!: ReactTestRenderer
|
||||
await act(async () => {
|
||||
renderer = create(
|
||||
<HistoryDetailScreen
|
||||
route={{ key: 'HistoryDetail-3', name: 'HistoryDetail', params: { historyId: HISTORY_ID } }}
|
||||
navigation={{ goBack: mockGoBack } as never}
|
||||
/>,
|
||||
)
|
||||
})
|
||||
|
||||
await act(async () => {
|
||||
renderer.root.findByProps({ testID: `history-audio-share-${AUDIO_ID}` }).props.onPress()
|
||||
await Promise.resolve()
|
||||
})
|
||||
|
||||
expect(mockCreateAudioPlaybackUrl).toHaveBeenCalledWith(USER_ID, SAMPLE_DETAIL.audioFiles[0])
|
||||
expect(mockPrepareAudioShareFile).toHaveBeenCalledWith(
|
||||
SAMPLE_DETAIL.audioFiles[0],
|
||||
'https://storage.example/signed.wav',
|
||||
)
|
||||
expect(mockSharePreparedPortableFile).toHaveBeenCalledWith(PREPARED_FILE, 'mobile.hist.shareAudio')
|
||||
act(() => renderer.unmount())
|
||||
})
|
||||
|
||||
test('HistoryDetailScreen_공유준비중언마운트_늦은공유시트를열지않고파일정리', async () => {
|
||||
let resolvePreparation: (file: typeof PREPARED_FILE) => void = () => undefined
|
||||
mockPrepareAudioShareFile.mockImplementation(
|
||||
() => new Promise<typeof PREPARED_FILE>((resolve) => {
|
||||
resolvePreparation = resolve
|
||||
}),
|
||||
)
|
||||
let renderer!: ReactTestRenderer
|
||||
await act(async () => {
|
||||
renderer = create(
|
||||
<HistoryDetailScreen
|
||||
route={{ key: 'HistoryDetail-4', name: 'HistoryDetail', params: { historyId: HISTORY_ID } }}
|
||||
navigation={{ goBack: mockGoBack } as never}
|
||||
/>,
|
||||
)
|
||||
})
|
||||
|
||||
await act(async () => {
|
||||
renderer.root.findByProps({ testID: `history-audio-share-${AUDIO_ID}` }).props.onPress()
|
||||
await Promise.resolve()
|
||||
})
|
||||
act(() => renderer.unmount())
|
||||
await act(async () => {
|
||||
resolvePreparation(PREPARED_FILE)
|
||||
await Promise.resolve()
|
||||
})
|
||||
|
||||
expect(mockSharePreparedPortableFile).not.toHaveBeenCalled()
|
||||
expect(mockDisposePreparedFile).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
92
apps/mobile-rn/__tests__/history-share.test.ts
Normal file
92
apps/mobile-rn/__tests__/history-share.test.ts
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
import { FileSystem } from 'react-native-file-access';
|
||||
import {
|
||||
MAX_SHARED_AUDIO_BYTES,
|
||||
prepareAudioShareFile,
|
||||
prepareTranscriptShareFile,
|
||||
} from '../src/features/history/history-share';
|
||||
|
||||
jest.mock('react-native-file-access', () => ({
|
||||
Dirs: { CacheDir: '/cache' },
|
||||
FileSystem: {
|
||||
exists: jest.fn(async () => true),
|
||||
mkdir: jest.fn(async () => undefined),
|
||||
writeFile: jest.fn(async () => undefined),
|
||||
stat: jest.fn(async () => ({ size: 1 })),
|
||||
unlink: jest.fn(async () => undefined),
|
||||
},
|
||||
}));
|
||||
|
||||
const ENTRY = {
|
||||
title: '주간 회의',
|
||||
original_text: '원문',
|
||||
polished_text: '다듬은 전사',
|
||||
summary_text: '요약 내용',
|
||||
};
|
||||
|
||||
describe('기록 파일 공유', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('다듬은 전사와 요약을 Markdown 파일로 저장한다', async () => {
|
||||
const file = await prepareTranscriptShareFile(ENTRY, 'md', '요약');
|
||||
|
||||
const write = jest.mocked(FileSystem.writeFile);
|
||||
expect(file.format).toBe('md');
|
||||
expect(file.mimeType).toBe('text/markdown');
|
||||
expect(file.fileName.endsWith('.md')).toBe(true);
|
||||
expect(write.mock.calls[0]?.[1]).toBe('# 주간 회의\n\n다듬은 전사\n\n## 요약\n\n요약 내용');
|
||||
});
|
||||
|
||||
it('다듬은 값이 비어 있으면 원문으로 텍스트 파일을 만든다', async () => {
|
||||
await prepareTranscriptShareFile({ ...ENTRY, polished_text: ' ' }, 'txt', '요약');
|
||||
|
||||
expect(jest.mocked(FileSystem.writeFile).mock.calls[0]?.[1]).toBe('주간 회의\n\n원문\n\n요약\n\n요약 내용');
|
||||
});
|
||||
|
||||
it('사용자가 선택한 원본 오디오를 제한 안에서 파일로 준비한다', async () => {
|
||||
const bytes = new Uint8Array([82, 73, 70, 70]);
|
||||
const fetchAudio: typeof fetch = async () => new Response(bytes, {
|
||||
status: 200,
|
||||
headers: { 'content-length': String(bytes.byteLength) },
|
||||
});
|
||||
|
||||
const file = await prepareAudioShareFile({
|
||||
mime_type: 'audio/wav',
|
||||
original_name: '회의.wav',
|
||||
size_bytes: bytes.byteLength,
|
||||
}, 'https://example.com/signed-audio', fetchAudio);
|
||||
|
||||
expect(file).toMatchObject({
|
||||
format: 'binary',
|
||||
mimeType: 'audio/wav',
|
||||
textContent: null,
|
||||
});
|
||||
expect(jest.mocked(FileSystem.writeFile).mock.calls[0]?.[2]).toBe('base64');
|
||||
});
|
||||
|
||||
it('Content-Length가 50 MiB를 넘으면 본문을 파일에 쓰지 않는다', async () => {
|
||||
const fetchAudio: typeof fetch = async () => new Response(new Uint8Array([1]), {
|
||||
status: 200,
|
||||
headers: { 'content-length': String(MAX_SHARED_AUDIO_BYTES + 1) },
|
||||
});
|
||||
|
||||
await expect(prepareAudioShareFile({
|
||||
mime_type: 'audio/wav',
|
||||
original_name: 'large.wav',
|
||||
size_bytes: 1,
|
||||
}, 'https://example.com/signed-audio', fetchAudio)).rejects.toThrow('50 MiB');
|
||||
expect(FileSystem.writeFile).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('다운로드 실패를 공유 성공으로 처리하지 않는다', async () => {
|
||||
const fetchAudio: typeof fetch = async () => new Response(null, { status: 403 });
|
||||
|
||||
await expect(prepareAudioShareFile({
|
||||
mime_type: 'audio/wav',
|
||||
original_name: 'private.wav',
|
||||
size_bytes: 4,
|
||||
}, 'https://example.com/expired-audio', fetchAudio)).rejects.toThrow('HTTP 403');
|
||||
expect(FileSystem.writeFile).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue