mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-10 20:07:02 +01:00
Every split is by test-group/concern, with the shared setup moved to a
sibling helper the splits import. All 313 tests are preserved -- the count
is unchanged and `test('…')` names are byte-identical to the originals
(verified by diffing the sorted name lists).
note_repository_test 677 -> 4 files + note_repository_helpers
capture_screen_test 660 -> 4 files + capture_screen_harness
note_editor_test 502 -> 3 files + note_editor_harness
port_guard_test 405 -> 3 files + port_guard_fakes
wrapper_server_test 402 -> 2 files + wrapper_server_harness
settings_screen_test 391 -> 2 files + settings_screen_harness
github_mirror_screen_test 365 -> 2 files + github_mirror_harness
notes_list_screen_test 347 -> 2 files + notes_list_harness
analytics_service_test 300 -> 2 files + analytics_helpers
Helpers are deliberately NOT named `*_test.dart`; the runner would collect
them and fail on the missing `main()`.
Three things did not survive a mechanical split and were handled explicitly:
* wrapper_server's `enabledOrigin` closes over the `late root` that setUp
assigns, so a top-level function cannot see it. It is now a
WrapperHarness class with an install() that registers the setUp/tearDown
pair -- the only structural change in this commit.
* note_repository's splits each repeat `setUpAll(sqfliteFfiInit)`, and
analytics' each repeat `@TestOn('vm')`. Omitting either fails quietly
(uninitialised sqflite / wrong platform) rather than loudly.
* capture_screen's `recordingMock` was declared mid-file between two
tests, so it moved to the harness rather than being dropped.
Verified: 313 tests pass (same as before the refactor), 100% coverage.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
51 lines
1.6 KiB
Dart
51 lines
1.6 KiB
Dart
/// The shared pumpEditor harness and template constants.
|
|
///
|
|
/// Shared by the files `note_editor_test.dart` was split into for the
|
|
/// 250-line cap. Deliberately NOT named `*_test.dart`: the runner would
|
|
/// collect it and fail on the missing `main()`.
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:todo/data/note.dart';
|
|
import 'package:todo/data/note_template.dart';
|
|
import 'package:todo/ui/markdown_view.dart';
|
|
import 'package:todo/ui/note_editor.dart';
|
|
|
|
const spec = NoteTemplate.llmDesignSpec;
|
|
const blank = NoteTemplate.blank;
|
|
|
|
// Pumps an editor and exposes the latest text emitted via onChanged.
|
|
Future<List<String>> pumpEditor(
|
|
WidgetTester tester, {
|
|
String initialText = '',
|
|
NoteTemplate? initialTemplate,
|
|
NoteEditorMode initialMode = NoteEditorMode.guided,
|
|
Priority priority = Priority.defaultValue,
|
|
ValueChanged<Priority>? onPriorityChanged,
|
|
ValueChanged<bool>? onChromeVisibleChanged,
|
|
}) async {
|
|
final emitted = <String>[];
|
|
tester.view.physicalSize = const Size(1200, 2400);
|
|
tester.view.devicePixelRatio = 1.0;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
body: NoteEditor(
|
|
initialText: initialText,
|
|
initialTemplate: initialTemplate,
|
|
initialMode: initialMode,
|
|
priority: priority,
|
|
onPriorityChanged: onPriorityChanged ?? (_) {},
|
|
onChromeVisibleChanged: onChromeVisibleChanged ?? (_) {},
|
|
onChanged: emitted.add,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
return emitted;
|
|
}
|