-
Notifications
You must be signed in to change notification settings - Fork 342
dialog: Remove no-op SingleChildScrollView; have tests' checkNoDialog describe dialog #1782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm good catch, thanks. Generally all looks good; various small comments.
test/widgets/dialog_checks.dart
Outdated
...find.bySubtype<AlertDialog>().evaluate().map((e) => e.widget), | ||
...find.byType(CupertinoAlertDialog).evaluate().map((e) => e.widget), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this is equivalent, right?
...find.bySubtype<AlertDialog>().evaluate().map((e) => e.widget), | |
...find.byType(CupertinoAlertDialog).evaluate().map((e) => e.widget), | |
...tester.widgetList(find.bySubtype<AlertDialog>()), | |
...tester.widgetList(find.byType(CupertinoAlertDialog)), |
test/widgets/dialog_checks.dart
Outdated
throw TestFailure(message); | ||
} | ||
|
||
check(find.byType(Dialog)).findsNothing(); // TODO is this needed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems useful to have for good measure — i.e. just to be sure there's not an unexpected kind of dialog that in the future it turns out we're using somewhere.
test/widgets/dialog_checks.dart
Outdated
} | ||
} | ||
} | ||
throw TestFailure(message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, this is a good way to construct a custom failure message — bypassing the assertions library (package:checks, or package:test) and taking control directly using ordinary Dart features.
test/widgets/dialog_checks.dart
Outdated
message += ' content: '; | ||
if (contentTexts.isNotEmpty) { | ||
message += contentTexts.map((t) => t.data).join('\n '); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best to use a StringBuffer rather than +=
on a String.
(This isn't a performance-critical spot here; but it's not significantly harder and sets a good example.)
lib/widgets/dialog.dart
Outdated
Widget? _adaptiveMessage(String? message) { | ||
if (message == null) return null; | ||
|
||
return _adaptiveContent(Text(message)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this function can be inlined — it's not really encapsulating any information that doesn't naturally go at its caller.
test/widgets/dialog_test.dart
Outdated
final context = tester.element(find.byType(ChooseAccountPage)); | ||
// TODO could do this with [TestGlobalStore] or similar? | ||
await GlobalStoreWidget.of(context) | ||
.settings.debugSetLegacyUpgradeState(LegacyUpgradeState.found); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right — this is how we'd normally do it, no?
final context = tester.element(find.byType(ChooseAccountPage)); | |
// TODO could do this with [TestGlobalStore] or similar? | |
await GlobalStoreWidget.of(context) | |
.settings.debugSetLegacyUpgradeState(LegacyUpgradeState.found); | |
await testBinding.globalStore | |
.settings.debugSetLegacyUpgradeState(LegacyUpgradeState.found); |
(with maybe ".settings" moved to the previous line)
Example output on failure: 00:05 +66: message action sheet ReactionButtons +1 request has an error; useLegacy: false ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════ The following TestFailure was thrown running a test: Found dialog(s) when none were expected: Dialog: title: Adding reaction failed content: Invalid message(s) When the exception was thrown, this was the stack: <asynchronous suspension> <asynchronous suspension> <asynchronous suspension> <asynchronous suspension> (elided one frame from package:stack_trace) The test description was: +1 request has an error; useLegacy: false ════════════════════════════════════════════════════════════════════════════════════════════════════ 00:05 +66 -1: message action sheet ReactionButtons +1 request has an error; useLegacy: false [E] Test failed. See exception logs above. The test description was: +1 request has an error; useLegacy: false
In zulip#1017, we overlooked the fact that a SingleChildScrollView is added automatically on iOS but not on Android. I haven't reproduced an observable bug that comes from this, but it calls for a fix. I tested this change manually on iOS (showErrorDialog, showSuggestedActionDialog, and UpgradeWelcomeDialog), with short text and long text (longer than a screenful, to check the scrolling works).
38a0878
to
8d3c128
Compare
Thanks! Revision pushed. |
Thanks! Looks good; merging. |
No description provided.