|
1 | 1 | import 'dart:async'; |
| 2 | +import 'dart:ui' show SemanticsAction; |
2 | 3 |
|
3 | 4 | import 'package:buzz/features/channels/channel.dart'; |
4 | 5 | import 'package:buzz/features/channels/channel_management_provider.dart'; |
@@ -194,20 +195,65 @@ void main() { |
194 | 195 | testWidgets('role updates block duplicates and show rejection', ( |
195 | 196 | tester, |
196 | 197 | ) async { |
197 | | - final actions = _Actions() |
198 | | - ..pending = Completer<void>() |
199 | | - ..fail = true; |
200 | | - await _pump(tester, actions: actions); |
201 | | - await tester.tap(find.text('Make channel admin')); |
202 | | - await tester.pump(); |
203 | | - await tester.tap(find.text('Make channel admin')); |
204 | | - expect(actions.calls, ['test:alice:admin']); |
205 | | - actions.pending!.complete(); |
206 | | - await tester.pumpAndSettle(); |
207 | | - expect( |
208 | | - find.text('Could not change this role. Please try again.'), |
209 | | - findsOneWidget, |
210 | | - ); |
| 198 | + final semantics = tester.ensureSemantics(); |
| 199 | + try { |
| 200 | + final actions = _Actions() |
| 201 | + ..pending = Completer<void>() |
| 202 | + ..fail = true; |
| 203 | + await _pump(tester, actions: actions); |
| 204 | + await tester.tap(find.text('Make channel admin')); |
| 205 | + await tester.pump(); |
| 206 | + final pending = find.bySemanticsLabel('Updating channel member'); |
| 207 | + expect(pending, findsOneWidget); |
| 208 | + expect( |
| 209 | + tester |
| 210 | + .getSemantics(pending) |
| 211 | + .getSemanticsData() |
| 212 | + .flagsCollection |
| 213 | + .isLiveRegion, |
| 214 | + isTrue, |
| 215 | + ); |
| 216 | + expect(find.bySemanticsLabel('Updating…'), findsNothing); |
| 217 | + for (final label in ['Make channel admin', 'Remove from channel']) { |
| 218 | + expect( |
| 219 | + tester |
| 220 | + .getSemantics(find.text(label)) |
| 221 | + .getSemanticsData() |
| 222 | + .hasAction(SemanticsAction.tap), |
| 223 | + isFalse, |
| 224 | + ); |
| 225 | + } |
| 226 | + await tester.tap(find.text('Make channel admin')); |
| 227 | + expect(actions.calls, ['test:alice:admin']); |
| 228 | + actions.pending!.complete(); |
| 229 | + await tester.pumpAndSettle(); |
| 230 | + expect( |
| 231 | + find.text('Could not change this role. Please try again.'), |
| 232 | + findsOneWidget, |
| 233 | + ); |
| 234 | + expect(pending, findsNothing); |
| 235 | + final error = find.bySemanticsLabel( |
| 236 | + 'Could not change this role. Please try again.', |
| 237 | + ); |
| 238 | + expect(error, findsOneWidget); |
| 239 | + expect( |
| 240 | + tester |
| 241 | + .getSemantics(error) |
| 242 | + .getSemanticsData() |
| 243 | + .flagsCollection |
| 244 | + .isLiveRegion, |
| 245 | + isTrue, |
| 246 | + ); |
| 247 | + expect( |
| 248 | + tester |
| 249 | + .getSemantics(find.text('Make channel admin')) |
| 250 | + .getSemanticsData() |
| 251 | + .hasAction(SemanticsAction.tap), |
| 252 | + isTrue, |
| 253 | + ); |
| 254 | + } finally { |
| 255 | + semantics.dispose(); |
| 256 | + } |
211 | 257 | }); |
212 | 258 | testWidgets('removal requires confirmation and reports rejection', ( |
213 | 259 | tester, |
|
0 commit comments