Skip to content

Commit 82733ca

Browse files
committed
message test: Switch to using eg.defaultStreamMessageStreamId, where boring
1 parent 65e0f67 commit 82733ca

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

test/model/message_test.dart

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ void main() {
151151
});
152152
});
153153

154-
final stream = eg.stream();
155-
final streamDestination = StreamDestination(stream.streamId, eg.t('some topic'));
154+
final streamDestination = StreamDestination(
155+
eg.defaultStreamMessageStreamId, eg.t('some topic'));
156156
late StreamMessage message;
157157

158158
test('outbox messages get unique localMessageId', () async {
159-
await prepare(stream: stream);
159+
await prepare();
160160
await prepareMessages([]);
161161

162162
for (int i = 0; i < 10; i++) {
@@ -175,19 +175,19 @@ void main() {
175175
MessageDestination? destination,
176176
int? zulipFeatureLevel,
177177
}) async {
178-
message = eg.streamMessage(stream: stream);
179-
await prepare(stream: stream, zulipFeatureLevel: zulipFeatureLevel);
180-
await prepareMessages([eg.streamMessage(stream: stream)]);
178+
message = eg.streamMessage();
179+
await prepare(zulipFeatureLevel: zulipFeatureLevel);
180+
await prepareMessages([eg.streamMessage()]);
181181
connection.prepare(json: SendMessageResult(id: 1).toJson());
182182
await store.sendMessage(
183183
destination: destination ?? streamDestination, content: 'content');
184184
}
185185

186186
late Future<void> outboxMessageFailFuture;
187187
Future<void> prepareOutboxMessageToFailAfterDelay(Duration delay) async {
188-
message = eg.streamMessage(stream: stream);
189-
await prepare(stream: stream);
190-
await prepareMessages([eg.streamMessage(stream: stream)]);
188+
message = eg.streamMessage();
189+
await prepare();
190+
await prepareMessages([eg.streamMessage()]);
191191
connection.prepare(httpException: SocketException('failed'), delay: delay);
192192
outboxMessageFailFuture = store.sendMessage(
193193
destination: streamDestination, content: 'content');
@@ -215,15 +215,15 @@ void main() {
215215

216216
test('smoke stream message: hidden -> waiting -> (delete)', () => awaitFakeAsync((async) async {
217217
await prepareOutboxMessage(destination: StreamDestination(
218-
stream.streamId, eg.t('foo')));
218+
eg.defaultStreamMessageStreamId, eg.t('foo')));
219219
checkState().equals(OutboxMessageState.hidden);
220220
checkNotNotified();
221221

222222
async.elapse(kLocalEchoDebounceDuration);
223223
checkState().equals(OutboxMessageState.waiting);
224224
checkNotifiedOnce();
225225

226-
await receiveMessage(eg.streamMessage(stream: stream, topic: 'foo'));
226+
await receiveMessage(eg.streamMessage(topic: 'foo'));
227227
check(store.outboxMessages).isEmpty();
228228
checkNotifiedOnce();
229229
}));
@@ -263,8 +263,8 @@ void main() {
263263
}));
264264

265265
test('waiting -> waitPeriodExpired -> waiting and never return to waitPeriodExpired', () => awaitFakeAsync((async) async {
266-
await prepare(stream: stream);
267-
await prepareMessages([eg.streamMessage(stream: stream)]);
266+
await prepare();
267+
await prepareMessages([eg.streamMessage()]);
268268
// Set up a [sendMessage] request that succeeds after enough delay,
269269
// for the outbox message to reach the waitPeriodExpired state.
270270
// TODO extract helper to add prepare an outbox message with a delayed
@@ -460,7 +460,8 @@ void main() {
460460

461461
test('when sending to "(no topic)", process topic like the server does when creating outbox message', () => awaitFakeAsync((async) async {
462462
await prepareOutboxMessage(
463-
destination: StreamDestination(stream.streamId, TopicName('(no topic)')),
463+
destination: StreamDestination(
464+
eg.defaultStreamMessageStreamId, TopicName('(no topic)')),
464465
zulipFeatureLevel: 370);
465466
async.elapse(kLocalEchoDebounceDuration);
466467
check(store.outboxMessages).values.single
@@ -469,7 +470,8 @@ void main() {
469470

470471
test('legacy: when sending to "(no topic)", process topic like the server does when creating outbox message', () => awaitFakeAsync((async) async {
471472
await prepareOutboxMessage(
472-
destination: StreamDestination(stream.streamId, TopicName('(no topic)')),
473+
destination: StreamDestination(
474+
eg.defaultStreamMessageStreamId, TopicName('(no topic)')),
473475
zulipFeatureLevel: 369);
474476
async.elapse(kLocalEchoDebounceDuration);
475477
check(store.outboxMessages).values.single
@@ -487,14 +489,14 @@ void main() {
487489
});
488490

489491
test('takeOutboxMessage', () async {
490-
final stream = eg.stream();
491-
await prepare(stream: stream);
492+
await prepare();
492493
await prepareMessages([]);
493494

494495
for (int i = 0; i < 10; i++) {
495496
connection.prepare(apiException: eg.apiBadRequest());
496497
await check(store.sendMessage(
497-
destination: StreamDestination(stream.streamId, eg.t('topic')),
498+
destination: StreamDestination(
499+
eg.defaultStreamMessageStreamId, eg.t('topic')),
498500
content: 'content')).throws();
499501
checkNotifiedOnce();
500502
}

0 commit comments

Comments
 (0)