Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

VatsalBhesaniya
Copy link

@VatsalBhesaniya VatsalBhesaniya commented Mar 27, 2024

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

Simulator Screenshot - iPhone 15 Pro Max - 2024-03-29 at 10 55 02

Screen.Recording.2024-03-28.at.7.06.06.PM.mov

Screenshot_1711685963

@abelaba
Copy link
Contributor

abelaba commented Mar 27, 2024

Hey, so one thing I would say is that your commit message should have a description. As stated here
https://zulip.readthedocs.io/en/latest/contributing/commit-discipline.html#commit-description

@abelaba
Copy link
Contributor

abelaba commented Mar 27, 2024

You must also add new tests for your code so that maintainers will review your code in detail.
https://github.com/zulip/zulip-flutter?tab=readme-ov-file#writing-tests

Copy link
Collaborator

@chrisbobbe chrisbobbe left a 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 and checkErrorDialog.

Also, please mark the commit with a Fixes line. I see you've already done this in the GitHub PR description. 🙂

lib/widgets/login.dart Outdated Show resolved Hide resolved
assets/l10n/app_en.arb Outdated Show resolved Hide resolved
lib/widgets/login.dart Outdated Show resolved Hide resolved
lib/widgets/login.dart Show resolved Hide resolved
lib/widgets/login.dart Outdated Show resolved Hide resolved
@VatsalBhesaniya VatsalBhesaniya force-pushed the login-server-url-doc-link branch 4 times, most recently from 130093f to 3d0f90a Compare March 28, 2024 13:25
@VatsalBhesaniya
Copy link
Author

Hey, so one thing I would say is that your commit message should have a description. As stated here https://zulip.readthedocs.io/en/latest/contributing/commit-discipline.html#commit-description

@abelaba Thank you for your feedback. 🙂

@VatsalBhesaniya
Copy link
Author

VatsalBhesaniya commented Mar 28, 2024

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 and checkErrorDialog.

Also, please mark the commit with a Fixes line. I see you've already done this in the GitHub PR description. 🙂

Thanks for the positive feedback! 🙂
I appreciate your suggestions on tests. I've added tests covering the success and the error cases.

I've also updated the commit message to include the Fixes line.

Please let me know if you have any further feedback or require any additional changes to the tests.

@chrisbobbe
Copy link
Collaborator

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 TODO(#109) in the code that should be removed in the commit that's marked as fixing #109. I've proposed an automated way to catch things like this:

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.

Thanks @VatsalBhesaniya for adding this (and for the upstream PR flutter/flutter#145157 that added this helper field!) See comments below.

lib/widgets/login.dart Outdated Show resolved Hide resolved
lib/widgets/login.dart Outdated Show resolved Hide resolved
test/widgets/login_test.dart Outdated Show resolved Hide resolved
test/widgets/login_test.dart Outdated Show resolved Hide resolved
test/widgets/login_test.dart Outdated Show resolved Hide resolved
test/widgets/login_test.dart Outdated Show resolved Hide resolved
assets/l10n/app_en.arb Outdated Show resolved Hide resolved
@VatsalBhesaniya VatsalBhesaniya force-pushed the login-server-url-doc-link branch 12 times, most recently from 3585ecd to 98f2e2f Compare March 29, 2024 07:46
@VatsalBhesaniya VatsalBhesaniya requested a review from gnprice March 29, 2024 08:46
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.

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:

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.

lib/widgets/launch_url.dart Outdated Show resolved Hide resolved
lib/widgets/launch_url.dart Outdated Show resolved Hide resolved
@VatsalBhesaniya VatsalBhesaniya force-pushed the login-server-url-doc-link branch 4 times, most recently from fbbcc13 to a683136 Compare April 2, 2024 11:57
@VatsalBhesaniya VatsalBhesaniya force-pushed the login-server-url-doc-link branch 10 times, most recently from f5efcb1 to e003a66 Compare April 10, 2024 10:49
@chrisbobbe
Copy link
Collaborator

chrisbobbe commented Apr 10, 2024

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

@VatsalBhesaniya
Copy link
Author

VatsalBhesaniya commented Apr 11, 2024

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.
Now I can see all of my updates. 🙂

Copy link
Collaborator

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

lib/widgets/login.dart Show resolved Hide resolved
lib/widgets/launch_url.dart Outdated Show resolved Hide resolved
test/widgets/login_test.dart Outdated Show resolved Hide resolved
test/widgets/login_test.dart Outdated Show resolved Hide resolved
test/widgets/login_test.dart Outdated Show resolved Hide resolved
@gnprice gnprice added the completion candidate PR with reviews that may unblock merging label May 14, 2024
@chrisbobbe
Copy link
Collaborator

Hi @VatsalBhesaniya, are you planning to return to this?

@VatsalBhesaniya VatsalBhesaniya force-pushed the login-server-url-doc-link branch 3 times, most recently from f1adf84 to 54ce074 Compare May 23, 2024 03:38
- 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.
@VatsalBhesaniya VatsalBhesaniya force-pushed the login-server-url-doc-link branch from 54ce074 to 560a4e0 Compare May 23, 2024 03:47
@VatsalBhesaniya
Copy link
Author

Hi @VatsalBhesaniya, are you planning to return to this?

Sorry for the delay. I have made all the changes requested.

@chrisbobbe
Copy link
Collaborator

Great, thank you! This revision LGTM; I'll mark this for Greg's review now.

@chrisbobbe chrisbobbe added the integration review Added by maintainers when PR may be ready for integration label Jun 5, 2024
@alya
Copy link
Collaborator

alya commented Jun 7, 2024

I don't understand the "Unable to open link" screenshots in the PR description. Is that something users will see?

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.

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

Comment on lines +24 to +25
/// Launches a URL without considering a realm base URL.
void launchUrlWithoutRealm(BuildContext context, Uri url) async {
Copy link
Member

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:

Suggested change
/// 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 {
Copy link
Member

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.

Comment on lines +12 to +13
/// Handles showing an error dialog with a customizable message.
Future<void> _showError(BuildContext context, String? message, String urlString) {
Copy link
Member

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.

See:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#avoid-useless-documentation

} on PlatformException catch (e) {
errorMessage = e.message;
}
if (!launched) { // TODO(log)
Copy link
Member

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/"}
Copy link
Member

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:

Suggested change
"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
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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.

@PIG208
Copy link
Member

PIG208 commented Oct 3, 2024

Hi @VatsalBhesaniya! Thanks for the previous revisions. Any plan to continue working on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completion candidate PR with reviews that may unblock merging 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.

login: Link to doc to help users understand what a "server URL" is and how to find theirs
6 participants