Skip to content

Commit 2cf973f

Browse files
committed
store [nfc]: Add assertion on zulipFeatureLevel
1 parent 5ec097c commit 2cf973f

File tree

5 files changed

+28
-14
lines changed

5 files changed

+28
-14
lines changed

lib/model/store.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ class PerAccountStore extends PerAccountStoreBase with ChangeNotifier, EmojiStor
571571
/// be empty otherwise.
572572
// TODO(server-10) simplify this
573573
String get realmEmptyTopicDisplayName {
574+
assert(zulipFeatureLevel >= 334);
574575
assert(_realmEmptyTopicDisplayName != null); // TODO(log)
575576
return _realmEmptyTopicDisplayName ?? 'general chat';
576577
}

test/widgets/action_sheet_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ void main() {
450450
});
451451

452452
testWidgets('show from app bar: resolve/unresolve not offered when topic is empty', (tester) async {
453-
await prepare();
453+
await prepare(zulipFeatureLevel: 334);
454454
final message = eg.streamMessage(stream: someChannel, topic: '');
455455
await showFromAppBar(tester,
456456
topic: TopicName(''),

test/widgets/autocomplete_test.dart

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,14 @@ Future<Finder> setupToComposeInput(WidgetTester tester, {
100100
Future<Finder> setupToTopicInput(WidgetTester tester, {
101101
required List<GetStreamTopicsEntry> topics,
102102
String? realmEmptyTopicDisplayName,
103+
int? zulipFeatureLevel,
103104
}) async {
104105
addTearDown(testBinding.reset);
105-
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot(
106+
final account = eg.selfAccount.copyWith(zulipFeatureLevel: zulipFeatureLevel);
107+
await testBinding.globalStore.add(account, eg.initialSnapshot(
108+
zulipFeatureLevel: zulipFeatureLevel,
106109
realmEmptyTopicDisplayName: realmEmptyTopicDisplayName));
107-
final store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
110+
final store = await testBinding.globalStore.perAccount(account.id);
108111
await store.addUser(eg.selfUser);
109112
final connection = store.connection as FakeApiConnection;
110113

@@ -121,7 +124,7 @@ Future<Finder> setupToTopicInput(WidgetTester tester, {
121124
messages: [message],
122125
).toJson());
123126

124-
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
127+
await tester.pumpWidget(TestZulipApp(accountId: account.id,
125128
child: MessageListPage(initNarrow: ChannelNarrow(stream.streamId))));
126129
await tester.pumpAndSettle();
127130

@@ -465,7 +468,8 @@ void main() {
465468
testWidgets('display realmEmptyTopicDisplayName for empty topic', (tester) async {
466469
final topic = eg.getStreamTopicsEntry(name: '');
467470
final topicInputFinder = await setupToTopicInput(tester, topics: [topic],
468-
realmEmptyTopicDisplayName: 'some display name');
471+
realmEmptyTopicDisplayName: 'some display name',
472+
zulipFeatureLevel: 334);
469473

470474
// TODO(#226): Remove this extra edit when this bug is fixed.
471475
await tester.enterText(topicInputFinder, ' ');
@@ -478,7 +482,8 @@ void main() {
478482
testWidgets('match realmEmptyTopicDisplayName in autocomplete', (tester) async {
479483
final topic = eg.getStreamTopicsEntry(name: '');
480484
final topicInputFinder = await setupToTopicInput(tester, topics: [topic],
481-
realmEmptyTopicDisplayName: 'general chat');
485+
realmEmptyTopicDisplayName: 'general chat',
486+
zulipFeatureLevel: 334);
482487

483488
// TODO(#226): Remove this extra edit when this bug is fixed.
484489
await tester.enterText(topicInputFinder, 'general ch');
@@ -491,7 +496,8 @@ void main() {
491496
testWidgets('autocomplete to realmEmptyTopicDisplayName sets topic to empty string', (tester) async {
492497
final topic = eg.getStreamTopicsEntry(name: '');
493498
final topicInputFinder = await setupToTopicInput(tester, topics: [topic],
494-
realmEmptyTopicDisplayName: 'general chat');
499+
realmEmptyTopicDisplayName: 'general chat',
500+
zulipFeatureLevel: 334);
495501
final controller = tester.widget<TextField>(topicInputFinder).controller!;
496502

497503
// TODO(#226): Remove this extra edit when this bug is fixed.

test/widgets/inbox_test.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,14 @@ void main() {
5858
List<Subscription>? subscriptions,
5959
List<User>? users,
6060
required List<Message> unreadMessages,
61+
int? zulipFeatureLevel,
6162
NavigatorObserver? navigatorObserver,
6263
}) async {
6364
addTearDown(testBinding.reset);
64-
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot());
65-
store = await testBinding.globalStore.perAccount(eg.selfAccount.id);
65+
final account = eg.selfAccount.copyWith(zulipFeatureLevel: zulipFeatureLevel);
66+
await testBinding.globalStore.add(account, eg.initialSnapshot(
67+
zulipFeatureLevel: zulipFeatureLevel));
68+
store = await testBinding.globalStore.perAccount(account.id);
6669

6770
await store.addStreams(streams ?? []);
6871
await store.addSubscriptions(subscriptions ?? []);
@@ -74,7 +77,7 @@ void main() {
7477
}
7578

7679
await tester.pumpWidget(TestZulipApp(
77-
accountId: eg.selfAccount.id,
80+
accountId: account.id,
7881
navigatorObservers: [if (navigatorObserver != null) navigatorObserver],
7982
child: const HomePage(),
8083
));
@@ -312,7 +315,8 @@ void main() {
312315
await setupPage(tester,
313316
streams: [channel],
314317
subscriptions: [(eg.subscription(channel))],
315-
unreadMessages: [eg.streamMessage(stream: channel, topic: '')]);
318+
unreadMessages: [eg.streamMessage(stream: channel, topic: '')],
319+
zulipFeatureLevel: 334);
316320
check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne();
317321
}, skip: true); // null topic names soon to be enabled
318322

test/widgets/message_list_test.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ void main() {
201201
await setupMessageListPage(tester,
202202
narrow: eg.topicNarrow(channel.streamId, ''),
203203
streams: [channel],
204-
messageCount: 1);
204+
messageCount: 1,
205+
zulipFeatureLevel: 334);
205206
checkAppBarChannelTopic(
206207
channel.name, eg.defaultRealmEmptyTopicDisplayName);
207208
}, skip: true); // null topic names soon to be enabled
@@ -951,7 +952,8 @@ void main() {
951952
testWidgets('show general chat for empty topics with channel name', (tester) async {
952953
await setupMessageListPage(tester,
953954
narrow: const CombinedFeedNarrow(),
954-
messages: [messageEmptyTopic], subscriptions: [eg.subscription(stream)]);
955+
messages: [messageEmptyTopic], subscriptions: [eg.subscription(stream)],
956+
zulipFeatureLevel: 334);
955957
await tester.pump();
956958
check(findInMessageList('stream name')).single;
957959
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single;
@@ -960,7 +962,8 @@ void main() {
960962
testWidgets('show general chat for empty topics without channel name', (tester) async {
961963
await setupMessageListPage(tester,
962964
narrow: TopicNarrow.ofMessage(messageEmptyTopic),
963-
messages: [messageEmptyTopic]);
965+
messages: [messageEmptyTopic],
966+
zulipFeatureLevel: 334);
964967
await tester.pump();
965968
check(findInMessageList('stream name')).isEmpty();
966969
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single;

0 commit comments

Comments
 (0)