@@ -9,9 +9,12 @@ import 'package:zulip/model/channel.dart';
9
9
import '../api/model/model_checks.dart' ;
10
10
import '../example_data.dart' as eg;
11
11
import '../stdlib_checks.dart' ;
12
+ import 'binding.dart' ;
12
13
import 'test_store.dart' ;
13
14
14
15
void main () {
16
+ TestZulipBinding .ensureInitialized ();
17
+
15
18
group ('Unified stream/sub data' , () {
16
19
/// Check that `streams` , `streamsByName` , and `subscriptions` all agree
17
20
/// and point to the same objects where applicable.
@@ -456,6 +459,32 @@ void main() {
456
459
});
457
460
458
461
group ('selfCanSendMessage' , () {
462
+ test ('in group' , () {
463
+ addTearDown (testBinding.reset);
464
+ final now = testBinding.utcNow ();
465
+
466
+ final canSendMessageGroup = eg.groupSetting (members: [eg.selfUser.userId]);
467
+ final channel = eg.stream (canSendMessageGroup: canSendMessageGroup);
468
+ final store = eg.store (
469
+ initialSnapshot: eg.initialSnapshot (streams: [channel]));
470
+ check (store.selfCanSendMessage (inChannel: channel, byDate: now))
471
+ .isTrue ();
472
+ });
473
+
474
+ test ('not in group' , () {
475
+ addTearDown (testBinding.reset);
476
+ final now = testBinding.utcNow ();
477
+
478
+ final canSendMessageGroup = eg.groupSetting (members: []);
479
+ final channel = eg.stream (canSendMessageGroup: canSendMessageGroup);
480
+ final store = eg.store (
481
+ initialSnapshot: eg.initialSnapshot (streams: [channel]));
482
+ check (store.selfCanSendMessage (inChannel: channel, byDate: now))
483
+ .isFalse ();
484
+ });
485
+ });
486
+
487
+ group ('selfCanSendMessage, legacy' , () {
459
488
final testCases = [
460
489
(ChannelPostPolicy .unknown, UserRole .unknown, true ),
461
490
(ChannelPostPolicy .unknown, UserRole .guest, true ),
0 commit comments