Add full note view/editor with templates and Markdown render
Notes were previously only openable via a quick-actions sheet; you
could not read or edit a note in full. Add a shared NoteEditor used by
both the capture and detail screens, plus selectable templates and a
rendered Markdown view.
- note_template.dart: pure assemble/parse layer over a Markdown subset
(# title, ## sections + italic guidance, dropping empty sections).
assemble(parse(text)) is idempotent for conforming text; non-conforming
/ legacy / freeform text is reported so the UI falls back to raw,
untouched. Two templates: llm-design-spec (default) and blank.
- note_editor.dart: View / Guided / Raw modes. Guided is an inline
Stepper (one step per section with its guidance); View renders the
note via MarkdownView; Raw is the verbatim text. Guided is offered
only for structured templates; switching to it is blocked when the
raw text no longer conforms.
- markdown_view.dart: lean read-only renderer for the note subset,
wrapped in a SelectionArea for copy-out.
- note_detail_screen.dart: full-screen note; opens in View, edits
persist immediately, priority/status dropdowns, delete.
- capture_screen / notes_list_screen wired to the new editor and detail
screen (tap a note opens it; quick actions move to the overflow button).
The editor is a view over plain text, so CRDT storage and Markdown
export/sync are unaffected. 138 tests, 100% line coverage.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 21:59:31 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
|
import 'package:todo/data/note.dart';
|
|
|
|
|
import 'package:todo/ui/note_detail_screen.dart';
|
|
|
|
|
|
|
|
|
|
import 'fake_note_repository.dart';
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
Note seedNote(String text) => Note(
|
|
|
|
|
id: 'n1',
|
|
|
|
|
text: text,
|
|
|
|
|
priority: Priority.medium,
|
|
|
|
|
status: Status.todo,
|
|
|
|
|
createdAt: DateTime(2026, 6, 15, 9),
|
|
|
|
|
updatedAt: DateTime(2026, 6, 15, 9),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Future<FakeNoteRepository> pumpDetail(WidgetTester tester, Note note) async {
|
|
|
|
|
tester.view.physicalSize = const Size(1200, 2400);
|
|
|
|
|
tester.view.devicePixelRatio = 1.0;
|
|
|
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
|
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
|
|
|
|
|
|
|
|
final repo = FakeNoteRepository([note]);
|
|
|
|
|
addTearDown(repo.close);
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
|
MaterialApp(
|
|
|
|
|
home: NoteDetailScreen(note: note, repository: repo),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
await tester.pump();
|
|
|
|
|
return repo;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-27 12:10:21 +02:00
|
|
|
testWidgets('opens in Raw with the title in the app bar', (tester) async {
|
Add full note view/editor with templates and Markdown render
Notes were previously only openable via a quick-actions sheet; you
could not read or edit a note in full. Add a shared NoteEditor used by
both the capture and detail screens, plus selectable templates and a
rendered Markdown view.
- note_template.dart: pure assemble/parse layer over a Markdown subset
(# title, ## sections + italic guidance, dropping empty sections).
assemble(parse(text)) is idempotent for conforming text; non-conforming
/ legacy / freeform text is reported so the UI falls back to raw,
untouched. Two templates: llm-design-spec (default) and blank.
- note_editor.dart: View / Guided / Raw modes. Guided is an inline
Stepper (one step per section with its guidance); View renders the
note via MarkdownView; Raw is the verbatim text. Guided is offered
only for structured templates; switching to it is blocked when the
raw text no longer conforms.
- markdown_view.dart: lean read-only renderer for the note subset,
wrapped in a SelectionArea for copy-out.
- note_detail_screen.dart: full-screen note; opens in View, edits
persist immediately, priority/status dropdowns, delete.
- capture_screen / notes_list_screen wired to the new editor and detail
screen (tap a note opens it; quick actions move to the overflow button).
The editor is a view over plain text, so CRDT storage and Markdown
export/sync are unaffected. 138 tests, 100% line coverage.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 21:59:31 +02:00
|
|
|
await pumpDetail(tester, seedNote('# My note\n\n## what\n_why_\n\nbody'));
|
|
|
|
|
|
2026-06-27 12:10:21 +02:00
|
|
|
final raw = tester.widget<TextField>(find.byType(TextField));
|
|
|
|
|
expect(raw.controller!.text, contains('My note'));
|
|
|
|
|
expect(find.text('My note'), findsOneWidget); // app bar title
|
Add full note view/editor with templates and Markdown render
Notes were previously only openable via a quick-actions sheet; you
could not read or edit a note in full. Add a shared NoteEditor used by
both the capture and detail screens, plus selectable templates and a
rendered Markdown view.
- note_template.dart: pure assemble/parse layer over a Markdown subset
(# title, ## sections + italic guidance, dropping empty sections).
assemble(parse(text)) is idempotent for conforming text; non-conforming
/ legacy / freeform text is reported so the UI falls back to raw,
untouched. Two templates: llm-design-spec (default) and blank.
- note_editor.dart: View / Guided / Raw modes. Guided is an inline
Stepper (one step per section with its guidance); View renders the
note via MarkdownView; Raw is the verbatim text. Guided is offered
only for structured templates; switching to it is blocked when the
raw text no longer conforms.
- markdown_view.dart: lean read-only renderer for the note subset,
wrapped in a SelectionArea for copy-out.
- note_detail_screen.dart: full-screen note; opens in View, edits
persist immediately, priority/status dropdowns, delete.
- capture_screen / notes_list_screen wired to the new editor and detail
screen (tap a note opens it; quick actions move to the overflow button).
The editor is a view over plain text, so CRDT storage and Markdown
export/sync are unaffected. 138 tests, 100% line coverage.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 21:59:31 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('changing the priority dropdown persists the note', (
|
|
|
|
|
tester,
|
|
|
|
|
) async {
|
|
|
|
|
final repo = await pumpDetail(tester, seedNote('# T'));
|
|
|
|
|
|
|
|
|
|
await tester.tap(
|
|
|
|
|
find.byWidgetPredicate((w) => w is DropdownButtonFormField<Priority>),
|
|
|
|
|
);
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
await tester.tap(find.text('High').last);
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
|
|
expect((await repo.listNotes()).single.priority, Priority.high);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('changing the status dropdown persists the note', (tester) async {
|
|
|
|
|
final repo = await pumpDetail(tester, seedNote('# T'));
|
|
|
|
|
|
|
|
|
|
await tester.tap(
|
|
|
|
|
find.byWidgetPredicate((w) => w is DropdownButtonFormField<Status>),
|
|
|
|
|
);
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
await tester.tap(find.text('Done').last);
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
|
|
expect((await repo.listNotes()).single.status, Status.done);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWidgets('editing the body in Raw mode persists the new text', (
|
|
|
|
|
tester,
|
|
|
|
|
) async {
|
|
|
|
|
final repo = await pumpDetail(tester, seedNote('# T\n\n## what\nold'));
|
|
|
|
|
|
|
|
|
|
await tester.tap(find.text('Raw'));
|
|
|
|
|
await tester.pump();
|
|
|
|
|
await tester.enterText(find.byType(TextField), '# T\n\n## what\nnew body');
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
expect((await repo.listNotes()).single.text, contains('new body'));
|
|
|
|
|
});
|
|
|
|
|
|
2026-06-27 12:10:21 +02:00
|
|
|
testWidgets(
|
|
|
|
|
'clearing the body then tapping Guided runs the wizard and persists the chosen priority',
|
|
|
|
|
(tester) async {
|
|
|
|
|
final repo = await pumpDetail(tester, seedNote('# T\n\n## what\nold'));
|
|
|
|
|
|
|
|
|
|
await tester.enterText(find.byType(TextField), '');
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
await tester.tap(find.text('Guided'));
|
|
|
|
|
await tester.pump();
|
|
|
|
|
expect(find.text('Step 1 of 2'), findsOneWidget);
|
|
|
|
|
// Wizard hides the Status dropdown (onChromeVisibleChanged(false)).
|
|
|
|
|
expect(find.text('Status'), findsNothing);
|
|
|
|
|
|
|
|
|
|
await tester.tap(find.byType(DropdownButtonFormField<Priority>));
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
await tester.tap(find.text('High').last);
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
|
|
await tester.tap(find.text('Next'));
|
|
|
|
|
await tester.pump();
|
|
|
|
|
await tester.tap(find.text('Start'));
|
|
|
|
|
await tester.pump();
|
|
|
|
|
|
|
|
|
|
expect((await repo.listNotes()).single.priority, Priority.high);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
Add full note view/editor with templates and Markdown render
Notes were previously only openable via a quick-actions sheet; you
could not read or edit a note in full. Add a shared NoteEditor used by
both the capture and detail screens, plus selectable templates and a
rendered Markdown view.
- note_template.dart: pure assemble/parse layer over a Markdown subset
(# title, ## sections + italic guidance, dropping empty sections).
assemble(parse(text)) is idempotent for conforming text; non-conforming
/ legacy / freeform text is reported so the UI falls back to raw,
untouched. Two templates: llm-design-spec (default) and blank.
- note_editor.dart: View / Guided / Raw modes. Guided is an inline
Stepper (one step per section with its guidance); View renders the
note via MarkdownView; Raw is the verbatim text. Guided is offered
only for structured templates; switching to it is blocked when the
raw text no longer conforms.
- markdown_view.dart: lean read-only renderer for the note subset,
wrapped in a SelectionArea for copy-out.
- note_detail_screen.dart: full-screen note; opens in View, edits
persist immediately, priority/status dropdowns, delete.
- capture_screen / notes_list_screen wired to the new editor and detail
screen (tap a note opens it; quick actions move to the overflow button).
The editor is a view over plain text, so CRDT storage and Markdown
export/sync are unaffected. 138 tests, 100% line coverage.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 21:59:31 +02:00
|
|
|
testWidgets('the delete action removes the note and pops', (tester) async {
|
|
|
|
|
final repo = await pumpDetail(tester, seedNote('# Bye'));
|
|
|
|
|
|
|
|
|
|
await tester.tap(find.byTooltip('Delete note'));
|
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
|
|
expect(await repo.listNotes(), isEmpty);
|
|
|
|
|
expect(find.byType(NoteDetailScreen), findsNothing);
|
|
|
|
|
});
|
|
|
|
|
}
|