Skip to content

Commit 4d26607

Browse files
test: added tests for pressedTint feature
Tests are added for the `pressedTint` feature in the `MessageWithPossibleSender` widget. The tests are for checking the color of the `MessageWithPossibleSender` initially (transparent), after long press (pressedTint) and lastly after closing the `showMessageActionSheet`.
1 parent b21687c commit 4d26607

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

test/widgets/message_list_test.dart

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import 'package:zulip/widgets/message_list.dart';
2424
import 'package:zulip/widgets/page.dart';
2525
import 'package:zulip/widgets/store.dart';
2626
import 'package:zulip/widgets/channel_colors.dart';
27+
import 'package:zulip/widgets/theme.dart';
2728

2829
import '../api/fake_api.dart';
2930
import '../example_data.dart' as eg;
@@ -1095,6 +1096,79 @@ void main() {
10951096

10961097
debugNetworkImageHttpClientProvider = null;
10971098
});
1099+
1100+
1101+
group('action sheet visual feedback', () {
1102+
late Message message;
1103+
1104+
setUp(() {
1105+
// Create a basic message for testing
1106+
message = eg.streamMessage();
1107+
});
1108+
1109+
// Helper function to find DecoratedBox and get its color
1110+
Color? getBackgroundColor(WidgetTester tester) {
1111+
final decoratedBox = tester.widget<DecoratedBox>(
1112+
find.descendant(
1113+
of: find.byType(MessageWithPossibleSender),
1114+
matching: find.byType(DecoratedBox),
1115+
),
1116+
);
1117+
return (decoratedBox.decoration as BoxDecoration).color;
1118+
}
1119+
1120+
Future<void> buildTestWidget(WidgetTester tester) async {
1121+
await setupMessageListPage(
1122+
tester,
1123+
messages: [message],
1124+
);
1125+
}
1126+
1127+
testWidgets('starts with transparent background', (tester) async {
1128+
await buildTestWidget(tester);
1129+
1130+
expect(
1131+
getBackgroundColor(tester),
1132+
equals(Colors.transparent),
1133+
reason: 'Message should start with transparent background',
1134+
);
1135+
});
1136+
1137+
testWidgets('shows tint color when long pressed', (tester) async {
1138+
await buildTestWidget(tester);
1139+
1140+
// Trigger long press
1141+
await tester.longPress(find.byType(MessageWithPossibleSender));
1142+
await tester.pump();
1143+
1144+
final expectedTint = DesignVariables.of(tester.element(find.byType(MessageWithPossibleSender)))
1145+
.pressedTint;
1146+
1147+
expect(
1148+
getBackgroundColor(tester),
1149+
equals(expectedTint),
1150+
reason: 'Message should show tint color during long press',
1151+
);
1152+
});
1153+
1154+
testWidgets('returns to transparent after action sheet dismissal', (tester) async {
1155+
await buildTestWidget(tester);
1156+
1157+
// Open action sheet
1158+
await tester.longPress(find.byType(MessageWithPossibleSender));
1159+
await tester.pump();
1160+
1161+
// Simulate action sheet dismissal by tapping outside
1162+
await tester.tapAt(const Offset(0, 0));
1163+
await tester.pumpAndSettle();
1164+
1165+
expect(
1166+
getBackgroundColor(tester),
1167+
equals(Colors.transparent),
1168+
reason: 'Message should return to transparent after dismissal',
1169+
);
1170+
});
1171+
});
10981172
});
10991173

11001174
group('Starred messages', () {

0 commit comments

Comments
 (0)