@@ -493,9 +493,12 @@ void main() {
493493 for (final (ChannelPostPolicy policy, UserRole role, bool canPost) in testCases) {
494494 test ('"${role .name }" user ${canPost ? 'can' : "can't" } post in channel '
495495 'with "${policy .name }" policy' , () {
496- final store = eg.store ();
497- final actual = store.hasPostingPermission (
498- inChannel: eg.stream (channelPostPolicy: policy), user: eg.user (role: role),
496+ final selfUserWithRole = eg.user (role: role);
497+ final store = eg.store (
498+ selfUser: selfUserWithRole,
499+ initialSnapshot: eg.initialSnapshot (realmUsers: [selfUserWithRole]));
500+ final actual = store.selfCanSendMessage (
501+ inChannel: eg.stream (channelPostPolicy: policy),
499502 // [byDate] is not actually relevant for these test cases; for the
500503 // ones which it is, they're practiced below.
501504 byDate: DateTime .now ());
@@ -504,27 +507,34 @@ void main() {
504507 }
505508
506509 group ('"member" user posting in a channel with "fullMembers" policy' , () {
507- PerAccountStore localStore ({required int realmWaitingPeriodThreshold}) =>
508- eg.store (initialSnapshot: eg.initialSnapshot (
509- realmWaitingPeriodThreshold: realmWaitingPeriodThreshold));
510+ PerAccountStore localStore ({
511+ required User selfUser,
512+ required int realmWaitingPeriodThreshold,
513+ }) => eg.store (
514+ selfUser: selfUser,
515+ initialSnapshot: eg.initialSnapshot (
516+ realmWaitingPeriodThreshold: realmWaitingPeriodThreshold,
517+ realmUsers: [selfUser]));
510518
511519 User memberUser ({required String dateJoined}) => eg.user (
512520 role: UserRole .member, dateJoined: dateJoined);
513521
514522 test ('a "full" member -> can post in the channel' , () {
515- final store = localStore (realmWaitingPeriodThreshold: 3 );
516- final hasPermission = store.hasPostingPermission (
523+ final store = localStore (
524+ selfUser: memberUser (dateJoined: '2024-11-25T10:00+00:00' ),
525+ realmWaitingPeriodThreshold: 3 );
526+ final hasPermission = store.selfCanSendMessage (
517527 inChannel: eg.stream (channelPostPolicy: ChannelPostPolicy .fullMembers),
518- user: memberUser (dateJoined: '2024-11-25T10:00+00:00' ),
519528 byDate: DateTime .utc (2024 , 11 , 28 , 10 , 00 ));
520529 check (hasPermission).isTrue ();
521530 });
522531
523532 test ('not a "full" member -> cannot post in the channel' , () {
524- final store = localStore (realmWaitingPeriodThreshold: 3 );
525- final actual = store.hasPostingPermission (
533+ final store = localStore (
534+ selfUser: memberUser (dateJoined: '2024-11-25T10:00+00:00' ),
535+ realmWaitingPeriodThreshold: 3 );
536+ final actual = store.selfCanSendMessage (
526537 inChannel: eg.stream (channelPostPolicy: ChannelPostPolicy .fullMembers),
527- user: memberUser (dateJoined: '2024-11-25T10:00+00:00' ),
528538 byDate: DateTime .utc (2024 , 11 , 28 , 09 , 59 ));
529539 check (actual).isFalse ();
530540 });
0 commit comments