|
2 | 2 | import 'package:checks/checks.dart';
|
3 | 3 | import 'package:test/scaffolding.dart';
|
4 | 4 | import 'package:zulip/api/model/model.dart';
|
| 5 | +import 'package:zulip/api/model/narrow.dart'; |
5 | 6 | import 'package:zulip/model/internal_link.dart';
|
6 | 7 | import 'package:zulip/model/narrow.dart';
|
7 | 8 | import 'package:zulip/model/store.dart';
|
@@ -221,25 +222,44 @@ void main() {
|
221 | 222 | testExpectedNarrows(testCases, streams: streams);
|
222 | 223 | });
|
223 | 224 |
|
224 |
| - group('"/#narrow/is/mentioned returns expected MentionsNarrow', () { |
225 |
| - final testCases = [ |
226 |
| - ('/#narrow/is/mentioned', const MentionsNarrow()), |
227 |
| - ('/#narrow/is/mentioned/near/1', const MentionsNarrow()), |
228 |
| - ('/#narrow/is/mentioned/with/2', const MentionsNarrow()), |
229 |
| - ('/#narrow/channel/7-test-here/is/mentioned', null), |
230 |
| - ('/#narrow/channel/check/topic/test/is/mentioned', null), |
231 |
| - ('/#narrow/topic/test/is/mentioned', null), |
232 |
| - ('/#narrow/dm/17327-Chris-Bobbe-(Test-Account)/is/mentioned', null), |
233 |
| - ('/#narrow/-is/mentioned', null), |
234 |
| - ]; |
235 |
| - testExpectedNarrows(testCases, streams: streams); |
| 225 | + group('/#narrow/is/<...> returns corresponding narrow', () { |
| 226 | + // For these tests, we are more interested in the internal links |
| 227 | + // containing a single effective `is` operator. |
| 228 | + // Internal links with multiple operators should be tested separately. |
| 229 | + for (final operand in IsOperand.values) { |
| 230 | + List<(String, Narrow?)> sharedCases(Narrow? narrow) => [ |
| 231 | + ('/#narrow/is/$operand', narrow), |
| 232 | + ('/#narrow/is/$operand/near/1', narrow), |
| 233 | + ('/#narrow/is/$operand/with/2', narrow), |
| 234 | + ('/#narrow/channel/7-test-here/is/$operand', null), |
| 235 | + ('/#narrow/channel/check/topic/test/is/$operand', null), |
| 236 | + ('/#narrow/topic/test/is/$operand', null), |
| 237 | + ('/#narrow/dm/17327-Chris-Bobbe-(Test-Account)/is/$operand', null), |
| 238 | + ('/#narrow/-is/$operand', null), |
| 239 | + ]; |
| 240 | + final List<(String, Narrow?)> testCases; |
| 241 | + switch (operand) { |
| 242 | + case IsOperand.mentioned: |
| 243 | + testCases = sharedCases(const MentionsNarrow()); |
| 244 | + case IsOperand.dm: |
| 245 | + case IsOperand.private: |
| 246 | + case IsOperand.alerted: |
| 247 | + case IsOperand.starred: |
| 248 | + case IsOperand.followed: |
| 249 | + case IsOperand.resolved: |
| 250 | + case IsOperand.unread: |
| 251 | + case IsOperand.unknown: |
| 252 | + // Unsupported operands should not return any narrow. |
| 253 | + testCases = sharedCases(null); |
| 254 | + } |
| 255 | + testExpectedNarrows(testCases, streams: streams); |
| 256 | + } |
236 | 257 | });
|
237 | 258 |
|
238 | 259 | group('unexpected link shapes are rejected', () {
|
239 | 260 | final testCases = [
|
240 | 261 | ('/#narrow/stream/name/topic/', null), // missing operand
|
241 | 262 | ('/#narrow/stream/name/unknown/operand/', null), // unknown operator
|
242 |
| - ('/#narrow/is/starred', null), // unknown `is` operand |
243 | 263 | ];
|
244 | 264 | testExpectedNarrows(testCases, streams: streams);
|
245 | 265 | });
|
|
0 commit comments