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
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