Files
clide/test/app_collapse_toggle_test.dart
jpmschweitzerandClaude Opus 4.8 6d0ebab721 chore: adopt Dart 3.9 toolchain — honest floor + tall-style reformat (T-353)
Raise the declared minimums in pubspec.yaml to what our deps already
require: Flutter >=3.35.0 / Dart >=3.9.0 (was 3.19.0 / 3.5.0). alchemist
0.12 needs Flutter 3.32; Dart 3.9 first ships in Flutter 3.35, so 3.35 is
the binding floor. Pin the exact build toolchain in .fvmrc (Flutter
3.44.1).

Moving to the Dart 3.9 language level switches `dart format` to the new
"tall" style and enables two new lints. This commit is the resulting
mechanical churn, isolated from any behaviour change:
  - whole-tree `dart format` reformat (tall style)
  - `dart fix` for unnecessary_underscores + use_null_aware_elements

No runtime behaviour change; `make test` green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-11 12:11:53 +02:00

108 lines
4.2 KiB
Dart

/// Status-bar collapse toggle (T-294): a fixed cell pinned to a screen edge of
/// the bar, flipping a caret-line chevron to reflect the direction of the
/// action and firing the existing collapse commands.
library;
import 'package:clide/app.dart';
import 'package:clide/builtin/default_layout/default_layout.dart';
import 'package:clide/extension/extension.dart';
import 'package:clide/kernel/kernel.dart';
import 'package:clide/widgets/widgets.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'helpers/kernel_fixture.dart';
Finder _icon(PhosphorIconPainter p) => find.byWidgetPredicate((w) => w is ClideIcon && w.painter == p);
Widget _host(KernelFixture f, Widget child) => Directionality(
textDirection: TextDirection.ltr,
child: ClideKernel(
services: f.services,
child: ClideTheme(
controller: f.services.theme,
child: MediaQuery(
data: const MediaQueryData(size: Size(800, 200)),
child: Align(
alignment: Alignment.topLeft,
child: SizedBox(height: 26, child: child),
),
),
),
),
);
void main() {
late KernelFixture f;
setUp(() async => f = await KernelFixture.create());
tearDown(() => f.dispose());
testWidgets('chevron points the direction of the action (collapse vs expand)', (tester) async {
// Sidebar open → action is collapse (leftward) → caret-line-left.
await tester.pumpWidget(_host(f, const StatusbarCollapseToggle(slot: Slots.sidebar, collapsed: false, visible: true)));
await tester.pump();
expect(_icon(PhosphorIcons.byName('caret-line-left')), findsOneWidget);
// Sidebar collapsed → action is expand (rightward) → caret-line-right.
await tester.pumpWidget(_host(f, const StatusbarCollapseToggle(slot: Slots.sidebar, collapsed: true, visible: true)));
await tester.pump();
expect(_icon(PhosphorIcons.byName('caret-line-right')), findsOneWidget);
// The context toggle mirrors it: open → collapse rightward, collapsed → expand leftward.
await tester.pumpWidget(_host(f, const StatusbarCollapseToggle(slot: Slots.contextPanel, collapsed: false, visible: true)));
await tester.pump();
expect(_icon(PhosphorIcons.byName('caret-line-right')), findsOneWidget);
});
testWidgets('the chevron flips live when the collapsed state changes', (tester) async {
var collapsed = false;
late StateSetter setOuter;
await tester.pumpWidget(
_host(
f,
StatefulBuilder(
builder: (ctx, setState) {
setOuter = setState;
return StatusbarCollapseToggle(slot: Slots.sidebar, collapsed: collapsed, visible: true);
},
),
),
);
await tester.pump();
expect(_icon(PhosphorIcons.byName('caret-line-left')), findsOneWidget);
setOuter(() => collapsed = true);
await tester.pump();
expect(_icon(PhosphorIcons.byName('caret-line-right')), findsOneWidget, reason: 'rebuilds and flips on state change');
expect(_icon(PhosphorIcons.byName('caret-line-left')), findsNothing);
});
testWidgets('a hidden pane reserves the cell but shows no chevron', (tester) async {
await tester.pumpWidget(_host(f, const StatusbarCollapseToggle(slot: Slots.sidebar, collapsed: false, visible: false)));
await tester.pump();
expect(_icon(PhosphorIcons.byName('caret-line-left')), findsNothing);
expect(_icon(PhosphorIcons.byName('caret-line-right')), findsNothing);
});
testWidgets('tapping fires the matching collapse command', (tester) async {
f.services.arrangement.applyPreset(
const LayoutPresetContribution(
id: 'test',
displayName: 'test',
slots: [LayoutSlot(slot: Slots.sidebar, position: SlotPosition.left, visible: true)],
),
);
f.services.extensions.register(DefaultLayoutExtension());
await f.services.extensions.activate('builtin.default-layout');
await tester.pumpWidget(_host(f, const StatusbarCollapseToggle(slot: Slots.sidebar, collapsed: false, visible: true)));
await tester.pump();
expect(f.services.arrangement.isCollapsed(Slots.sidebar), isFalse);
await tester.tap(_icon(PhosphorIcons.byName('caret-line-left')));
await tester.pump();
expect(f.services.arrangement.isCollapsed(Slots.sidebar), isTrue);
});
}