Skip to content

Commit 87c6854

Browse files
committed
fix(mobile): announce member management progress and errors
Signed-off-by: kenny lopez <[email protected]>
1 parent dd21d3d commit 87c6854

2 files changed

Lines changed: 78 additions & 19 deletions

File tree

‎mobile/lib/features/channels/channel_member_profile_actions.dart‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,25 @@ class ChannelMemberProfileActions extends HookConsumerWidget {
165165
),
166166
],
167167
),
168-
if (busy.value) const Center(child: Text('Updating…')),
168+
if (busy.value)
169+
Semantics(
170+
liveRegion: true,
171+
label: 'Updating channel member',
172+
child: const ExcludeSemantics(
173+
child: Center(child: Text('Updating…')),
174+
),
175+
),
169176
if (error.value != null)
170-
Text(
171-
error.value!,
172-
style: context.textTheme.bodyMedium?.copyWith(
173-
color: context.colors.error,
177+
Semantics(
178+
liveRegion: true,
179+
label: error.value!,
180+
child: ExcludeSemantics(
181+
child: Text(
182+
error.value!,
183+
style: context.textTheme.bodyMedium?.copyWith(
184+
color: context.colors.error,
185+
),
186+
),
174187
),
175188
),
176189
],

‎mobile/test/features/channels/channel_member_profile_actions_test.dart‎

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:async';
2+
import 'dart:ui' show SemanticsAction;
23

34
import 'package:buzz/features/channels/channel.dart';
45
import 'package:buzz/features/channels/channel_management_provider.dart';
@@ -194,20 +195,65 @@ void main() {
194195
testWidgets('role updates block duplicates and show rejection', (
195196
tester,
196197
) 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+
}
211257
});
212258
testWidgets('removal requires confirmation and reports rejection', (
213259
tester,

0 commit comments

Comments
 (0)