fix: run search bar commands on Enter and filter by /folder
This commit is contained in:
parent
b3df7fba9f
commit
0940fec5e8
4 changed files with 138 additions and 41 deletions
56
test/note_list_harness.dart
Normal file
56
test/note_list_harness.dart
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:muzzle_velocity/note_list.dart';
|
||||
import 'package:path_provider_platform_interface/path_provider_platform_interface.dart';
|
||||
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class _FakePathProvider extends PathProviderPlatform
|
||||
with MockPlatformInterfaceMixin {
|
||||
_FakePathProvider(this.path);
|
||||
final String path;
|
||||
|
||||
@override
|
||||
Future<String?> getApplicationDocumentsPath() async => path;
|
||||
}
|
||||
|
||||
/// Creates a temporary notes folder with [files] (relative path to content)
|
||||
/// and makes it the app's default notes directory.
|
||||
Directory setUpNotes(Map<String, String> files) {
|
||||
final notes = Directory.systemTemp.createTempSync('mv-list');
|
||||
files.forEach((name, content) {
|
||||
File('${notes.path}/$name')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(content);
|
||||
});
|
||||
PathProviderPlatform.instance = _FakePathProvider(notes.path);
|
||||
SharedPreferences.setMockInitialValues({'initialized': true});
|
||||
return notes;
|
||||
}
|
||||
|
||||
/// Pumps the note list, letting its real file I/O finish.
|
||||
Future<void> pumpList(
|
||||
WidgetTester tester, {
|
||||
void Function(bool)? toggleTheme,
|
||||
VoidCallback? toggleTags,
|
||||
}) async {
|
||||
await tester.runAsync(() async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: NoteListScreen(
|
||||
toggleTheme: toggleTheme ?? (_) {},
|
||||
toggleTags: toggleTags ?? () {},
|
||||
isDarkMode: false,
|
||||
showTags: true,
|
||||
),
|
||||
));
|
||||
await Future<void>.delayed(const Duration(milliseconds: 200));
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
/// Titles of the notes currently listed.
|
||||
List<String> listedNotes(WidgetTester tester) => [
|
||||
for (final tile in tester.widgetList<ListTile>(find.byType(ListTile)))
|
||||
(tile.title as Text).data!,
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue