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
|
|
@ -1,21 +1,8 @@
|
|||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:muzzle_velocity/note_editor.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;
|
||||
}
|
||||
import 'note_list_harness.dart';
|
||||
|
||||
Future<void> _press(WidgetTester tester, LogicalKeyboardKey key) async {
|
||||
await tester.sendKeyEvent(key);
|
||||
|
|
@ -23,31 +10,9 @@ Future<void> _press(WidgetTester tester, LogicalKeyboardKey key) async {
|
|||
}
|
||||
|
||||
void main() {
|
||||
late Directory notes;
|
||||
|
||||
setUp(() {
|
||||
notes = Directory.systemTemp.createTempSync('mv-list');
|
||||
for (final name in ['alpha', 'beta', 'gamma']) {
|
||||
File('${notes.path}/$name.md').writeAsStringSync('# $name\n');
|
||||
}
|
||||
PathProviderPlatform.instance = _FakePathProvider(notes.path);
|
||||
SharedPreferences.setMockInitialValues({'initialized': true});
|
||||
});
|
||||
|
||||
Future<void> pumpList(WidgetTester tester) async {
|
||||
await tester.runAsync(() async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: NoteListScreen(
|
||||
toggleTheme: (_) {},
|
||||
toggleTags: () {},
|
||||
isDarkMode: false,
|
||||
showTags: true,
|
||||
),
|
||||
));
|
||||
await Future<void>.delayed(const Duration(milliseconds: 200));
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
setUp(() => setUpNotes({
|
||||
for (final name in ['alpha', 'beta', 'gamma']) '$name.md': '# $name\n',
|
||||
}));
|
||||
|
||||
bool searchHasFocus(WidgetTester tester) =>
|
||||
tester.widget<TextField>(find.byType(TextField)).focusNode!.hasFocus;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue