todo-app/test/markdown_view_test.dart
Krzysztof kuhy Rudnicki 3a747c2e51
Some checks failed
dependency freshness / dependencies on newest stable (push) Has been cancelled
file-length / file length <= 250 lines (push) Has been cancelled
md-naming / markdown naming convention (push) Has been cancelled
release-apk / release (APK) (push) Has been cancelled
repo-contract / repo contract (push) Has been cancelled
Report errors and slow waits to the board
crdt_sync_flutter 0.9.0's installAppErrors in main(): uncaught errors and
every spinner shown over 1 s (WaitWatch: sync.run, mirror.test) upload to
RTDB /todo/errors/<device> with the versionCode, where the PC app-errors
ingest files board tickets (kuhyx/utils DOCS-app-errors.md).

The app moves to material_ui first: sync_settings_ui 0.8.x and
design_system 0.4.x sit on it, and Flutter 3.50 deprecates
flutter/material. Pins: crdt_sync 0.14.1, csf 0.9.0, ssui 0.8.3,
gda 0.5.1, design_system 0.4.1, image 4.13.1, mcp_dart 2.4.4.
file_picker stays 13.3.3, held by data_transfer_flutter 0.2.2
(allowlisted, self-clearing).

appRoute takes a route name so each report names its screen; the
release build passes APP_BUILD/APP_VERSION. Nothing new on screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 23:07:58 +01:00

72 lines
2.3 KiB
Dart

import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:todo/ui/markdown_view.dart';
void main() {
Future<void> pumpView(WidgetTester tester, String text) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(body: MarkdownView(text: text)),
),
);
await tester.pump();
}
/// Finds the rendered Text widget whose data equals [data] and returns it.
Text textWidget(WidgetTester tester, String data) =>
tester.widget<Text>(find.text(data));
testWidgets('renders an h1 title bold and large', (tester) async {
await pumpView(tester, '# Big title');
final t = textWidget(tester, 'Big title');
expect(t.style?.fontWeight, FontWeight.bold);
});
testWidgets('renders an h2 section heading without its marker', (
tester,
) async {
await pumpView(tester, '## what');
expect(find.text('what'), findsOneWidget);
expect(textWidget(tester, 'what').style?.fontWeight, FontWeight.bold);
});
testWidgets('renders a whole-line italic guidance line', (tester) async {
await pumpView(tester, '_guidance text_');
final t = textWidget(tester, 'guidance text');
expect(t.style?.fontStyle, FontStyle.italic);
});
testWidgets('renders dash and star bullets with a bullet glyph', (
tester,
) async {
await pumpView(tester, '- first\n* second');
expect(find.text('first'), findsOneWidget);
expect(find.text('second'), findsOneWidget);
expect(find.textContaining('•'), findsNWidgets(2));
});
testWidgets('renders a plain paragraph and blank-line spacers', (
tester,
) async {
await pumpView(tester, 'a paragraph\n\nanother');
expect(find.text('a paragraph'), findsOneWidget);
expect(find.text('another'), findsOneWidget);
// The blank line between paragraphs becomes a spacer box.
expect(find.byType(SizedBox), findsWidgets);
});
testWidgets('a full assembled note renders all element types', (
tester,
) async {
await pumpView(
tester,
'# Title\n\n## what\n_why we need it_\n\n- one\n- two\nplain tail',
);
expect(find.text('Title'), findsOneWidget);
expect(find.text('what'), findsOneWidget);
expect(find.text('why we need it'), findsOneWidget);
expect(find.text('one'), findsOneWidget);
expect(find.text('plain tail'), findsOneWidget);
});
}