Chat stack: the default, also on a wide phone or tablet; a close button where the pile was
Chat stack is now the default phone chat navigation (a stored choice is kept), and on Android or iOS it stays on a wide layout (an unfolded foldable) above the active pane, where floating is ignored too. When expanded, the pile turns into a close button at its own spot and the column rises above it; while a chat is dragged that button is the remove target, replacing the separate x at the bottom. Chat widget tests start on Quick switch (they run as Android); the stack's tests choose it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:pipelines_app/features/chat/stack/mobile_chat_navigation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/app_session.dart';
|
||||
@@ -29,6 +30,12 @@ Widget host(AppSession session, {String? initialSessionId}) => MaterialApp(
|
||||
);
|
||||
|
||||
void main() {
|
||||
// These describe the Quick switch layout (the peek of the next chat).
|
||||
setUp(
|
||||
() => MobileChatNavigationController.instance.debugUse(
|
||||
MobileChatNavigation.quickSwitch,
|
||||
),
|
||||
);
|
||||
testWidgets('nothing is requested before the shared socket is ready', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:pipelines_app/features/chat/stack/mobile_chat_navigation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -293,6 +294,12 @@ Future<void> replyChatHistory(
|
||||
}
|
||||
|
||||
void main() {
|
||||
// These describe the Quick switch layout (the peek of the next chat).
|
||||
setUp(
|
||||
() => MobileChatNavigationController.instance.debugUse(
|
||||
MobileChatNavigation.quickSwitch,
|
||||
),
|
||||
);
|
||||
testWidgets(
|
||||
'a wide /chat/s1 deep link shows that thread beside the list and route Back returns to /chat',
|
||||
(tester) async {
|
||||
|
||||
@@ -1,13 +1,23 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/stack/mobile_chat_navigation.dart';
|
||||
|
||||
/// Functional chat tests settle asynchronous state with reduced motion. Tests
|
||||
/// covering animation explicitly opt back in and pump known frame durations.
|
||||
///
|
||||
/// Tests run as Android, where the Chat stack (the default) also shows on a
|
||||
/// wide layout. Each test starts on Quick switch, the layout most of them
|
||||
/// describe; the stack's own tests choose it.
|
||||
Future<void> testExecutable(FutureOr<void> Function() testMain) async {
|
||||
TestWidgetsFlutterBinding.ensureInitialized()
|
||||
.platformDispatcher
|
||||
.accessibilityFeaturesTestValue = const FakeAccessibilityFeatures(
|
||||
disableAnimations: true,
|
||||
);
|
||||
setUp(
|
||||
() => MobileChatNavigationController.instance.debugUse(
|
||||
MobileChatNavigation.quickSwitch,
|
||||
),
|
||||
);
|
||||
await testMain();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:pipelines_app/features/chat/screen.dart';
|
||||
import 'package:pipelines_app/features/chat/stack/chat_stack_column.dart';
|
||||
import 'package:pipelines_app/features/chat/stack/chat_stack_disc.dart';
|
||||
import 'package:pipelines_app/features/chat/stack/chat_stack_drag.dart';
|
||||
import 'package:pipelines_app/features/chat/stack/chat_stack_remove_target.dart';
|
||||
import 'package:pipelines_app/features/chat/stack/chat_stack_close_target.dart';
|
||||
import 'package:pipelines_app/features/chat/stack/mobile_chat_navigation.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
|
||||
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
@@ -117,7 +117,7 @@ Finder _button(WidgetTester tester, String id) {
|
||||
}
|
||||
|
||||
final _add = find.byKey(const ValueKey('chat-stack-button-add'));
|
||||
final _target = find.byType(ChatStackRemoveTarget);
|
||||
final _target = find.byType(ChatStackCloseTarget);
|
||||
|
||||
/// Holds [finder] until it lifts.
|
||||
Future<TestGesture> _lift(WidgetTester tester, Finder finder) async {
|
||||
@@ -127,7 +127,7 @@ Future<TestGesture> _lift(WidgetTester tester, Finder finder) async {
|
||||
}
|
||||
|
||||
double _shown(WidgetTester tester) =>
|
||||
tester.widget<ChatStackRemoveTarget>(_target).shown.value;
|
||||
tester.widget<ChatStackCloseTarget>(_target).armed.value;
|
||||
|
||||
void main() {
|
||||
final navigation = MobileChatNavigationController.instance;
|
||||
@@ -182,7 +182,7 @@ void main() {
|
||||
final from = tester.getCenter(_button(tester, 'b'));
|
||||
await gesture.moveBy(tester.getCenter(_target) - from);
|
||||
await tester.pumpAndSettle();
|
||||
final drag = tester.widget<ChatStackRemoveTarget>(_target).hover;
|
||||
final drag = tester.widget<ChatStackCloseTarget>(_target).hover;
|
||||
expect(drag.value, 1);
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
@@ -308,9 +308,9 @@ void main() {
|
||||
await gesture.moveBy(const Offset(0, -kChatStackPitch));
|
||||
await tester.pump();
|
||||
expect(tester.getCenter(_button(tester, 'b')).dy, b.dy + kChatStackPitch);
|
||||
// No slide: the target sits in place.
|
||||
// No turn or growth: the button only fades.
|
||||
expect(
|
||||
find.descendant(of: _target, matching: find.byType(SlideTransition)),
|
||||
find.descendant(of: _target, matching: find.byType(RotationTransition)),
|
||||
findsNothing,
|
||||
);
|
||||
await gesture.up();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/stack/chat_stack_close_target.dart';
|
||||
import 'package:pipelines_app/features/chat/stack/chat_stack_column.dart';
|
||||
import 'package:pipelines_app/features/chat/stack/chat_stack_disc.dart';
|
||||
import 'package:pipelines_app/features/chat/stack/chat_stack_entry.dart';
|
||||
import 'package:pipelines_app/features/chat/stack/chat_stack_fab.dart';
|
||||
import 'package:pipelines_app/features/chat/stack/chat_stack_pose.dart';
|
||||
@@ -103,7 +105,8 @@ void main() {
|
||||
expect(find.text('Chat 0'), findsOneWidget);
|
||||
expect(find.text('Chat 4'), findsOneWidget);
|
||||
expect(find.text(ChatStackColumn.addLabel), findsOneWidget);
|
||||
// Item 0 sits on the stack; each further item rises one pitch.
|
||||
// The stack's slot holds the close button; item 0 sits a pitch above
|
||||
// it and each further item rises one more.
|
||||
final first = tester.getCenter(
|
||||
find.byKey(const ValueKey('chat-stack-button-pane-0')),
|
||||
);
|
||||
@@ -114,7 +117,11 @@ void main() {
|
||||
find.byKey(const ValueKey('chat-stack-button-add')),
|
||||
);
|
||||
expect(first.dx, closeTo(slot.center.dx, .5));
|
||||
expect(first.dy, closeTo(slot.center.dy, .5));
|
||||
expect(first.dy, closeTo(slot.center.dy - kChatStackPitch, .5));
|
||||
expect(
|
||||
tester.getCenter(find.bySemanticsLabel(ChatStackCloseTarget.label)),
|
||||
slot.center,
|
||||
);
|
||||
expect(second.dy, lessThan(first.dy));
|
||||
expect(add.dy, lessThan(second.dy));
|
||||
// Outside the column.
|
||||
@@ -126,6 +133,22 @@ void main() {
|
||||
expect(harness.opened, isEmpty);
|
||||
});
|
||||
|
||||
testWidgets('the close button where the pile was folds the column', (
|
||||
tester,
|
||||
) async {
|
||||
final harness = await _pump(tester);
|
||||
final slot = tester.getRect(find.byKey(const Key('chat-stack')));
|
||||
await tester.tap(find.byKey(const Key('chat-stack')));
|
||||
await _settle(tester);
|
||||
await tester.tapAt(slot.center);
|
||||
await tester.pump();
|
||||
expect(_state(tester).expanded, isFalse);
|
||||
await _settle(tester);
|
||||
expect(find.byType(ChatStackColumn), findsNothing);
|
||||
expect(harness.opened, isEmpty);
|
||||
expect(harness.added, 0);
|
||||
});
|
||||
|
||||
testWidgets('tapping a chat opens it and folds the column', (tester) async {
|
||||
final harness = await _pump(tester);
|
||||
await tester.tap(find.byKey(const Key('chat-stack')));
|
||||
|
||||
@@ -34,6 +34,15 @@ class _Gateway extends FakeChatGateway {
|
||||
}
|
||||
}
|
||||
|
||||
class _Store implements MobileChatNavigationStore {
|
||||
_Store(this.value);
|
||||
final String? value;
|
||||
@override
|
||||
Future<String?> load() async => value;
|
||||
@override
|
||||
Future<bool> save(String value) async => true;
|
||||
}
|
||||
|
||||
Future<void> _pump(WidgetTester tester, Size size) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
unawaited(
|
||||
@@ -114,14 +123,53 @@ void main() {
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
});
|
||||
|
||||
testWidgets('a wide window keeps its panes and shows no stack', (
|
||||
tester,
|
||||
) async {
|
||||
await _pump(tester, const Size(1280, 800));
|
||||
await tester.tap(find.byKey(const Key('chat-row-a')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_thread('a'), findsOneWidget);
|
||||
expect(_stack, findsNothing);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
testWidgets(
|
||||
'a wide desktop window keeps its panes and shows no stack',
|
||||
variant: TargetPlatformVariant.desktop(),
|
||||
(tester) async {
|
||||
await _pump(tester, const Size(1280, 800));
|
||||
await tester.tap(find.byKey(const Key('chat-row-a')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_thread('a'), findsOneWidget);
|
||||
expect(_stack, findsNothing);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'a wide phone or tablet layout (an unfolded foldable) keeps the stack',
|
||||
variant: TargetPlatformVariant({
|
||||
TargetPlatform.android,
|
||||
TargetPlatform.iOS,
|
||||
}),
|
||||
(tester) async {
|
||||
await _pump(tester, const Size(1280, 800));
|
||||
await tester.tap(find.byKey(const Key('chat-row-a')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_thread('a'), findsOneWidget);
|
||||
// The list stays beside the chat, the stack floats over the pane.
|
||||
expect(find.byKey(const Key('chat-row-b')), findsOneWidget);
|
||||
expect(_stack.hitTestable(), findsOneWidget);
|
||||
await tester.tap(_stack);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const ValueKey('chat-stack-button-add')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Beta').last);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.bySemanticsLabel(chatStackLabel(2)), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
|
||||
test('Chat stack is the default without a stored choice', () async {
|
||||
final controller = MobileChatNavigationController(store: _Store(null));
|
||||
expect(controller.value, MobileChatNavigation.chatStack);
|
||||
await controller.restore();
|
||||
expect(controller.value, MobileChatNavigation.chatStack);
|
||||
final chosen = MobileChatNavigationController(store: _Store('quickSwitch'));
|
||||
await chosen.restore();
|
||||
expect(chosen.value, MobileChatNavigation.quickSwitch);
|
||||
controller.dispose();
|
||||
chosen.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -32,19 +32,20 @@ void main() {
|
||||
),
|
||||
);
|
||||
expect(find.text(SettingsChatNavigationSection.title), findsOneWidget);
|
||||
expect(controller.value, MobileChatNavigation.quickSwitch);
|
||||
// Without a stored choice: the Chat stack.
|
||||
expect(controller.value, MobileChatNavigation.chatStack);
|
||||
expect(
|
||||
find.text(MobileChatNavigation.quickSwitch.description),
|
||||
find.text(MobileChatNavigation.chatStack.description),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(
|
||||
find.byKey(const ValueKey('settings-chat-navigation-chatStack')),
|
||||
find.byKey(const ValueKey('settings-chat-navigation-quickSwitch')),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.value, MobileChatNavigation.chatStack);
|
||||
expect(store.saved, 'chatStack');
|
||||
expect(controller.value, MobileChatNavigation.quickSwitch);
|
||||
expect(store.saved, 'quickSwitch');
|
||||
expect(
|
||||
find.text(MobileChatNavigation.chatStack.description),
|
||||
find.text(MobileChatNavigation.quickSwitch.description),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
@@ -52,11 +53,11 @@ void main() {
|
||||
final next = MobileChatNavigationController(store: store);
|
||||
addTearDown(next.dispose);
|
||||
await next.restore();
|
||||
expect(next.value, MobileChatNavigation.chatStack);
|
||||
expect(next.value, MobileChatNavigation.quickSwitch);
|
||||
|
||||
store.success = false;
|
||||
await tester.tap(
|
||||
find.byKey(const ValueKey('settings-chat-navigation-quickSwitch')),
|
||||
find.byKey(const ValueKey('settings-chat-navigation-chatStack')),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Could not save; applies until reload.'), findsOneWidget);
|
||||
|
||||
Reference in New Issue
Block a user