feat: replace mail protocol with smolmail and rebuild the UI

This commit is contained in:
randogoth 2026-09-26 22:45:38 +03:00
parent cb24b68069
commit e94e4158cc
93 changed files with 6387 additions and 3479 deletions

61
test/dbg_test.dart Normal file
View file

@ -0,0 +1,61 @@
import "dart:io";
import "package:auto_route/auto_route.dart";
import "package:flutter/material.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:flutter_test/flutter_test.dart";
import "package:hive_flutter/hive_flutter.dart";
import "package:smol_mail/data/providers/providers.dart";
import "package:smol_mail/presentation/app_widget.dart";
import "package:smol_mail/presentation/routes/app_router.gr.dart";
import "package:smol_mail/smol/client.dart";
import "package:smol_mail/smol/crypto.dart";
import "package:smol_mail/smol/proto.dart";
import "package:smol_mail/smol/store.dart";
class StubClient extends SmolClient {
StubClient(super.store);
@override
Future<SmolAddress> recallAccount(String addressText) async {
final addr = parseAddress(addressText);
store.setAccount(addr);
return addr;
}
}
void main() {
late SmolStore store;
setUpAll(() async {
TestWidgetsFlutterBinding.ensureInitialized();
final dir = await Directory.systemTemp.createTemp("dbg4");
Hive.init(dir.path);
store = await SmolStore.open(stateBox: "dbg-state", mailBox: "dbg-mail");
});
testWidgets("direct replace", (tester) async {
final seed = randomBytes(32);
await tester.pumpWidget(ProviderScope(
overrides: [
storeProvider.overrideWithValue(store),
clientProvider.overrideWithValue(StubClient(store)),
],
child: const AppWidget(),
));
await tester.pumpAndSettle();
await tester.tap(find.text("Restore From Seed"));
await tester.pumpAndSettle();
final fields = find.byType(TextField);
await tester.enterText(fields.at(0), hex(seed));
await tester.enterText(fields.at(1), "randogoth@smol.place");
await tester.tap(find.text("Restore"));
await tester.pumpAndSettle();
expect(store.account(), isNotNull, reason: "recall stub ran");
final element = tester.element(find.text("Back"));
final router = AutoRouter.of(element);
await router.replace(InboxRoute());
await tester.pumpAndSettle();
expect(find.text("Inbox"), findsOneWidget);
});
}