Fix onboarding layout issues

This commit is contained in:
Janez T
2026-03-11 15:08:04 +01:00
parent 193a193e8a
commit 0dfb84bf4e
3 changed files with 779 additions and 98 deletions

View File

@@ -0,0 +1,64 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:meshcore_sar_app/l10n/app_localizations.dart';
import 'package:meshcore_sar_app/widgets/contacts/add_channel_dialog.dart';
void main() {
Future<void> pumpDialog(
WidgetTester tester, {
required Future<void> Function(String name, String secret) onCreateChannel,
}) async {
await tester.pumpWidget(
MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: Scaffold(
body: Builder(
builder: (context) => Center(
child: AddChannelDialog(onCreateChannel: onCreateChannel),
),
),
),
),
);
}
testWidgets('submits hash channels with an empty secret', (tester) async {
String? submittedName;
String? submittedSecret;
await pumpDialog(
tester,
onCreateChannel: (name, secret) async {
submittedName = name;
submittedSecret = secret;
},
);
await tester.enterText(find.byType(TextFormField).first, '#slovenia');
await tester.pump();
await tester.tap(find.text('Create Channel'));
await tester.pumpAndSettle();
expect(submittedName, '#slovenia');
expect(submittedSecret, '');
});
testWidgets('uses done action for hash channels', (tester) async {
String? submittedName;
await pumpDialog(
tester,
onCreateChannel: (name, secret) async {
submittedName = name;
},
);
await tester.enterText(find.byType(TextFormField).first, '#slovenia');
await tester.pump();
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pumpAndSettle();
expect(submittedName, '#slovenia');
});
}