Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions integration_test/new_note_creation_test.dart
Original file line number Diff line number Diff line change
@@ -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);
});
});
}
32 changes: 16 additions & 16 deletions lib/utils/encryption.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand Down
15 changes: 15 additions & 0 deletions lib/widgets/loading_animation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ Future<dynamic> 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<void> showAnimationDialogSolid(
BuildContext context,
int animationIndex,
String alertMsg,
bool showPathBackground,
VoidCallback? updateStateCallback,
) => solidui.showAnimationDialog(
context, animationIndex, alertMsg, showPathBackground, updateStateCallback);

return showDialog(
barrierDismissible: false,
context: context,
Expand Down
4 changes: 4 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down