@@ -465,82 +465,6 @@ void main() {
465
465
});
466
466
});
467
467
468
- group ('PerAccountStore.hasPostingPermission' , () {
469
- final testCases = [
470
- (ChannelPostPolicy .unknown, UserRole .unknown, true ),
471
- (ChannelPostPolicy .unknown, UserRole .guest, true ),
472
- (ChannelPostPolicy .unknown, UserRole .member, true ),
473
- (ChannelPostPolicy .unknown, UserRole .moderator, true ),
474
- (ChannelPostPolicy .unknown, UserRole .administrator, true ),
475
- (ChannelPostPolicy .unknown, UserRole .owner, true ),
476
- (ChannelPostPolicy .any, UserRole .unknown, true ),
477
- (ChannelPostPolicy .any, UserRole .guest, true ),
478
- (ChannelPostPolicy .any, UserRole .member, true ),
479
- (ChannelPostPolicy .any, UserRole .moderator, true ),
480
- (ChannelPostPolicy .any, UserRole .administrator, true ),
481
- (ChannelPostPolicy .any, UserRole .owner, true ),
482
- (ChannelPostPolicy .fullMembers, UserRole .unknown, true ),
483
- (ChannelPostPolicy .fullMembers, UserRole .guest, false ),
484
- // The fullMembers/member case gets its own tests further below.
485
- // (ChannelPostPolicy.fullMembers, UserRole.member, /* complicated */),
486
- (ChannelPostPolicy .fullMembers, UserRole .moderator, true ),
487
- (ChannelPostPolicy .fullMembers, UserRole .administrator, true ),
488
- (ChannelPostPolicy .fullMembers, UserRole .owner, true ),
489
- (ChannelPostPolicy .moderators, UserRole .unknown, true ),
490
- (ChannelPostPolicy .moderators, UserRole .guest, false ),
491
- (ChannelPostPolicy .moderators, UserRole .member, false ),
492
- (ChannelPostPolicy .moderators, UserRole .moderator, true ),
493
- (ChannelPostPolicy .moderators, UserRole .administrator, true ),
494
- (ChannelPostPolicy .moderators, UserRole .owner, true ),
495
- (ChannelPostPolicy .administrators, UserRole .unknown, true ),
496
- (ChannelPostPolicy .administrators, UserRole .guest, false ),
497
- (ChannelPostPolicy .administrators, UserRole .member, false ),
498
- (ChannelPostPolicy .administrators, UserRole .moderator, false ),
499
- (ChannelPostPolicy .administrators, UserRole .administrator, true ),
500
- (ChannelPostPolicy .administrators, UserRole .owner, true ),
501
- ];
502
-
503
- for (final (ChannelPostPolicy policy, UserRole role, bool canPost) in testCases) {
504
- test ('"${role .name }" user ${canPost ? 'can' : "can't" } post in channel '
505
- 'with "${policy .name }" policy' , () {
506
- final store = eg.store ();
507
- final actual = store.hasPostingPermission (
508
- inChannel: eg.stream (channelPostPolicy: policy), user: eg.user (role: role),
509
- // [byDate] is not actually relevant for these test cases; for the
510
- // ones which it is, they're practiced below.
511
- byDate: DateTime .now ());
512
- check (actual).equals (canPost);
513
- });
514
- }
515
-
516
- group ('"member" user posting in a channel with "fullMembers" policy' , () {
517
- PerAccountStore localStore ({required int realmWaitingPeriodThreshold}) =>
518
- eg.store (initialSnapshot: eg.initialSnapshot (
519
- realmWaitingPeriodThreshold: realmWaitingPeriodThreshold));
520
-
521
- User memberUser ({required String dateJoined}) => eg.user (
522
- role: UserRole .member, dateJoined: dateJoined);
523
-
524
- test ('a "full" member -> can post in the channel' , () {
525
- final store = localStore (realmWaitingPeriodThreshold: 3 );
526
- final hasPermission = store.hasPostingPermission (
527
- inChannel: eg.stream (channelPostPolicy: ChannelPostPolicy .fullMembers),
528
- user: memberUser (dateJoined: '2024-11-25T10:00+00:00' ),
529
- byDate: DateTime .utc (2024 , 11 , 28 , 10 , 00 ));
530
- check (hasPermission).isTrue ();
531
- });
532
-
533
- test ('not a "full" member -> cannot post in the channel' , () {
534
- final store = localStore (realmWaitingPeriodThreshold: 3 );
535
- final actual = store.hasPostingPermission (
536
- inChannel: eg.stream (channelPostPolicy: ChannelPostPolicy .fullMembers),
537
- user: memberUser (dateJoined: '2024-11-25T10:00+00:00' ),
538
- byDate: DateTime .utc (2024 , 11 , 28 , 09 , 59 ));
539
- check (actual).isFalse ();
540
- });
541
- });
542
- });
543
-
544
468
group ('PerAccountStore.handleEvent' , () {
545
469
// Mostly this method just dispatches to ChannelStore and MessageStore etc.,
546
470
// and so its tests generally live in the test files for those
0 commit comments