todo-app/test/cli/cli_new_note_test.dart
Krzysztof kuhy Rudnicki 75248e9cde Add new_note to add_task with merge and start
new_note files a separate note per repo; an exact section-title
match in another open note merges into it and starts it via the
board, unless that note is running, none or low priority.

Todo: 64d39ab5

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 15:24:41 +01:00

41 lines
1.6 KiB
Dart

// `--repo --new-note`: the task gets its own note; an exact title in another
// separate note merges into it. The CLI never talks to the board. ASCII
// titles: FakeRtdb encodes its responses as Latin-1.
import 'package:flutter_test/flutter_test.dart';
import 'package:todo/cli/cli_args.dart';
import 'cli_harness.dart';
void main() {
late CliHarness h;
setUp(() => h = CliHarness());
tearDown(() => h.dispose());
Future<String> add(String text, [List<String> more = const []]) =>
h.add(text, ['--repo', 'kuhyx/herosi', ...more]);
test('C1: --new-note opens a second note; a duplicate merges', () async {
final shared = await add('Old\n\nx');
final split = await add('Mlody\n\nwhat', ['--new-note']);
expect(split, isNot(shared));
final again = await add('Mlody\n\nmore', ['--new-note']);
expect(again, split);
expect(h.err.toString(), contains('merged into'));
expect(h.err.toString(), contains('click Start on the board by hand'));
expect(await h.run(['--list', '--repo', 'kuhyx/herosi']), 0);
expect(h.out.toString().trim().split('\n'), hasLength(2));
expect(await h.run(['--get', split]), 0);
expect(h.out.toString(), contains('herosi todos: Mlody'));
});
test('--new-note needs --repo and an add', () {
expect(() => CliArgs.parse(['--new-note']), throwsA(isA<UsageError>()));
expect(
() => CliArgs.parse(['--list', '--repo', 'a/b', '--new-note']),
throwsA(isA<UsageError>()),
);
expect(CliArgs.parse(['--repo', 'a/b', '--new-note']).newNote, isTrue);
expect(CliArgs.parse(['--repo', 'a/b']).newNote, isFalse);
});
}