Skip to content

Commit c279530

Browse files
committed
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 d4be4d7 commit c279530

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
});
@@ -342,16 +342,16 @@ void main() {
342342
group('events', () {
343343
test('add with new stream', () async {
344344
final store = eg.store();
345-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
345+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
346346
compareTopicVisibility(store, [
347347
eg.userTopicItem(stream1, 'topic', UserTopicVisibilityPolicy.muted),
348348
]);
349349
});
350350

351351
test('add in existing stream', () async {
352352
final store = eg.store();
353-
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
354-
await store.addUserTopic(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted);
353+
await store.setUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
354+
await store.setUserTopic(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted);
355355
compareTopicVisibility(store, [
356356
eg.userTopicItem(stream1, 'topic', UserTopicVisibilityPolicy.muted),
357357
eg.userTopicItem(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted),
@@ -360,35 +360,35 @@ void main() {
360360

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

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

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

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

test/model/message_list_test.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ void main() {
353353
final stream = eg.stream();
354354
final otherStream = eg.stream();
355355
await prepare(narrow: ChannelNarrow(stream.streamId));
356-
await store.addUserTopic(stream, 'muted', UserTopicVisibilityPolicy.muted);
356+
await store.setUserTopic(stream, 'muted', UserTopicVisibilityPolicy.muted);
357357
await prepareOutboxMessagesTo([
358358
StreamDestination(stream.streamId, eg.t('topic')),
359359
StreamDestination(stream.streamId, eg.t('muted')),
@@ -1118,7 +1118,7 @@ void main() {
11181118
eg.streamMessage(id: 2, stream: stream, topic: topic),
11191119
];
11201120
await prepareMessages(foundOldest: true, messages: messages);
1121-
await store.addUserTopic(stream, 'muted', UserTopicVisibilityPolicy.muted);
1121+
await store.setUserTopic(stream, 'muted', UserTopicVisibilityPolicy.muted);
11221122
await prepareOutboxMessagesTo([
11231123
StreamDestination(stream.streamId, eg.t(topic)),
11241124
StreamDestination(stream.streamId, eg.t('muted')),
@@ -2068,9 +2068,9 @@ void main() {
20682068
await prepare(narrow: const CombinedFeedNarrow());
20692069
await store.addStreams([stream1, stream2]);
20702070
await store.addSubscription(eg.subscription(stream1));
2071-
await store.addUserTopic(stream1, 'B', UserTopicVisibilityPolicy.muted);
2071+
await store.setUserTopic(stream1, 'B', UserTopicVisibilityPolicy.muted);
20722072
await store.addSubscription(eg.subscription(stream2, isMuted: true));
2073-
await store.addUserTopic(stream2, 'C', UserTopicVisibilityPolicy.unmuted);
2073+
await store.setUserTopic(stream2, 'C', UserTopicVisibilityPolicy.unmuted);
20742074

20752075
// Check filtering on fetchInitial…
20762076
await prepareMessages(foundOldest: false, messages: [
@@ -2128,8 +2128,8 @@ void main() {
21282128
await prepare(narrow: ChannelNarrow(stream.streamId));
21292129
await store.addStream(stream);
21302130
await store.addSubscription(eg.subscription(stream, isMuted: true));
2131-
await store.addUserTopic(stream, 'A', UserTopicVisibilityPolicy.unmuted);
2132-
await store.addUserTopic(stream, 'C', UserTopicVisibilityPolicy.muted);
2131+
await store.setUserTopic(stream, 'A', UserTopicVisibilityPolicy.unmuted);
2132+
await store.setUserTopic(stream, 'C', UserTopicVisibilityPolicy.muted);
21332133

21342134
// Check filtering on fetchInitial…
21352135
await prepareMessages(foundOldest: false, messages: [
@@ -2173,7 +2173,7 @@ void main() {
21732173
await prepare(narrow: ChannelNarrow(stream.streamId));
21742174
await store.addStream(stream);
21752175
await store.addSubscription(eg.subscription(stream));
2176-
await store.addUserTopic(stream, 'muted', UserTopicVisibilityPolicy.muted);
2176+
await store.setUserTopic(stream, 'muted', UserTopicVisibilityPolicy.muted);
21772177
await prepareMessages(foundOldest: true, messages: []);
21782178

21792179
// Check filtering on sent messages…
@@ -2206,7 +2206,7 @@ void main() {
22062206
await prepare(narrow: eg.topicNarrow(stream.streamId, 'A'));
22072207
await store.addStream(stream);
22082208
await store.addSubscription(eg.subscription(stream, isMuted: true));
2209-
await store.addUserTopic(stream, 'A', UserTopicVisibilityPolicy.muted);
2209+
await store.setUserTopic(stream, 'A', UserTopicVisibilityPolicy.muted);
22102210

22112211
// Check filtering on fetchInitial…
22122212
await prepareMessages(foundOldest: false, messages: [
@@ -2236,7 +2236,7 @@ void main() {
22362236
const mutedTopic = 'muted';
22372237
await prepare(narrow: const MentionsNarrow());
22382238
await store.addStream(stream);
2239-
await store.addUserTopic(stream, mutedTopic, UserTopicVisibilityPolicy.muted);
2239+
await store.setUserTopic(stream, mutedTopic, UserTopicVisibilityPolicy.muted);
22402240
await store.addSubscription(eg.subscription(stream, isMuted: true));
22412241

22422242
List<Message> getMessages(int startingId) => [
@@ -2274,7 +2274,7 @@ void main() {
22742274
const mutedTopic = 'muted';
22752275
await prepare(narrow: const StarredMessagesNarrow());
22762276
await store.addStream(stream);
2277-
await store.addUserTopic(stream, mutedTopic, UserTopicVisibilityPolicy.muted);
2277+
await store.setUserTopic(stream, mutedTopic, UserTopicVisibilityPolicy.muted);
22782278
await store.addSubscription(eg.subscription(stream, isMuted: true));
22792279

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

test/model/test_store.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ extension PerAccountStoreTestExtension on PerAccountStore {
283283
await handleEvent(SubscriptionAddEvent(id: 1, subscriptions: subscriptions));
284284
}
285285

286-
Future<void> addUserTopic(ZulipStream stream, String topic, UserTopicVisibilityPolicy visibilityPolicy) async {
286+
Future<void> setUserTopic(ZulipStream stream, String topic, UserTopicVisibilityPolicy visibilityPolicy) async {
287287
await handleEvent(eg.userTopicEvent(stream.streamId, topic, visibilityPolicy));
288288
}
289289

test/model/unreads_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void main() {
188188
await store.addSubscription(eg.subscription(stream1));
189189
await store.addSubscription(eg.subscription(stream2));
190190
await store.addSubscription(eg.subscription(stream3, isMuted: true));
191-
await store.addUserTopic(stream1, 'a', UserTopicVisibilityPolicy.muted);
191+
await store.setUserTopic(stream1, 'a', UserTopicVisibilityPolicy.muted);
192192
fillWithMessages([
193193
eg.streamMessage(stream: stream1, topic: 'a', flags: []),
194194
eg.streamMessage(stream: stream1, topic: 'b', flags: []),
@@ -206,8 +206,8 @@ void main() {
206206
prepare();
207207
await store.addStream(stream);
208208
await store.addSubscription(eg.subscription(stream));
209-
await store.addUserTopic(stream, 'a', UserTopicVisibilityPolicy.unmuted);
210-
await store.addUserTopic(stream, 'c', UserTopicVisibilityPolicy.muted);
209+
await store.setUserTopic(stream, 'a', UserTopicVisibilityPolicy.unmuted);
210+
await store.setUserTopic(stream, 'c', UserTopicVisibilityPolicy.muted);
211211
fillWithMessages([
212212
eg.streamMessage(stream: stream, topic: 'a', flags: []),
213213
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)