@@ -184,6 +184,36 @@ void main() {
184
184
testExpectedNarrows (testCases, streams: streams);
185
185
});
186
186
187
+ group ('topic link parsing' , () {
188
+ final stream = eg.stream (name: "general" );
189
+
190
+ group ('basic' , () {
191
+ String mkUrlString (String operand) {
192
+ return '#narrow/stream/${stream .streamId }-${stream .name }/topic/$operand ' ;
193
+ }
194
+ final testCases = [
195
+ (mkUrlString ('(no.20topic)' ), TopicNarrow (stream.streamId, '(no topic)' )),
196
+ (mkUrlString ('lunch' ), TopicNarrow (stream.streamId, 'lunch' )),
197
+ ];
198
+ testExpectedNarrows (testCases, streams: [stream]);
199
+ });
200
+
201
+ group ('on old topic link, with dot-encoding' , () {
202
+ String mkUrlString (String operand) {
203
+ return '#narrow/stream/${stream .name }/topic/$operand ' ;
204
+ }
205
+ final testCases = [
206
+ (mkUrlString ('(no.20topic)' ), TopicNarrow (stream.streamId, '(no topic)' )),
207
+ (mkUrlString ('google.2Ecom' ), TopicNarrow (stream.streamId, 'google.com' )),
208
+ (mkUrlString ('google.com' ), null ),
209
+ (mkUrlString ('topic.20name' ), TopicNarrow (stream.streamId, 'topic name' )),
210
+ (mkUrlString ('stream' ), TopicNarrow (stream.streamId, 'stream' )),
211
+ (mkUrlString ('topic' ), TopicNarrow (stream.streamId, 'topic' )),
212
+ ];
213
+ testExpectedNarrows (testCases, streams: [stream]);
214
+ });
215
+ });
216
+
187
217
group ('Both `stream` and `channel` can be used interchangeably' , () {
188
218
const testCases = [
189
219
('/#narrow/stream/check' , ChannelNarrow (1 )),
@@ -203,6 +233,10 @@ void main() {
203
233
('/#narrow/dm/1,2-group' , expectedNarrow),
204
234
('/#narrow/dm/1,2-group/near/1' , expectedNarrow),
205
235
('/#narrow/dm/1,2-group/with/2' , expectedNarrow),
236
+
237
+ // The webapp doesn't generate this, but best to handle it anyway.
238
+ ('#narrow/dm/1,2,${eg .selfUser .userId }-group' , expectedNarrow),
239
+
206
240
('/#narrow/dm/a.40b.2Ecom.2Ec.2Ed.2Ecom/near/3' , null ),
207
241
('/#narrow/dm/a.40b.2Ecom.2Ec.2Ed.2Ecom/with/4' , null ),
208
242
];
@@ -216,6 +250,10 @@ void main() {
216
250
('/#narrow/pm-with/1,2-group' , expectedNarrow),
217
251
('/#narrow/pm-with/1,2-group/near/1' , expectedNarrow),
218
252
('/#narrow/pm-with/1,2-group/with/2' , expectedNarrow),
253
+
254
+ // The webapp doesn't generate this, but best to handle it anyway.
255
+ ('#narrow/pm-with/1,2,${eg .selfUser .userId }-group' , expectedNarrow),
256
+
219
257
('/#narrow/pm-with/a.40b.2Ecom.2Ec.2Ed.2Ecom/near/3' , null ),
220
258
('/#narrow/pm-with/a.40b.2Ecom.2Ec.2Ed.2Ecom/with/3' , null ),
221
259
];
@@ -397,58 +435,4 @@ void main() {
397
435
testExpectedNarrows (testCases, streams: streams);
398
436
});
399
437
});
400
-
401
- group ('parseInternalLink' , () {
402
- group ('topic link parsing' , () {
403
- final stream = eg.stream (name: "general" );
404
-
405
- group ('basic' , () {
406
- String mkUrlString (String operand) {
407
- return '#narrow/stream/${stream .streamId }-${stream .name }/topic/$operand ' ;
408
- }
409
- final testCases = [
410
- (mkUrlString ('(no.20topic)' ), TopicNarrow (stream.streamId, '(no topic)' )),
411
- (mkUrlString ('lunch' ), TopicNarrow (stream.streamId, 'lunch' )),
412
- ];
413
- testExpectedNarrows (testCases, streams: [stream]);
414
- });
415
-
416
- group ('on old topic link, with dot-encoding' , () {
417
- String mkUrlString (String operand) {
418
- return '#narrow/stream/${stream .name }/topic/$operand ' ;
419
- }
420
- final testCases = [
421
- (mkUrlString ('(no.20topic)' ), TopicNarrow (stream.streamId, '(no topic)' )),
422
- (mkUrlString ('google.2Ecom' ), TopicNarrow (stream.streamId, 'google.com' )),
423
- (mkUrlString ('google.com' ), null ),
424
- (mkUrlString ('topic.20name' ), TopicNarrow (stream.streamId, 'topic name' )),
425
- (mkUrlString ('stream' ), TopicNarrow (stream.streamId, 'stream' )),
426
- (mkUrlString ('topic' ), TopicNarrow (stream.streamId, 'topic' )),
427
- ];
428
- testExpectedNarrows (testCases, streams: [stream]);
429
- });
430
- });
431
-
432
- group ('DM link parsing' , () {
433
- void testExpectedDmNarrow (String testCase) {
434
- final expectedNarrow = DmNarrow .withUsers ([1 , 2 ],
435
- selfUserId: eg.selfUser.userId);
436
- testExpectedNarrows ([(testCase, expectedNarrow)], users: [
437
- eg.user (userId: 1 ),
438
- eg.user (userId: 2 ),
439
- ]);
440
- }
441
-
442
- group ('on group PM link' , () {
443
- testExpectedDmNarrow ('#narrow/dm/1,2-group' );
444
- testExpectedDmNarrow ('#narrow/pm-with/1,2-group' );
445
- });
446
-
447
- group ('on group PM link including self' , () {
448
- // The webapp doesn't generate these, but best to handle them anyway.
449
- testExpectedDmNarrow ('#narrow/dm/1,2,${eg .selfUser .userId }-group' );
450
- testExpectedDmNarrow ('#narrow/pm-with/1,2,${eg .selfUser .userId }-group' );
451
- });
452
- });
453
- });
454
438
}
0 commit comments