diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 46d9200c..a2805d3e 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -1278,6 +1278,10 @@ "sendLogs_title": "Send logs to Offband", "sendLogs_consent": "This sends the app's logs to Offband so we can look into a problem. They include your messages and the radio traffic, with passwords and PINs removed. They are encrypted on this device, only Offband can read them, and they are deleted 30 days after we review them.", "sendLogs_noteLabel": "What happened? (optional)", + "sendLogs_nameLabel": "Name or screen name (optional)", + "sendLogs_emailLabel": "Email (optional)", + "sendLogs_emailInvalid": "That doesn't look like an email address. Fix it or leave it empty.", + "sendLogs_contactNote": "If you leave these empty, we can't reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.", "sendLogs_preparing": "Gathering the logs", "sendLogs_size": "{size} to send", "@sendLogs_size": { diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 5d0ff078..b7935281 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -3934,6 +3934,30 @@ abstract class AppLocalizations { /// **'What happened? (optional)'** String get sendLogs_noteLabel; + /// No description provided for @sendLogs_nameLabel. + /// + /// In en, this message translates to: + /// **'Name or screen name (optional)'** + String get sendLogs_nameLabel; + + /// No description provided for @sendLogs_emailLabel. + /// + /// In en, this message translates to: + /// **'Email (optional)'** + String get sendLogs_emailLabel; + + /// No description provided for @sendLogs_emailInvalid. + /// + /// In en, this message translates to: + /// **'That doesn\'t look like an email address. Fix it or leave it empty.'** + String get sendLogs_emailInvalid; + + /// No description provided for @sendLogs_contactNote. + /// + /// In en, this message translates to: + /// **'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'** + String get sendLogs_contactNote; + /// No description provided for @sendLogs_preparing. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index 88ea03d3..cfaf5744 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -2246,6 +2246,20 @@ class AppLocalizationsBg extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index 0327ec37..e1d935a3 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -2243,6 +2243,20 @@ class AppLocalizationsDe extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 2eeeef67..2ec9d189 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -2216,6 +2216,20 @@ class AppLocalizationsEn extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index b8b13746..b1c00d47 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -2242,6 +2242,20 @@ class AppLocalizationsEs extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index 54b578fb..71c21817 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -2248,6 +2248,20 @@ class AppLocalizationsFr extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index a0218834..fac89982 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -2252,6 +2252,20 @@ class AppLocalizationsHu extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index 6db391b4..169dff31 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -2244,6 +2244,20 @@ class AppLocalizationsIt extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index 1c1a7305..122c6e8e 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -2180,6 +2180,20 @@ class AppLocalizationsJa extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index 46356832..5a72e294 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -2175,6 +2175,20 @@ class AppLocalizationsKo extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index f7cc365c..f35f990d 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -2232,6 +2232,20 @@ class AppLocalizationsNl extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index c70d795a..fa3a7f75 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -2254,6 +2254,20 @@ class AppLocalizationsPl extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index 184b66f3..8f97aca7 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -2241,6 +2241,20 @@ class AppLocalizationsPt extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index 45669e0d..0caafcef 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -2242,6 +2242,20 @@ class AppLocalizationsRu extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 015dd361..9cdf3a74 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -2233,6 +2233,20 @@ class AppLocalizationsSk extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index 8c48015f..22400f26 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -2230,6 +2230,20 @@ class AppLocalizationsSl extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index 65d65daf..10f58a68 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -2224,6 +2224,20 @@ class AppLocalizationsSv extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index a9f461bc..8a6b17a5 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -2237,6 +2237,20 @@ class AppLocalizationsUk extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index e33c8a8d..2da415f3 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -2161,6 +2161,20 @@ class AppLocalizationsZh extends AppLocalizations { @override String get sendLogs_noteLabel => 'What happened? (optional)'; + @override + String get sendLogs_nameLabel => 'Name or screen name (optional)'; + + @override + String get sendLogs_emailLabel => 'Email (optional)'; + + @override + String get sendLogs_emailInvalid => + 'That doesn\'t look like an email address. Fix it or leave it empty.'; + + @override + String get sendLogs_contactNote => + 'If you leave these empty, we can\'t reach you to give you an update. Anything you enter is encrypted with the logs and used only to follow up on this report.'; + @override String get sendLogs_preparing => 'Gathering the logs'; diff --git a/lib/screens/send_logs_screen.dart b/lib/screens/send_logs_screen.dart index 41aaa932..002dd7b3 100644 --- a/lib/screens/send_logs_screen.dart +++ b/lib/screens/send_logs_screen.dart @@ -47,6 +47,8 @@ enum _Phase { preparing, empty, prepareFailed, ready, sending, failed, sent } class _SendLogsScreenState extends State { final _note = TextEditingController(); + final _name = TextEditingController(); + final _email = TextEditingController(); late final LogUploader _uploader = widget.uploader ?? LogUploader(); _Phase _phase = _Phase.preparing; Uint8List? _zip; @@ -63,9 +65,18 @@ class _SendLogsScreenState extends State { @override void dispose() { _note.dispose(); + _name.dispose(); + _email.dispose(); super.dispose(); } + static final _emailShape = RegExp(r'^[^@\s]+@[^@\s]+\.[^@\s]+$'); + + bool get _emailInvalid { + final email = _email.text.trim(); + return email.isNotEmpty && !_emailShape.hasMatch(email); + } + Future _prepare(MeshCoreConnector radio) async { Uint8List? zip; try { @@ -96,10 +107,10 @@ class _SendLogsScreenState extends State { Future _send() async { final zip = _zip; - if (zip == null) return; + if (zip == null || _emailInvalid) return; setState(() => _phase = _Phase.sending); final result = await _uploader.send( - zip, + LogPackage.withSender(zip, name: _name.text, email: _email.text), platform: kIsWeb ? 'web' : defaultTargetPlatform.name, appVersion: appLogger.appVersion, note: _note.text, @@ -182,8 +193,33 @@ class _SendLogsScreenState extends State { ), ), const SizedBox(height: 8), + TextField( + controller: _name, + enabled: canSend, + maxLength: 100, + decoration: InputDecoration( + labelText: l10n.sendLogs_nameLabel, + border: const OutlineInputBorder(), + ), + ), + const SizedBox(height: 8), + TextField( + controller: _email, + enabled: canSend, + maxLength: 254, + keyboardType: TextInputType.emailAddress, + autocorrect: false, + onChanged: (_) => setState(() {}), + decoration: InputDecoration( + labelText: l10n.sendLogs_emailLabel, + errorText: _emailInvalid ? l10n.sendLogs_emailInvalid : null, + border: const OutlineInputBorder(), + ), + ), + Text(l10n.sendLogs_contactNote, style: theme.textTheme.bodySmall), + const SizedBox(height: 12), FilledButton.icon( - onPressed: canSend ? _send : null, + onPressed: canSend && !_emailInvalid ? _send : null, icon: const Icon(Icons.cloud_upload_outlined), label: Text( _phase == _Phase.failed diff --git a/lib/services/log_package.dart b/lib/services/log_package.dart index 460c0756..3cd93a20 100644 --- a/lib/services/log_package.dart +++ b/lib/services/log_package.dart @@ -138,6 +138,27 @@ class LogPackage { return ZipEncoder().encodeBytes(archive); } + static const String senderName = 'sender.json'; + + /// [zip] with `sender.json` added when the sender gave a name or an email + /// (#1190). It travels inside the sealed package, never in a header, so the + /// intake issue never shows it. + static Uint8List withSender(Uint8List zip, {String? name, String? email}) { + final sender = { + if (name != null && name.trim().isNotEmpty) 'name': name.trim(), + if (email != null && email.trim().isNotEmpty) 'email': email.trim(), + }; + if (sender.isEmpty) return zip; + final archive = ZipDecoder().decodeBytes(zip) + ..addFile( + ArchiveFile.string( + senderName, + const JsonEncoder.withIndent(' ').convert(sender), + ), + ); + return ZipEncoder().encodeBytes(archive); + } + /// Every file, at its path inside the package, in one zip. Future zip() async { final archive = Archive(); diff --git a/test/screens/send_logs_screen_test.dart b/test/screens/send_logs_screen_test.dart index 68287937..e68b5a0b 100644 --- a/test/screens/send_logs_screen_test.dart +++ b/test/screens/send_logs_screen_test.dart @@ -1,5 +1,7 @@ +import 'dart:convert'; import 'dart:typed_data'; +import 'package:archive/archive.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:meshcore_open/connector/meshcore_connector.dart'; @@ -50,7 +52,70 @@ Future _pump( return AppLocalizations.of(tester.element(find.byType(SendLogsScreen))); } +Future _tapSend(WidgetTester tester, AppLocalizations l10n) async { + await tester.ensureVisible(find.text(l10n.sendLogs_send)); + await tester.pumpAndSettle(); + await tester.tap(find.text(l10n.sendLogs_send)); + await tester.pumpAndSettle(); +} + +Uint8List _realZip() => ZipEncoder().encodeBytes( + Archive()..addFile(ArchiveFile.string('manifest.json', '{"format": 1}')), +); + void main() { + testWidgets('name and email are sealed inside the package, not the note', ( + tester, + ) async { + final zip = _realZip(); + final uploader = _FakeUploader([const LogUploadSent('OB-7K2QX')]); + final l10n = await _pump( + tester, + uploader: uploader, + zipPackage: (_) async => zip, + ); + + await tester.enterText( + find.widgetWithText(TextField, l10n.sendLogs_nameLabel), + ' Pottsytron ', + ); + await tester.enterText( + find.widgetWithText(TextField, l10n.sendLogs_emailLabel), + 'ben@example.com', + ); + await _tapSend(tester, l10n); + + final (sent, note) = uploader.sent.single; + expect(note, isEmpty); + final files = ZipDecoder().decodeBytes(sent); + expect(files.findFile('manifest.json'), isNotNull); + final sender = jsonDecode( + utf8.decode(files.findFile('sender.json')!.content as List), + ); + expect(sender, {'name': 'Pottsytron', 'email': 'ben@example.com'}); + }); + + testWidgets('a mistyped email blocks the send and says why', (tester) async { + final uploader = _FakeUploader([const LogUploadSent('OB-7K2QX')]); + final l10n = await _pump(tester, uploader: uploader); + final email = find.widgetWithText(TextField, l10n.sendLogs_emailLabel); + + await tester.enterText(email, 'ben@example'); + await tester.pump(); + expect(find.text(l10n.sendLogs_emailInvalid), findsOneWidget); + await tester.ensureVisible(find.text(l10n.sendLogs_send)); + await tester.pumpAndSettle(); + await tester.tap(find.text(l10n.sendLogs_send), warnIfMissed: false); + await tester.pumpAndSettle(); + expect(uploader.sent, isEmpty); + + await tester.enterText(email, ''); + await tester.pump(); + expect(find.text(l10n.sendLogs_emailInvalid), findsNothing); + await _tapSend(tester, l10n); + expect(uploader.sent, hasLength(1)); + }); + testWidgets('says what is sent, then sends and shows the code', ( tester, ) async { @@ -59,10 +124,14 @@ void main() { expect(find.text(l10n.sendLogs_consent), findsOneWidget); expect(find.text(l10n.sendLogs_size('3 KB')), findsOneWidget); - await tester.enterText(find.byType(TextField), 'lost a DM'); - await tester.tap(find.text(l10n.sendLogs_send)); - await tester.pumpAndSettle(); + expect(find.text(l10n.sendLogs_contactNote), findsOneWidget); + await tester.enterText( + find.widgetWithText(TextField, l10n.sendLogs_noteLabel), + 'lost a DM', + ); + await _tapSend(tester, l10n); + // No name or email: the package goes out exactly as built. expect(uploader.sent.single.$1, _zip); expect(uploader.sent.single.$2, 'lost a DM'); expect(find.text('OB-7K2QX'), findsOneWidget); @@ -79,11 +148,12 @@ void main() { ]); final l10n = await _pump(tester, uploader: uploader); - await tester.tap(find.text(l10n.sendLogs_send)); - await tester.pumpAndSettle(); + await _tapSend(tester, l10n); await tester.pump(const Duration(seconds: 30)); expect(find.text(l10n.sendLogs_failedNetwork), findsOneWidget); + await tester.ensureVisible(find.text(l10n.sendLogs_retry)); + await tester.pumpAndSettle(); await tester.tap(find.text(l10n.sendLogs_retry)); await tester.pumpAndSettle(); expect(uploader.sent, hasLength(2)); @@ -112,8 +182,7 @@ void main() { tester, uploader: _FakeUploader([LogUploadFailed(failure, 'x')]), ); - await tester.tap(find.text(l10n.sendLogs_send)); - await tester.pumpAndSettle(); + await _tapSend(tester, l10n); expect(find.text(text(l10n)), findsOneWidget); }); } diff --git a/untranslated.json b/untranslated.json index d4f7301d..ff47c670 100644 --- a/untranslated.json +++ b/untranslated.json @@ -214,6 +214,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -666,6 +670,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -1118,6 +1126,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -1570,6 +1582,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -2022,6 +2038,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -2474,6 +2494,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -2926,6 +2950,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -3378,6 +3406,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -3830,6 +3862,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -4282,6 +4318,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -4734,6 +4774,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -5186,6 +5230,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -5638,6 +5686,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -6090,6 +6142,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -6542,6 +6598,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -6994,6 +7054,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send", @@ -7446,6 +7510,10 @@ "sendLogs_title", "sendLogs_consent", "sendLogs_noteLabel", + "sendLogs_nameLabel", + "sendLogs_emailLabel", + "sendLogs_emailInvalid", + "sendLogs_contactNote", "sendLogs_preparing", "sendLogs_size", "sendLogs_send",