Files
notas/test/note_editor_screen_test.dart
T
Marcos 710be805ee feat: integrate Flutter Quill for rich text editing and update note handling
- Added Flutter Quill package for rich text editing capabilities.
- Refactored note body handling to support Quill's Document format.
- Updated note editor screen to use QuillEditor and QuillController.
- Enhanced note search functionality to convert note body to plain text.
- Modified note card display to show plain text from note body.
- Updated localization support for Quill in the app.
- Registered necessary plugins for URL launching and file selection on all platforms.
- Updated app icons and other assets for consistency across platforms.
- Updated pubspec.yaml and pubspec.lock to include new dependencies and versions.
2026-05-24 17:52:11 +02:00

96 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_quill/flutter_quill.dart';
import 'package:notas/models/category.dart';
import 'package:notas/models/note.dart';
import 'package:notas/screens/note_editor_screen.dart';
void main() {
testWidgets('saves a note when only the category changes', (
WidgetTester tester,
) async {
Note? savedNote;
await tester.pumpWidget(
MaterialApp(
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
FlutterQuillLocalizations.delegate,
],
home: Scaffold(
body: NoteEditorScreen(
note: null,
categoryId: null,
categories: <Category>[
Category(
id: 'work',
name: 'Trabajo',
updatedAt: DateTime(2026, 5, 21),
),
],
onComplete: (dynamic result) {
savedNote = result as Note?;
},
),
),
),
);
expect(find.text('Sin categoría'), findsWidgets);
await tester.tap(find.byKey(const ValueKey<String>('category_selector')));
await tester.pumpAndSettle();
await tester.tap(find.text('Trabajo').last);
await tester.pumpAndSettle();
await tester.tap(find.text('Guardar'));
await tester.pumpAndSettle();
expect(savedNote, isNotNull);
expect(savedNote!.categoryId, 'work');
expect(savedNote!.title, 'Sin título');
});
testWidgets('only completes once when save is tapped twice', (
WidgetTester tester,
) async {
int completionCount = 0;
await tester.pumpWidget(
MaterialApp(
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
FlutterQuillLocalizations.delegate,
],
home: Scaffold(
body: NoteEditorScreen(
note: null,
categoryId: null,
categories: <Category>[],
onComplete: (dynamic result) {
if (result is Note) {
completionCount += 1;
}
},
),
),
),
);
await tester.enterText(find.byType(TextField).first, 'Nota de prueba');
await tester.tap(find.text('Guardar'));
await tester.tap(find.text('Guardar'));
await tester.pumpAndSettle();
expect(completionCount, 1);
});
}