-
Notifications
You must be signed in to change notification settings - Fork 214
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
Add helper text for "server URL" with link to documentation #595
base: main
Are you sure you want to change the base?
Add helper text for "server URL" with link to documentation #595
Conversation
Hey, so one thing I would say is that your commit message should have a description. As stated here |
You must also add new tests for your code so that maintainers will review your code in detail. |
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.
Thanks @VatsalBhesaniya, I'm looking forward to this! This will help people get what they need to start using the app.
Small comments below. Also, this will need tests. Here are the things I would test:
- Basic happy case: When the text is tapped, the URL is opened. For this, see our uses of
testBinding.takeLaunchUrlCalls()
. - Error case: When the URL fails to be opened, we show an error dialog. For this, see our uses of
testBinding.launchUrlResult
andcheckErrorDialog
.
Also, please mark the commit with a Fixes
line. I see you've already done this in the GitHub PR description. 🙂
130093f
to
3d0f90a
Compare
@abelaba Thank you for your feedback. 🙂 |
Thanks for the positive feedback! 🙂 I've also updated the commit message to include the Please let me know if you have any further feedback or require any additional changes to the tests. |
Hi! One small comment I meant to leave last time, and I think Greg intends to do the next full review. 🙂 There's still a |
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.
Thanks @VatsalBhesaniya for adding this (and for the upstream PR flutter/flutter#145157 that added this helper
field!) See comments below.
3585ecd
to
98f2e2f
Compare
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.
Thanks @VatsalBhesaniya for the revision!
In this version, the first commit introduces a duplicate _launchUrl
function which is missing the mode
logic, much like in the previous revision as discussed at #595 (comment) . Then the second commit deduplicates the two functions into one combined place.
As part of writing clear and coherent commits, we want to avoid that intermediate step where we're adding a _launchUrl
function that has the wrong behavior. So instead a good commit sequence would be:
- Move the existing
_launchUrl
to the new file, renaming it, perhaps splitting into pieces, but maintaining the exact same behavior. This will be an NFC commit. - Add i18n for that function.
- Add the UI that resolves login: Link to doc to help users understand what a "server URL" is and how to find theirs #109, calling that function.
After that's done it'll again be possible to do a fine-grained review. In the meantime, here's a couple of comments from a high-level look.
fbbcc13
to
a683136
Compare
f5efcb1
to
e003a66
Compare
Hi @VatsalBhesaniya, it looks like you've updated the PR branch. Is it ready for another review? When you push updates and it's ready for another review, it's helpful if you post a comment saying so, for explicitness; that way reviewers don't have to guess. 🙂 |
Hi @chrisbobbe, Yes, the PR branch is ready for another review! I apologize for the confusion. I made updates locally, but for some reason, they weren't reflecting on GitHub 🤔. This hasn't happened to me before, so I hesitated to request another review until I was certain everything was pushed correctly. |
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.
Thanks @VatsalBhesaniya! This is very close. Small comments below, and also #595 (comment) (which doesn't appear below for some reason).
Hi @VatsalBhesaniya, are you planning to return to this? |
f1adf84
to
54ce074
Compare
- Move the existing launchUrl logic from content.dart to a new file named launch_url.dart. - Split function into pieces to handle realm-based and non-realm URLs. - Refactor error handling into a private function.
54ce074
to
560a4e0
Compare
Sorry for the delay. I have made all the changes requested. |
Great, thank you! This revision LGTM; I'll mark this for Greg's review now. |
I don't understand the "Unable to open link" screenshots in the PR description. Is that something users will see? |
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.
Thanks @VatsalBhesaniya, and thanks @chrisbobbe for the previous revisions! Code comments below.
Echoing Alya's question: what are the circumstances where you'd expect a user to see that error dialog?
In addition to the two screen recordings, which are helpful for the interaction of opening the link: I think a very helpful thing to include as a screenshot would be just this add-account screen itself. That'd help for being able to look at the new helper text and gauge how it looks. (A video is less good for that because it's hard to get it in full resolution.)
/// Launches a URL without considering a realm base URL. | ||
void launchUrlWithoutRealm(BuildContext context, Uri url) async { |
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.
From the name, I can't really tell what this does; I don't know what "without realm" means.
I think what this function is really about in contrast with launchUrlWithRealm
is that it requires the URL to be already resolved to an absolute URL — it won't accept a relative link. So we can rename it accordingly.
We can also revise the doc to be more specific about what "launch" means, following the upstream launchUrl
doc; and add an assert checking that expectation of an absolute URL:
/// Launches a URL without considering a realm base URL. | |
void launchUrlWithoutRealm(BuildContext context, Uri url) async { | |
/// Pass a URL to the underlying platform for handling. | |
/// | |
/// [url] must be an absolute URL. | |
/// For possibly-relative URLs, consider [launchUrlWithRealm]. | |
void launchAbsoluteUrl(BuildContext context, Uri url) async { | |
assert(url.hasScheme); |
} | ||
|
||
/// Launches a URL considering a realm base URL. | ||
void launchUrlWithRealm(BuildContext context, String urlString) async { |
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.
Similarly I don't feel like "with realm" quite makes clear what the relationship to the realm is. I think launchUrlWithRealmBase
would do it.
/// Handles showing an error dialog with a customizable message. | ||
Future<void> _showError(BuildContext context, String? message, String urlString) { |
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.
This doc doesn't really add anything beyond the function's name and parameters; so better to leave it out.
} on PlatformException catch (e) { | ||
errorMessage = e.message; | ||
} | ||
if (!launched) { // TODO(log) |
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.
This // TODO(log)
got dropped. Was that intended?
"@errorUnableToOpenLinkMessage": { | ||
"description": "Error message when a link fails to open.", | ||
"placeholders": { | ||
"url": {"type": "String", "example": "http://example.com/"} |
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: even in examples, let's stick to HTTPS everywhere:
"url": {"type": "String", "example": "http://example.com/"} | |
"url": {"type": "String", "example": "https://example.com/"} |
@@ -61,7 +64,44 @@ void main() { | |||
expectErrorFromText('[email protected]', ServerUrlValidationError.noUseEmail); | |||
}); | |||
|
|||
// TODO test AddAccountPage |
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.
There's lots more to test on this page 🙂 — so this TODO is still relevant and let's keep it.
)); | ||
} | ||
|
||
final zulipLocalizations = GlobalLocalizations.zulipLocalizations; |
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.
This GlobalLocalizations.zulipLocalizations
is application state that can change. So reading it should happen within individual test cases (including helpers they call), i.e. individual testWidgets
callbacks, not outside them.
|
||
testWidgets('shows error dialog when URL fails to open', (tester) async { | ||
await prepareAddAccountPage(tester); | ||
testBinding.launchUrlResult = false; |
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.
When a test manipulates testBinding
, it needs to call addTearDown(testBinding.reset)
somewhere so that the state gets reset before the next test.
(In the "error dialog if invalid link" in widgets/content_test.dart which this one is presumably based on, that gets taken care of by the prepare
helper, because the latter does other things with testBinding
that also need a reset.)
You can reproduce the problem with the command:
$ flutter test test/widgets/login_test.dart --test-randomize-ordering-seed=random
At your current revision, that often fails because launchUrlResult
remains set to false when the other new test tries to run. After you fix the problem with a reset, that command should pass every time.
Hi @VatsalBhesaniya! Thanks for the previous revisions. Any plan to continue working on this? |
Add helper text below the "server URL" field that, when tapped, opens relevant Zulip documentation explaining what a server URL is and how to find theirs. It will help users understand the "server URL" field during login.
Fixes: #109
Screen.Recording.2024-03-29.at.10.53.04.AM.mov
Screen.Recording.2024-03-28.at.7.06.06.PM.mov