mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-10 20:47:01 +01:00
Editing an existing note looked nothing like capturing a new one: it always showed the template dropdown, the View/Guided/Raw pills and the priority/status row. The cause was one missing argument -- both screens already embedded the same NoteEditor, but NoteDetailScreen never passed advancedMode, which defaults to true in the widget while the app-wide AppSettings.advancedMode defaults to false. Extract the shared form as three single-purpose components rather than one widget owning several jobs: - note_meta_row.dart renders the priority/status row (was capture_meta_row.dart; drops the private _MetaDropdown duplicate the detail screen carried, which used DropdownButtonFormField where the shared one uses DropdownButton). - note_form_chrome_gate.dart owns chrome visibility and nothing else, replacing the _chromeVisible flag both screens copy-pasted. - note_form.dart composes those two with NoteEditor. appSettings is now a required parameter through NotesListScreen and NoteDetailScreen. Required, not defaulted: a silent default is exactly what caused this, so it must not be reintroducible. Also in the capture app bar: drop the decorative Icons.list_alt_outlined beside the note count, since the adjacent Icons.list button already names what is counted, and move the count to the right of that button. The finalize-and-clear action becomes Icons.check instead of Icons.add -- it never saved anything (every keystroke is already persisted), so a plus sign misdescribed it. 314 tests, 100% line coverage. Verified in a running web build that edit and capture render identically with advanced mode both off and on. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
50 lines
1.3 KiB
Dart
50 lines
1.3 KiB
Dart
/// The shared pumpList harness and its fixed-clock note fixture.
|
|
///
|
|
/// Shared by the files `notes_list_screen_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/app_settings.dart';
|
|
import 'package:todo/data/note.dart';
|
|
import 'package:todo/ui/notes_list_screen.dart';
|
|
|
|
import 'fake_note_repository.dart';
|
|
|
|
Note note(
|
|
String id,
|
|
String text, {
|
|
Priority priority = Priority.medium,
|
|
Status status = Status.todo,
|
|
}) {
|
|
final now = DateTime(2026, 6, 15, 9);
|
|
return Note(
|
|
id: id,
|
|
text: text,
|
|
priority: priority,
|
|
status: status,
|
|
createdAt: now,
|
|
updatedAt: now,
|
|
);
|
|
}
|
|
|
|
Future<FakeNoteRepository> pumpList(
|
|
WidgetTester tester, {
|
|
List<Note> seed = const [],
|
|
bool advancedMode = true,
|
|
}) async {
|
|
final repo = FakeNoteRepository(seed);
|
|
addTearDown(repo.close);
|
|
final settings = ValueNotifier(AppSettings(advancedMode: advancedMode));
|
|
addTearDown(settings.dispose);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: NotesListScreen(repository: repo, appSettings: settings),
|
|
),
|
|
);
|
|
await tester.pump(); // flush the initial stream emit
|
|
return repo;
|
|
}
|