mirror of
https://github.com/block/buzz.git
synced 2026-10-31 14:31:02 +00:00
Follow-up to #8650. This addresses the items from the [second-pass review](https://github.com/block/buzz/pull/8650#pullrequestreview-5700660448), which arrived after #8650 merged. - **Setting menu semantics.** Options in the shared `BuzzSettingMenu` (model, reasoning effort, and channel TTL) expose their checked state again. The trigger is announced as a button with enabled and expanded state, so a disabled "Reasoning effort" no longer reads as plain text. The `PopupMenuButton` this menu replaced also provided a named route and a "Dismiss menu" action. `MenuAnchor` does not provide them, so this PR does not restore them. - **Remote listing failures.** "Could not load agents" for a failed Builderlab listing now appears only in communities that support remote agents. For example, it no longer appears in a non-hosted community while signed in. - **Add agent during a community reload.** No change needed here. #8693 already disables Add while the page has no community. ### Validation - Added tests: setting-menu checked, button, enabled and expanded semantics; a failed remote listing stays hidden where remote agents are off. Both fail without these changes. - Mobile analysis is clean, and the Agents and shared widget tests pass locally after rebasing onto #8693. - Not covered: VoiceOver on a device. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@sprout-oss.stage.blox.sqprod.co>
58 lines
2.1 KiB
Dart
58 lines
2.1 KiB
Dart
import 'dart:ui' show CheckedState, Tristate;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/rendering.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:buzz/shared/theme/theme.dart';
|
|
import 'package:buzz/shared/widgets/buzz_setting_menu.dart';
|
|
|
|
void main() {
|
|
Widget menu({required bool enabled}) => MaterialApp(
|
|
theme: AppTheme.light(),
|
|
home: Scaffold(
|
|
body: BuzzSettingMenu<String>(
|
|
controlKey: const Key('menu'),
|
|
enabled: enabled,
|
|
label: 'Effort',
|
|
onSelected: (_) {},
|
|
options: const [
|
|
BuzzSettingMenuOption(key: Key('low'), label: 'Low', value: 'low'),
|
|
BuzzSettingMenuOption(key: Key('high'), label: 'High', value: 'high'),
|
|
],
|
|
value: 'high',
|
|
valueLabel: 'High',
|
|
),
|
|
),
|
|
);
|
|
|
|
testWidgets('exposes button, expanded and checked semantics', (tester) async {
|
|
final handle = tester.ensureSemantics();
|
|
await tester.pumpWidget(menu(enabled: true));
|
|
SemanticsData trigger() =>
|
|
tester.getSemantics(find.byKey(const Key('menu'))).getSemanticsData();
|
|
expect(trigger().flagsCollection.isButton, isTrue);
|
|
expect(trigger().flagsCollection.isEnabled, Tristate.isTrue);
|
|
expect(trigger().flagsCollection.isExpanded, Tristate.isFalse);
|
|
|
|
await tester.tap(find.byKey(const Key('menu')));
|
|
await tester.pumpAndSettle();
|
|
expect(trigger().flagsCollection.isExpanded, Tristate.isTrue);
|
|
SemanticsData option(String key) =>
|
|
tester.getSemantics(find.byKey(Key(key))).getSemanticsData();
|
|
expect(option('high').flagsCollection.isChecked, CheckedState.isTrue);
|
|
expect(option('low').flagsCollection.isChecked, CheckedState.isFalse);
|
|
handle.dispose();
|
|
});
|
|
|
|
testWidgets('a disabled menu reads as a disabled button', (tester) async {
|
|
final handle = tester.ensureSemantics();
|
|
await tester.pumpWidget(menu(enabled: false));
|
|
final data = tester
|
|
.getSemantics(find.byKey(const Key('menu')))
|
|
.getSemanticsData();
|
|
expect(data.flagsCollection.isButton, isTrue);
|
|
expect(data.flagsCollection.isEnabled, Tristate.isFalse);
|
|
handle.dispose();
|
|
});
|
|
}
|