Skip to content

Conversation

chrisbobbe
Copy link
Collaborator

No description provided.

@chrisbobbe chrisbobbe requested a review from gnprice August 4, 2025 23:15
@chrisbobbe chrisbobbe added the integration review Added by maintainers when PR may be ready for integration label Aug 4, 2025
Copy link
Member

@gnprice gnprice left a 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.

Comment on lines 61 to 62
...find.bySubtype<AlertDialog>().evaluate().map((e) => e.widget),
...find.byType(CupertinoAlertDialog).evaluate().map((e) => e.widget),
Copy link
Member

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?

Suggested change
...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)),

throw TestFailure(message);
}

check(find.byType(Dialog)).findsNothing(); // TODO is this needed?
Copy link
Member

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.

}
}
}
throw TestFailure(message);
Copy link
Member

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.

Comment on lines 82 to 84
message += ' content: ';
if (contentTexts.isNotEmpty) {
message += contentTexts.map((t) => t.data).join('\n ');
Copy link
Member

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.)

Comment on lines 59 to 62
Widget? _adaptiveMessage(String? message) {
if (message == null) return null;

return _adaptiveContent(Text(message));
Copy link
Member

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.

Comment on lines 159 to 162
final context = tester.element(find.byType(ChooseAccountPage));
// TODO could do this with [TestGlobalStore] or similar?
await GlobalStoreWidget.of(context)
.settings.debugSetLegacyUpgradeState(LegacyUpgradeState.found);
Copy link
Member

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?

Suggested change
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).
@chrisbobbe chrisbobbe force-pushed the pr-dialog-improvements branch from 38a0878 to 8d3c128 Compare August 6, 2025 23:01
@chrisbobbe
Copy link
Collaborator Author

Thanks! Revision pushed.

@gnprice
Copy link
Member

gnprice commented Aug 6, 2025

Thanks! Looks good; merging.

@gnprice gnprice merged commit 8d3c128 into zulip:main Aug 6, 2025
1 check failed
@chrisbobbe chrisbobbe deleted the pr-dialog-improvements branch August 6, 2025 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration review Added by maintainers when PR may be ready for integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants