Follow-ups to Phase E (ADR-15): - Recordings over 25 MB are cut into pieces and transcribed in turn: with ffmpeg (now in the server and all-in-one images) any format is re-encoded to 16 kHz mono MP3 in 20-minute pieces; without it, MP3 is cut at frame boundaries and WAV at sample boundaries in Go. - PDFs without a text layer are written out by a document-capable chat model (Anthropic document input, OpenAI file input); Ollama is skipped. - Phone app: AI answers render as Markdown with tappable citations; the editing toolbar opens the writing actions on the selection; audio files get Transcribe. Editor bridge protocol 4 adds setAi, getSelection, insertMarkdown and transcribe/transcribed. - The transcript HTML builder moves to @docwell/editor, shared by the web app and the phone editor. - An integration test runs chat, Transcribe and writing actions on a device against a live server; the editor test no longer expects headings to have only a level. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
65 lines
2.0 KiB
Dart
65 lines
2.0 KiB
Dart
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import 'package:docwell_mobile/api/docwell_api.dart';
|
|
import 'package:docwell_mobile/screens/ai_chat_screen.dart';
|
|
import 'package:docwell_mobile/screens/markdown_view.dart';
|
|
import 'package:flutter/gestures.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
test('parseEventStream splits events across chunks', () async {
|
|
final chunks = Stream.fromIterable([
|
|
'event: sources\ndata: {"citations":[]}\n\nevent: del',
|
|
'ta\ndata: {"text":"Hi"}\r\n\r\n',
|
|
'event: done\ndata: {}\n\n',
|
|
]);
|
|
final events = await parseEventStream(chunks).toList();
|
|
expect(events.map((e) => e.name), ['sources', 'delta', 'done']);
|
|
expect(events[1].data['text'], 'Hi');
|
|
});
|
|
|
|
test('citedNumbers finds every [n]', () {
|
|
expect(citedNumbers('a [1] b [12][3]'), {1, 12, 3});
|
|
});
|
|
|
|
testWidgets('MarkdownView draws formatting, lists and citations', (
|
|
tester,
|
|
) async {
|
|
int? cited;
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
body: MarkdownView(
|
|
'## Plan\n\nShip **Friday** [1].\n\n- one\n- [ ] call Ana\n\n| A | B |\n|---|---|\n| x | y |\n',
|
|
onCite: (n) => cited = n,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
expect(find.text('Plan'), findsOneWidget);
|
|
expect(
|
|
find.textContaining('Ship Friday', findRichText: true),
|
|
findsOneWidget,
|
|
);
|
|
expect(find.text('☐'), findsOneWidget);
|
|
expect(find.text('•'), findsOneWidget);
|
|
expect(find.text('x'), findsOneWidget);
|
|
final rich = tester.widget<RichText>(
|
|
find.byWidgetPredicate(
|
|
(w) => w is RichText && w.text.toPlainText().contains('Ship'),
|
|
),
|
|
);
|
|
var tapped = false;
|
|
rich.text.visitChildren((span) {
|
|
if (span is TextSpan && span.text == ' 1 ' && span.recognizer != null) {
|
|
(span.recognizer! as TapGestureRecognizer).onTap!();
|
|
tapped = true;
|
|
}
|
|
return true;
|
|
});
|
|
expect(tapped, isTrue);
|
|
expect(cited, 1);
|
|
});
|
|
}
|