Skip to content

Commit cf57281

Browse files
chrisbobbegnprice
authored andcommitted
test [nfc]: s/addUserTopic/setUserTopic/ in PerAccountStoreTestExtension
The event's doc says: https://zulip.com/api/get-events#user_topic > Event sent to a user's clients when the user mutes/unmutes a > topic, or otherwise modifies their personal per-topic > configuration. The new name is still accurate for "adding" a configuration (i.e. setting it to something not-"none"), but now also covers updating a configuration (moving between not-"none" configurations) and removing one (resetting to "none).
1 parent 7382bdf commit cf57281

File tree

6 files changed

+37
-37
lines changed

6 files changed

+37
-37
lines changed

test/model/channel_test.dart

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void main() {
148148

149149
test('with nothing for topic', () async {
150150
final store = eg.store();
151-
await store.addUserTopic(stream1, 'other topic', UserTopicVisibilityPolicy.muted);
151+
await store.setUserTopic(stream1, 'other topic', UserTopicVisibilityPolicy.muted);
152152
check(store.topicVisibilityPolicy(stream1.streamId, eg.t('topic')))
153153
.equals(UserTopicVisibilityPolicy.none);
154154
});
@@ -160,7 +160,7 @@ void main() {
160160
UserTopicVisibilityPolicy.unmuted,
161161
UserTopicVisibilityPolicy.followed,
162162
]) {
163-
await store.addUserTopic(stream1, 'topic', policy);
163+
await store.setUserTopic(stream1, 'topic', policy);
164164
check(store.topicVisibilityPolicy(stream1.streamId, eg.t('topic')))
165165
.equals(policy);
166166
}
@@ -195,7 +195,7 @@ void main() {
195195
final store = eg.store();
196196
await store.addStream(stream1);
197197
await store.addSubscription(eg.subscription(stream1));
198-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
198+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
199199
check(store.isTopicVisibleInStream(stream1.streamId, eg.t('topic'))).isFalse();
200200
check(store.isTopicVisible (stream1.streamId, eg.t('topic'))).isFalse();
201201
});
@@ -204,7 +204,7 @@ void main() {
204204
final store = eg.store();
205205
await store.addStream(stream1);
206206
await store.addSubscription(eg.subscription(stream1, isMuted: true));
207-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.unmuted);
207+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.unmuted);
208208
check(store.isTopicVisibleInStream(stream1.streamId, eg.t('topic'))).isTrue();
209209
check(store.isTopicVisible (stream1.streamId, eg.t('topic'))).isTrue();
210210
});
@@ -213,7 +213,7 @@ void main() {
213213
final store = eg.store();
214214
await store.addStream(stream1);
215215
await store.addSubscription(eg.subscription(stream1, isMuted: true));
216-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.followed);
216+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.followed);
217217
check(store.isTopicVisibleInStream(stream1.streamId, eg.t('topic'))).isTrue();
218218
check(store.isTopicVisible (stream1.streamId, eg.t('topic'))).isTrue();
219219
});
@@ -343,16 +343,16 @@ void main() {
343343
group('events', () {
344344
test('add with new stream', () async {
345345
final store = eg.store();
346-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
346+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
347347
compareTopicVisibility(store, [
348348
eg.userTopicItem(stream1, 'topic', UserTopicVisibilityPolicy.muted),
349349
]);
350350
});
351351

352352
test('add in existing stream', () async {
353353
final store = eg.store();
354-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
355-
await store.addUserTopic(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted);
354+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
355+
await store.setUserTopic(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted);
356356
compareTopicVisibility(store, [
357357
eg.userTopicItem(stream1, 'topic', UserTopicVisibilityPolicy.muted),
358358
eg.userTopicItem(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted),
@@ -361,35 +361,35 @@ void main() {
361361

362362
test('update existing policy', () async {
363363
final store = eg.store();
364-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
365-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.unmuted);
364+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
365+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.unmuted);
366366
compareTopicVisibility(store, [
367367
eg.userTopicItem(stream1, 'topic', UserTopicVisibilityPolicy.unmuted),
368368
]);
369369
});
370370

371371
test('remove, with others in stream', () async {
372372
final store = eg.store();
373-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
374-
await store.addUserTopic(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted);
375-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.none);
373+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
374+
await store.setUserTopic(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted);
375+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.none);
376376
compareTopicVisibility(store, [
377377
eg.userTopicItem(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted),
378378
]);
379379
});
380380

381381
test('remove, as last in stream', () async {
382382
final store = eg.store();
383-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
384-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.none);
383+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
384+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.none);
385385
compareTopicVisibility(store, [
386386
]);
387387
});
388388

389389
test('treat unknown enum value as removing', () async {
390390
final store = eg.store();
391-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
392-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.unknown);
391+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
392+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.unknown);
393393
compareTopicVisibility(store, [
394394
]);
395395
});

test/model/message_list_test.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ void main() {
359359
final stream = eg.stream();
360360
final otherStream = eg.stream();
361361
await prepare(narrow: ChannelNarrow(stream.streamId));
362-
await store.addUserTopic(stream, 'muted', UserTopicVisibilityPolicy.muted);
362+
await store.setUserTopic(stream, 'muted', UserTopicVisibilityPolicy.muted);
363363
await prepareOutboxMessagesTo([
364364
StreamDestination(stream.streamId, eg.t('topic')),
365365
StreamDestination(stream.streamId, eg.t('muted')),
@@ -1124,7 +1124,7 @@ void main() {
11241124
eg.streamMessage(id: 2, stream: stream, topic: topic),
11251125
];
11261126
await prepareMessages(foundOldest: true, messages: messages);
1127-
await store.addUserTopic(stream, 'muted', UserTopicVisibilityPolicy.muted);
1127+
await store.setUserTopic(stream, 'muted', UserTopicVisibilityPolicy.muted);
11281128
await prepareOutboxMessagesTo([
11291129
StreamDestination(stream.streamId, eg.t(topic)),
11301130
StreamDestination(stream.streamId, eg.t('muted')),
@@ -2218,9 +2218,9 @@ void main() {
22182218
await prepare(narrow: const CombinedFeedNarrow());
22192219
await store.addStreams([stream1, stream2]);
22202220
await store.addSubscription(eg.subscription(stream1));
2221-
await store.addUserTopic(stream1, 'B', UserTopicVisibilityPolicy.muted);
2221+
await store.setUserTopic(stream1, 'B', UserTopicVisibilityPolicy.muted);
22222222
await store.addSubscription(eg.subscription(stream2, isMuted: true));
2223-
await store.addUserTopic(stream2, 'C', UserTopicVisibilityPolicy.unmuted);
2223+
await store.setUserTopic(stream2, 'C', UserTopicVisibilityPolicy.unmuted);
22242224

22252225
// Check filtering on fetchInitial…
22262226
await prepareMessages(foundOldest: false, messages: [
@@ -2278,8 +2278,8 @@ void main() {
22782278
await prepare(narrow: ChannelNarrow(stream.streamId));
22792279
await store.addStream(stream);
22802280
await store.addSubscription(eg.subscription(stream, isMuted: true));
2281-
await store.addUserTopic(stream, 'A', UserTopicVisibilityPolicy.unmuted);
2282-
await store.addUserTopic(stream, 'C', UserTopicVisibilityPolicy.muted);
2281+
await store.setUserTopic(stream, 'A', UserTopicVisibilityPolicy.unmuted);
2282+
await store.setUserTopic(stream, 'C', UserTopicVisibilityPolicy.muted);
22832283

22842284
// Check filtering on fetchInitial…
22852285
await prepareMessages(foundOldest: false, messages: [
@@ -2323,7 +2323,7 @@ void main() {
23232323
await prepare(narrow: ChannelNarrow(stream.streamId));
23242324
await store.addStream(stream);
23252325
await store.addSubscription(eg.subscription(stream));
2326-
await store.addUserTopic(stream, 'muted', UserTopicVisibilityPolicy.muted);
2326+
await store.setUserTopic(stream, 'muted', UserTopicVisibilityPolicy.muted);
23272327
await prepareMessages(foundOldest: true, messages: []);
23282328

23292329
// Check filtering on sent messages…
@@ -2356,7 +2356,7 @@ void main() {
23562356
await prepare(narrow: eg.topicNarrow(stream.streamId, 'A'));
23572357
await store.addStream(stream);
23582358
await store.addSubscription(eg.subscription(stream, isMuted: true));
2359-
await store.addUserTopic(stream, 'A', UserTopicVisibilityPolicy.muted);
2359+
await store.setUserTopic(stream, 'A', UserTopicVisibilityPolicy.muted);
23602360

23612361
// Check filtering on fetchInitial…
23622362
await prepareMessages(foundOldest: false, messages: [
@@ -2386,7 +2386,7 @@ void main() {
23862386
const mutedTopic = 'muted';
23872387
await prepare(narrow: const MentionsNarrow());
23882388
await store.addStream(stream);
2389-
await store.addUserTopic(stream, mutedTopic, UserTopicVisibilityPolicy.muted);
2389+
await store.setUserTopic(stream, mutedTopic, UserTopicVisibilityPolicy.muted);
23902390
await store.addSubscription(eg.subscription(stream, isMuted: true));
23912391

23922392
List<Message> getMessages(int startingId) => [
@@ -2424,7 +2424,7 @@ void main() {
24242424
const mutedTopic = 'muted';
24252425
await prepare(narrow: const StarredMessagesNarrow());
24262426
await store.addStream(stream);
2427-
await store.addUserTopic(stream, mutedTopic, UserTopicVisibilityPolicy.muted);
2427+
await store.setUserTopic(stream, mutedTopic, UserTopicVisibilityPolicy.muted);
24282428
await store.addSubscription(eg.subscription(stream, isMuted: true));
24292429

24302430
List<Message> getMessages(int startingId) => [

test/model/test_store.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ extension PerAccountStoreTestExtension on PerAccountStore {
287287
await handleEvent(SubscriptionAddEvent(id: 1, subscriptions: subscriptions));
288288
}
289289

290-
Future<void> addUserTopic(ZulipStream stream, String topic, UserTopicVisibilityPolicy visibilityPolicy) async {
290+
Future<void> setUserTopic(ZulipStream stream, String topic, UserTopicVisibilityPolicy visibilityPolicy) async {
291291
await handleEvent(eg.userTopicEvent(stream.streamId, topic, visibilityPolicy));
292292
}
293293

test/model/unreads_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ void main() {
186186
await store.addSubscription(eg.subscription(stream1));
187187
await store.addSubscription(eg.subscription(stream2));
188188
await store.addSubscription(eg.subscription(stream3, isMuted: true));
189-
await store.addUserTopic(stream1, 'a', UserTopicVisibilityPolicy.muted);
189+
await store.setUserTopic(stream1, 'a', UserTopicVisibilityPolicy.muted);
190190
fillWithMessages([
191191
eg.streamMessage(stream: stream1, topic: 'a', flags: []),
192192
eg.streamMessage(stream: stream1, topic: 'b', flags: []),
@@ -204,8 +204,8 @@ void main() {
204204
prepare();
205205
await store.addStream(stream);
206206
await store.addSubscription(eg.subscription(stream));
207-
await store.addUserTopic(stream, 'a', UserTopicVisibilityPolicy.unmuted);
208-
await store.addUserTopic(stream, 'c', UserTopicVisibilityPolicy.muted);
207+
await store.setUserTopic(stream, 'a', UserTopicVisibilityPolicy.unmuted);
208+
await store.setUserTopic(stream, 'c', UserTopicVisibilityPolicy.muted);
209209
fillWithMessages([
210210
eg.streamMessage(stream: stream, topic: 'a', flags: []),
211211
eg.streamMessage(stream: stream, topic: 'A', flags: []),

test/widgets/inbox_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void main() {
227227
streams: [stream],
228228
subscriptions: [subscription],
229229
unreadMessages: [eg.streamMessage(stream: stream, topic: 'lunch')]);
230-
await store.addUserTopic(stream, 'lunch', UserTopicVisibilityPolicy.muted);
230+
await store.setUserTopic(stream, 'lunch', UserTopicVisibilityPolicy.muted);
231231
await tester.pump();
232232
check(tester.widgetList(find.text('lunch'))).length.equals(0);
233233
});
@@ -249,7 +249,7 @@ void main() {
249249
streams: [stream],
250250
subscriptions: [subscription],
251251
unreadMessages: [eg.streamMessage(stream: stream, topic: 'lunch')]);
252-
await store.addUserTopic(stream, 'lunch', UserTopicVisibilityPolicy.unmuted);
252+
await store.setUserTopic(stream, 'lunch', UserTopicVisibilityPolicy.unmuted);
253253
await tester.pump();
254254
check(tester.widgetList(find.text('lunch'))).length.equals(1);
255255
});
@@ -327,7 +327,7 @@ void main() {
327327
streams: [channel],
328328
subscriptions: [eg.subscription(channel)],
329329
unreadMessages: [message]);
330-
await store.addUserTopic(channel, topic, UserTopicVisibilityPolicy.followed);
330+
await store.setUserTopic(channel, topic, UserTopicVisibilityPolicy.followed);
331331
await tester.pump();
332332
check(hasIcon(tester,
333333
parent: findRowByLabel(tester, topic),
@@ -340,7 +340,7 @@ void main() {
340340
subscriptions: [eg.subscription(channel)],
341341
unreadMessages: [eg.streamMessage(stream: channel, topic: topic,
342342
flags: [MessageFlag.mentioned])]);
343-
await store.addUserTopic(channel, topic, UserTopicVisibilityPolicy.followed);
343+
await store.setUserTopic(channel, topic, UserTopicVisibilityPolicy.followed);
344344
await tester.pump();
345345
check(hasIcon(tester,
346346
parent: findRowByLabel(tester, topic),
@@ -356,7 +356,7 @@ void main() {
356356
streams: [channel],
357357
subscriptions: [eg.subscription(channel, isMuted: true)],
358358
unreadMessages: [message]);
359-
await store.addUserTopic(channel, topic, UserTopicVisibilityPolicy.unmuted);
359+
await store.setUserTopic(channel, topic, UserTopicVisibilityPolicy.unmuted);
360360
await tester.pump();
361361
check(hasIcon(tester,
362362
parent: findRowByLabel(tester, topic),

test/widgets/topic_list_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void main() {
4242
await store.addStream(channel);
4343
await store.addSubscription(eg.subscription(channel));
4444
for (final userTopic in userTopics) {
45-
await store.addUserTopic(
45+
await store.setUserTopic(
4646
channel, userTopic.topicName.apiName, userTopic.visibilityPolicy);
4747
}
4848
topics ??= [eg.getStreamTopicsEntry()];

0 commit comments

Comments
 (0)