Skip to content

Conversation

chrisbobbe
Copy link
Collaborator

Stacked atop #1782, which is an improvement to the tests that I found while working this (actually while pairing with @sm-sayedi 🙂) plus a fix for something we overlooked in #1017.


There's a planned change to make zulipMergeBase required in
GetServerSettingsResult (see #904). When we do that, we'd otherwise
just treat a missing zulipMergeBase on an ancient server the same
way we treat any malformed response. Better to check if the server
is an ancient one we don't support, just like when the /register
response is malformed.

@chrisbobbe chrisbobbe requested a review from gnprice August 4, 2025 23:26
@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.

Thanks for taking care of this! Looks good; small comments.

import '../api/core.dart';
import '../api/exception.dart';
import '../api/model/initial_snapshot.dart';
import '../api/route/realm.dart';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: third commit removes this line; second commit could omit adding it

connection.prepare(json: serverSettings.toJson());
await tester.tap(find.text('Continue'));
await tester.pump(Duration.zero);
checkNoDialog(tester);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

third commit has an error at this line

Comment on lines 100 to 101
await tester.pump((pushedRoute as TransitionRoute).transitionDuration);
await tester.pump();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this do the job?

Suggested change
await tester.pump((pushedRoute as TransitionRoute).transitionDuration);
await tester.pump();
await testNavObserver.pumpPastTransition(tester);

(Then also pushedRoute above can be inlined.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, TIL we made TestNavigatorObserver extend TransitionDurationObserver :) in d7fac5d

Comment on lines 109 to 113
testBinding.globalStore.useCachedApiConnections = true;
connection = testBinding.globalStore.apiConnection(
realmUrl: serverSettings.realmUrl,
zulipFeatureLevel: null);

await tester.enterText(find.byType(TextField),
serverSettings.realmUrl.toString());

connection.prepare(json: serverSettings.toJson());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the making an API connection (to go into the global cache), and then preparing a response, go logically together and separate from the entering text into the input.

So like:

Suggested change
testBinding.globalStore.useCachedApiConnections = true;
connection = testBinding.globalStore.apiConnection(
realmUrl: serverSettings.realmUrl,
zulipFeatureLevel: null);
await tester.enterText(find.byType(TextField),
serverSettings.realmUrl.toString());
connection.prepare(json: serverSettings.toJson());
await tester.enterText(find.byType(TextField),
serverSettings.realmUrl.toString());
testBinding.globalStore.useCachedApiConnections = true;
connection = testBinding.globalStore.apiConnection(
realmUrl: serverSettings.realmUrl,
zulipFeatureLevel: null);
connection.prepare(json: serverSettings.toJson());

@chrisbobbe chrisbobbe force-pushed the pr-ancient-servers-server-settings branch from 10e5f91 to 96f59ba Compare August 6, 2025 23:48
@chrisbobbe
Copy link
Collaborator Author

Thanks, revision pushed! PTAL.

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! One remaining comment.

Comment on lines 127 to 135
testBinding.globalStore.useCachedApiConnections = true;
connection = testBinding.globalStore.apiConnection(
realmUrl: serverSettings.realmUrl,
zulipFeatureLevel: null);

await tester.enterText(find.byType(TextField),
serverSettings.realmUrl.toString());

connection.prepare(json: serverSettings.toJson());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump #1783 (comment) 🙂

Also I suspect this group of tests would be clarified by a little helper. Something like:

    await attempt(tester, serverSettings.realmUrl, serverSettings.toJson());

which would cover all these lines and the tap/pump below, and leave the caller to finish up with just the check steps.

@@ -7,7 +7,6 @@ import 'package:url_launcher/url_launcher.dart';
import 'package:zulip/model/settings.dart';
import 'package:zulip/widgets/app.dart';
import 'package:zulip/widgets/dialog.dart';
import 'package:zulip/widgets/store.dart';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dialog test [nfc]: Remove an unused import

Looks like this slipped through CI, introduced recently in
8d3c1284e.

Ah, oops. I guess that changed in your revision of #1782, and I merged before CI finished running.

… In fact I'm pretty sure I ran flutter test on this very file before merging, because I saw CI wasn't done. But I guess I should have checked the analyzer output too.

@chrisbobbe chrisbobbe force-pushed the pr-ancient-servers-server-settings branch from 96f59ba to 73be315 Compare August 7, 2025 00:26
@chrisbobbe
Copy link
Collaborator Author

Thanks, revision pushed!

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! Just nits below; otherwise all looks good.

await testNavObserver.pumpPastTransition(tester);
}

Future<void> attempt(WidgetTester tester,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these two commits can be squashed 🙂

0b07032 login test: Add happy-path test for AddAccountPage
0b5f728 login test [nfc]: Pull out an attempt helper in AddAccountPage test

Comment on lines 166 to 168
.throws<void>();


await attempt(tester, serverSettings.realmUrl, serverSettingsMalformedJson);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: double blank line

@chrisbobbe
Copy link
Collaborator Author

Thanks, fixed!

There's a planned change to make zulipMergeBase required in
GetServerSettingsResult (see zulip#904). When we do that, we'd otherwise
just treat a missing zulipMergeBase on an ancient server the same
way we treat any malformed response. Better to check if the server
is an ancient one we don't support, just like when the /register
response is malformed.
@chrisbobbe chrisbobbe force-pushed the pr-ancient-servers-server-settings branch from 73be315 to 733bb88 Compare August 7, 2025 00:39
@gnprice
Copy link
Member

gnprice commented Aug 7, 2025

Thanks! Looks good; merging.

@gnprice gnprice merged commit 733bb88 into zulip:main Aug 7, 2025
1 check passed
gnprice pushed a commit to PIG208/zulip-flutter that referenced this pull request Aug 14, 2025
See "Feature level 88" from Zulip API changelog:

   https://zulip.com/api/changelog

This is one of the few places (along with registerQueue) where it's
important that we smoothly handle attempting to connect to an
ancient server where this field might indeed be missing.  Happily,
we do handle those since commit 733bb88 (zulip#1783).
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