@@ -4,6 +4,7 @@ import 'package:flutter_checks/flutter_checks.dart';
4
4
import 'package:flutter_test/flutter_test.dart' ;
5
5
import 'package:zulip/api/model/events.dart' ;
6
6
import 'package:zulip/api/model/model.dart' ;
7
+ import 'package:zulip/model/localizations.dart' ;
7
8
import 'package:zulip/model/store.dart' ;
8
9
import 'package:zulip/widgets/color.dart' ;
9
10
import 'package:zulip/widgets/home.dart' ;
@@ -133,7 +134,14 @@ void main() {
133
134
134
135
/// Find the all-DMs header element.
135
136
Widget ? findAllDmsHeaderRow (WidgetTester tester) {
136
- return findRowByLabel (tester, 'Direct messages' );
137
+ final finder = find.ancestor (
138
+ of: find.byWidgetPredicate ((widget) =>
139
+ widget is RichText &&
140
+ widget.text.toPlainText ().contains ('Direct messages' )
141
+ ),
142
+ matching: find.byType (Row ),
143
+ );
144
+ return finder.evaluate ().isNotEmpty ? tester.widget (finder.first) : null ;
137
145
}
138
146
139
147
Color ? allDmsHeaderBackgroundColor (WidgetTester tester) {
@@ -149,7 +157,15 @@ void main() {
149
157
/// For the given stream ID, find the stream header element.
150
158
Widget ? findStreamHeaderRow (WidgetTester tester, int streamId) {
151
159
final stream = store.streams[streamId]! ;
152
- return findRowByLabel (tester, stream.name);
160
+ return tester.widget <Row >(
161
+ find.ancestor (
162
+ of: find.byWidgetPredicate ((widget) =>
163
+ widget is RichText &&
164
+ widget.text.toPlainText ().contains (stream.name)
165
+ ),
166
+ matching: find.byType (Row ),
167
+ ).first
168
+ );
153
169
}
154
170
155
171
Color ? streamHeaderBackgroundColor (WidgetTester tester, int streamId) {
@@ -259,8 +275,13 @@ void main() {
259
275
final subscription = eg.subscription (stream);
260
276
const topic = 'lunch' ;
261
277
262
- bool hasAtSign (WidgetTester tester, Widget ? parent) =>
263
- hasIcon (tester, parent: parent, icon: ZulipIcons .at_sign);
278
+ bool hasAtSign (WidgetTester tester, {required Widget ? parent}) {
279
+ if (parent == null ) return false ;
280
+ return tester.widgetList (find.descendant (
281
+ of: find.byWidget (parent),
282
+ matching: find.byIcon (ZulipIcons .at_sign),
283
+ )).isNotEmpty;
284
+ }
264
285
265
286
testWidgets ('topic with a mention' , (tester) async {
266
287
await setupPage (tester,
@@ -269,9 +290,9 @@ void main() {
269
290
unreadMessages: [eg.streamMessage (stream: stream, topic: topic,
270
291
flags: [MessageFlag .mentioned])]);
271
292
272
- check (hasAtSign (tester, findStreamHeaderRow (tester, stream.streamId)))
293
+ check (hasAtSign (tester, parent : findStreamHeaderRow (tester, stream.streamId)))
273
294
.isTrue ();
274
- check (hasAtSign (tester, findRowByLabel (tester, topic))).isTrue ();
295
+ check (hasAtSign (tester, parent : findRowByLabel (tester, topic))).isTrue ();
275
296
});
276
297
277
298
testWidgets ('topic without a mention' , (tester) async {
@@ -281,9 +302,9 @@ void main() {
281
302
unreadMessages: [eg.streamMessage (stream: stream, topic: topic,
282
303
flags: [])]);
283
304
284
- check (hasAtSign (tester, findStreamHeaderRow (tester, stream.streamId)))
305
+ check (hasAtSign (tester, parent : findStreamHeaderRow (tester, stream.streamId)))
285
306
.isFalse ();
286
- check (hasAtSign (tester, findRowByLabel (tester, topic))).isFalse ();
307
+ check (hasAtSign (tester, parent : findRowByLabel (tester, topic))).isFalse ();
287
308
});
288
309
289
310
testWidgets ('dm with a mention' , (tester) async {
@@ -292,8 +313,8 @@ void main() {
292
313
unreadMessages: [eg.dmMessage (from: eg.otherUser, to: [eg.selfUser],
293
314
flags: [MessageFlag .mentioned])]);
294
315
295
- check (hasAtSign (tester, findAllDmsHeaderRow (tester))).isTrue ();
296
- check (hasAtSign (tester, findRowByLabel (tester, eg.otherUser.fullName))).isTrue ();
316
+ check (hasAtSign (tester, parent : findAllDmsHeaderRow (tester))).isTrue ();
317
+ check (hasAtSign (tester, parent : findRowByLabel (tester, eg.otherUser.fullName))).isTrue ();
297
318
});
298
319
299
320
testWidgets ('dm without mention' , (tester) async {
@@ -302,8 +323,8 @@ void main() {
302
323
unreadMessages: [eg.dmMessage (from: eg.otherUser, to: [eg.selfUser],
303
324
flags: [])]);
304
325
305
- check (hasAtSign (tester, findAllDmsHeaderRow (tester))).isFalse ();
306
- check (hasAtSign (tester, findRowByLabel (tester, eg.otherUser.fullName))).isFalse ();
326
+ check (hasAtSign (tester, parent : findAllDmsHeaderRow (tester))).isFalse ();
327
+ check (hasAtSign (tester, parent : findRowByLabel (tester, eg.otherUser.fullName))).isFalse ();
307
328
});
308
329
});
309
330
@@ -595,6 +616,36 @@ void main() {
595
616
check (rectAfterTap).equals (rectBeforeTap);
596
617
});
597
618
619
+ testWidgets ('shows archived label for archived streams' , (tester) async {
620
+ final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
621
+ final stream = eg.stream (streamId: 1 , isArchived: true );
622
+ final subscription = eg.subscription (stream);
623
+
624
+ await setupPage (tester,
625
+ streams: [stream],
626
+ subscriptions: [subscription],
627
+ unreadMessages: [eg.streamMessage (stream: stream)]);
628
+ await tester.pumpAndSettle ();
629
+
630
+ final headerRowFinder = findStreamHeaderRow (tester, stream.streamId);
631
+ check (headerRowFinder).isNotNull ();
632
+
633
+ final richTextFinder = find.descendant (
634
+ of: find.byWidget (headerRowFinder! ),
635
+ matching: find.byWidgetPredicate ((widget) =>
636
+ widget is RichText &&
637
+ widget.text.toPlainText ().contains (stream.name) &&
638
+ widget.text.toPlainText ().contains (zulipLocalizations.channelArchivedLabel)
639
+ ),
640
+ );
641
+ expect (richTextFinder, findsOneWidget);
642
+
643
+ final richText = tester.widget <RichText >(richTextFinder);
644
+ final textSpan = richText.text as TextSpan ;
645
+ final archivedSpan = textSpan.children! [1 ] as TextSpan ;
646
+ expect (archivedSpan.style? .fontStyle, FontStyle .italic);
647
+ });
648
+
598
649
// TODO check it remains collapsed even if you scroll far away and back
599
650
600
651
// TODO check that it's always uncollapsed when it appears after being
0 commit comments