From 8952695463ea658231969ad2497d7ed688963aa6 Mon Sep 17 00:00:00 2001 From: Amoghhosamane Date: Thu, 21 May 2026 12:49:26 +0530 Subject: [PATCH 1/3] NOTEPOD: add test of new note creation #236 --- integration_test/new_note_creation_test.dart | 49 ++++++++++++++++++++ pubspec.yaml | 4 ++ 2 files changed, 53 insertions(+) create mode 100644 integration_test/new_note_creation_test.dart diff --git a/integration_test/new_note_creation_test.dart b/integration_test/new_note_creation_test.dart new file mode 100644 index 0000000..8a874b1 --- /dev/null +++ b/integration_test/new_note_creation_test.dart @@ -0,0 +1,49 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; +import 'package:notepod/main.dart' as app; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + group('end-to-end test', () { + testWidgets('user with cached credentials can create and save a new note', + (WidgetTester tester) async { + app.main(); + await tester.pumpAndSettle(); + + // Tap on the FAB to add a new note (if it exists) + final addNoteButton = find.byIcon(Icons.add); + if (addNoteButton.evaluate().isNotEmpty) { + await tester.tap(addNoteButton); + await tester.pumpAndSettle(); + } else { + // Alternatively it might be an 'Add Note' text button + final addNoteText = find.text('Add Note'); + if (addNoteText.evaluate().isNotEmpty) { + await tester.tap(addNoteText); + await tester.pumpAndSettle(); + } + } + + // We expect to find text fields for the title and content + expect(find.byType(TextFormField), findsWidgets); + + // Enter a title + final titleField = find.byType(TextFormField).first; + await tester.enterText(titleField, 'Automated Test Note'); + + // The content field is typically the second or last text field + final contentField = find.byType(TextFormField).last; + await tester.enterText(contentField, 'This is a test note created by an integration test.'); + + // Tap on the save button + final saveButton = find.byIcon(Icons.save); + await tester.tap(saveButton); + await tester.pumpAndSettle(); + + // Verify that the note is now displayed in the list + expect(find.text('Automated Test Note'), findsWidgets); + }); + }); +} diff --git a/pubspec.yaml b/pubspec.yaml index d7e4166..2603629 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,6 +42,10 @@ dev_dependencies: build_runner: ^2.4.14 flutter_launcher_icons: ^0.14.4 flutter_lints: ^6.0.0 + flutter_test: + sdk: flutter + integration_test: + sdk: flutter flutter: assets: From e58080267fb5c17da588506a0c1bd0d776f21021 Mon Sep 17 00:00:00 2001 From: Amoghhosamane Date: Thu, 21 May 2026 16:25:52 +0530 Subject: [PATCH 2/3] NOTEPOD: use base64 encoding for note content #272 Replace AES encryption of note text with base64 encoding as suggested in issue #272. The rdflib parser cannot handle multiline text with # (hash) values, so encoding is needed. base64 is a simpler and more appropriate solution than AES encryption (which used creation time as key). Decoding falls back to AES decryption for backward compatibility with existing notes that were saved with the old AES-based encoding. --- lib/utils/encryption.dart | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/utils/encryption.dart b/lib/utils/encryption.dart index e84e614..8d9082b 100644 --- a/lib/utils/encryption.dart +++ b/lib/utils/encryption.dart @@ -43,13 +43,7 @@ import 'package:encrypter_plus/encrypter_plus.dart'; /// - [encKey] - String to use as the encryption key. String encryptVal({required String plainText, required String encKey}) { - String encKeySha256 = - sha256.convert(utf8.encode(encKey)).toString().substring(0, 32); - final keyEncode = Key.fromUtf8(encKeySha256); - final encrypter = Encrypter(AES(keyEncode, mode: AESMode.cbc)); - final encryptVal = encrypter.encrypt(plainText, iv: getDummyIv()); - String encryptValStr = encryptVal.base64.toString(); - return encryptValStr; + return base64.encode(utf8.encode(plainText)); } /// A function for decrypting an encypted value @@ -58,15 +52,21 @@ String encryptVal({required String plainText, required String encKey}) { /// and then returns the decrypted string value String decryptVal(String encValStr, String encKey) { - String encKeySha256 = - sha256.convert(utf8.encode(encKey)).toString().substring(0, 32); - final keyEncode = Key.fromUtf8(encKeySha256); - final encrypter = Encrypter(AES(keyEncode, mode: AESMode.cbc)); - final decrypter = Encrypted.from64( - encValStr, - ); - final decryptValStr = encrypter.decrypt(decrypter, iv: getDummyIv()); - return decryptValStr; + try { + final decodedBytes = base64.decode(encValStr.trim()); + return utf8.decode(decodedBytes); + } catch (e) { + // Fallback to AES decryption for backward compatibility + String encKeySha256 = + sha256.convert(utf8.encode(encKey)).toString().substring(0, 32); + final keyEncode = Key.fromUtf8(encKeySha256); + final encrypter = Encrypter(AES(keyEncode, mode: AESMode.cbc)); + final decrypter = Encrypted.from64( + encValStr, + ); + final decryptValStr = encrypter.decrypt(decrypter, iv: getDummyIv()); + return decryptValStr; + } } IV getDummyIv() { From 9531627e35b4da90870d26b8672ff503aeebf6ed Mon Sep 17 00:00:00 2001 From: Amoghhosamane Date: Tue, 26 May 2026 21:50:40 +0530 Subject: [PATCH 3/3] backup: preserve current work safely --- lib/widgets/loading_animation.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/widgets/loading_animation.dart b/lib/widgets/loading_animation.dart index 029eb1e..0a38aca 100644 --- a/lib/widgets/loading_animation.dart +++ b/lib/widgets/loading_animation.dart @@ -36,6 +36,21 @@ Future showAnimationDialog( String alertMsg, bool showPathBackground, ) { + // Delegates to solidui's showAnimationDialog for consistency and reduces duplicate code. + // Using animationIndex 0 (ballScaleRipple) as a reasonable default. + return showAnimationDialogSolid(context, 0, alertMsg, showPathBackground, null); +} + +// Alias to avoid name clash with the delegating function. +Future showAnimationDialogSolid( + BuildContext context, + int animationIndex, + String alertMsg, + bool showPathBackground, + VoidCallback? updateStateCallback, +) => solidui.showAnimationDialog( + context, animationIndex, alertMsg, showPathBackground, updateStateCallback); + return showDialog( barrierDismissible: false, context: context,