@@ -1411,31 +1411,54 @@ void main() {
1411
1411
void checkComposeBox ({required bool isShown}) => checkComposeBoxIsShown (isShown,
1412
1412
bannerLabel: zulipLocalizations.errorBannerCannotPostInChannelLabel);
1413
1413
1414
- final narrowTestCases = [
1415
- ('channel' , const ChannelNarrow (1 )),
1416
- ('topic' , eg.topicNarrow (1 , 'topic' )),
1417
- ];
1418
-
1419
- for (final (String narrowType, Narrow narrow) in narrowTestCases) {
1420
- testWidgets ('compose box is shown in $narrowType narrow' , (tester) async {
1414
+ const channelNarrow = ChannelNarrow (1 );
1415
+ final topicNarrow = eg.topicNarrow (1 , 'topic' );
1416
+
1417
+ void doTestComposeBoxShown ({
1418
+ required Narrow narrow,
1419
+ required ChannelPostPolicy channelPostPolicy,
1420
+ required UserRole selfUserRole,
1421
+ required bool expected,
1422
+ }) {
1423
+ final description = [
1424
+ narrow.toString (),
1425
+ 'channelPostPolicy: ${channelPostPolicy .name }' ,
1426
+ 'self-user role: ${selfUserRole .name }' ,
1427
+ ].join (', ' );
1428
+ testWidgets (description, (tester) async {
1421
1429
await prepareComposeBox (tester,
1422
1430
narrow: narrow,
1423
- selfUser: eg.user (role: UserRole .administrator ),
1431
+ selfUser: eg.user (role: selfUserRole ),
1424
1432
subscriptions: [eg.subscription (eg.stream (streamId: 1 ,
1425
- channelPostPolicy: ChannelPostPolicy .moderators))]);
1426
- checkComposeBox (isShown: true );
1427
- });
1428
-
1429
- testWidgets ('error banner is shown in $narrowType narrow' , (tester) async {
1430
- await prepareComposeBox (tester,
1431
- narrow: narrow,
1432
- selfUser: eg.user (role: UserRole .moderator),
1433
- subscriptions: [eg.subscription (eg.stream (streamId: 1 ,
1434
- channelPostPolicy: ChannelPostPolicy .administrators))]);
1435
- checkComposeBox (isShown: false );
1433
+ channelPostPolicy: channelPostPolicy))]);
1434
+ checkComposeBox (isShown: expected);
1436
1435
});
1437
1436
}
1438
1437
1438
+ doTestComposeBoxShown (
1439
+ narrow: channelNarrow,
1440
+ channelPostPolicy: ChannelPostPolicy .moderators,
1441
+ selfUserRole: UserRole .administrator,
1442
+ expected: true );
1443
+
1444
+ doTestComposeBoxShown (
1445
+ narrow: topicNarrow,
1446
+ channelPostPolicy: ChannelPostPolicy .moderators,
1447
+ selfUserRole: UserRole .administrator,
1448
+ expected: true );
1449
+
1450
+ doTestComposeBoxShown (
1451
+ narrow: channelNarrow,
1452
+ channelPostPolicy: ChannelPostPolicy .administrators,
1453
+ selfUserRole: UserRole .moderator,
1454
+ expected: false );
1455
+
1456
+ doTestComposeBoxShown (
1457
+ narrow: topicNarrow,
1458
+ channelPostPolicy: ChannelPostPolicy .administrators,
1459
+ selfUserRole: UserRole .moderator,
1460
+ expected: false );
1461
+
1439
1462
testWidgets ('user loses privilege -> compose box is replaced with the banner' , (tester) async {
1440
1463
final selfUser = eg.user (role: UserRole .administrator);
1441
1464
await prepareComposeBox (tester,
0 commit comments