Merge commit 'c75023eb402a3851e5bbb617920e1574bb1614ef' into pipelines/run-20261111-0115-cupertino-out-servers-and-settings-secur-c6ad
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -34,61 +33,53 @@ class _Gateway extends FakeChatGateway {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'a pushed phone chat stays read and preserves underlying list chrome ($cupertino)',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
final gateway = _Gateway()..history = (_) async => chatPage([]);
|
||||
addTearDown(gateway.close);
|
||||
final bar = ShellBarRegistry();
|
||||
addTearDown(bar.dispose);
|
||||
final selected = ValueNotifier<String?>('s1');
|
||||
addTearDown(selected.dispose);
|
||||
final screen = ShellBarScope(
|
||||
registry: bar,
|
||||
destination: AppDestination.chat,
|
||||
child: ValueListenableBuilder<String?>(
|
||||
valueListenable: selected,
|
||||
builder: (_, id, _) => ChatScreen(
|
||||
gateway: gateway,
|
||||
initialSessionId: id,
|
||||
onBack: () => selected.value = null,
|
||||
),
|
||||
testWidgets(
|
||||
'a pushed phone chat stays read and preserves underlying list chrome',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
final gateway = _Gateway()..history = (_) async => chatPage([]);
|
||||
addTearDown(gateway.close);
|
||||
final bar = ShellBarRegistry();
|
||||
addTearDown(bar.dispose);
|
||||
final selected = ValueNotifier<String?>('s1');
|
||||
addTearDown(selected.dispose);
|
||||
final screen = ShellBarScope(
|
||||
registry: bar,
|
||||
destination: AppDestination.chat,
|
||||
child: ValueListenableBuilder<String?>(
|
||||
valueListenable: selected,
|
||||
builder: (_, id, _) => ChatScreen(
|
||||
gateway: gateway,
|
||||
initialSessionId: id,
|
||||
onBack: () => selected.value = null,
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
|
||||
: MaterialApp(home: Scaffold(body: screen)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final list = tester.widget<ChatSessionsScreen>(
|
||||
find.byType(ChatSessionsScreen, skipOffstage: false),
|
||||
);
|
||||
final controller = list.controller!;
|
||||
expect(controller.activeSessionId, 's1');
|
||||
expect(bar.specFor(AppDestination.chat)?.actions, isNotEmpty);
|
||||
gateway.emitEvent(chatTextFrame('New live answer', session: 's1'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.sessions.where(controller.isUnseen), isEmpty);
|
||||
gateway.emitEvent(chatTextFrame('Different answer', session: 's2'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
controller.sessions
|
||||
.where(controller.isUnseen)
|
||||
.map((row) => row['id']),
|
||||
['s2'],
|
||||
);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.activeSessionId, isNull);
|
||||
expect(find.text('Open conversation'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||
await tester.pumpAndSettle();
|
||||
final list = tester.widget<ChatSessionsScreen>(
|
||||
find.byType(ChatSessionsScreen, skipOffstage: false),
|
||||
);
|
||||
final controller = list.controller!;
|
||||
expect(controller.activeSessionId, 's1');
|
||||
expect(bar.specFor(AppDestination.chat)?.actions, isNotEmpty);
|
||||
gateway.emitEvent(chatTextFrame('New live answer', session: 's1'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.sessions.where(controller.isUnseen), isEmpty);
|
||||
gateway.emitEvent(chatTextFrame('Different answer', session: 's2'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
controller.sessions.where(controller.isUnseen).map((row) => row['id']),
|
||||
['s2'],
|
||||
);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.activeSessionId, isNull);
|
||||
expect(find.text('Open conversation'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -192,6 +192,13 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(widthOf(tester, 'three'), 950);
|
||||
expect(find.byType(ChatCenterStageStrip), findsNWidgets(2));
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(ChatCenterStageStrip).first,
|
||||
matching: find.byType(InkWell),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('draft'), findsOneWidget);
|
||||
|
||||
stage.value = false;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_mobile_panes.dart';
|
||||
@@ -36,54 +35,48 @@ class _ThreadState extends State<_Thread> {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final height in [32.0, 48.0]) {
|
||||
testWidgets(
|
||||
'peek title and switch fit $height height at 2x ($cupertino)',
|
||||
(tester) async {
|
||||
var activated = 0;
|
||||
Size? bodySize;
|
||||
final viewport = MediaQuery(
|
||||
data: const MediaQueryData(textScaler: TextScaler.linear(2)),
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: SizedBox(
|
||||
width: 320,
|
||||
height: height,
|
||||
child: ChatMobilePaneViewport(
|
||||
peek: true,
|
||||
active: false,
|
||||
barReveal: const AlwaysStoppedAnimation(0),
|
||||
onActivate: () => activated++,
|
||||
label: 'A long working project name',
|
||||
paneId: 'first',
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
bodySize = constraints.biggest;
|
||||
return const SizedBox.expand();
|
||||
},
|
||||
),
|
||||
),
|
||||
for (final height in [32.0, 48.0]) {
|
||||
testWidgets('peek title and switch fit $height height at 2x', (
|
||||
tester,
|
||||
) async {
|
||||
var activated = 0;
|
||||
Size? bodySize;
|
||||
final viewport = MediaQuery(
|
||||
data: const MediaQueryData(textScaler: TextScaler.linear(2)),
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: SizedBox(
|
||||
width: 320,
|
||||
height: height,
|
||||
child: ChatMobilePaneViewport(
|
||||
peek: true,
|
||||
active: false,
|
||||
barReveal: const AlwaysStoppedAnimation(0),
|
||||
onActivate: () => activated++,
|
||||
label: 'A long working project name',
|
||||
paneId: 'first',
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
bodySize = constraints.biggest;
|
||||
return const SizedBox.expand();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: viewport))
|
||||
: MaterialApp(home: Scaffold(body: viewport)),
|
||||
);
|
||||
expect(find.text('A long working project name'), findsOneWidget);
|
||||
expect(find.text('Switch'), findsOneWidget);
|
||||
final headerSize = tester.getSize(find.byType(ChatPeekHeader));
|
||||
expect(headerSize.height, lessThanOrEqualTo(height));
|
||||
expect(bodySize!.height, closeTo(height - headerSize.height, .01));
|
||||
await tester.tap(find.text('Switch'));
|
||||
await tester.pump();
|
||||
expect(activated, 1);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: viewport)));
|
||||
expect(find.text('A long working project name'), findsOneWidget);
|
||||
expect(find.text('Switch'), findsOneWidget);
|
||||
expect(find.byType(TextButton), findsOneWidget);
|
||||
final headerSize = tester.getSize(find.byType(ChatPeekHeader));
|
||||
expect(headerSize.height, lessThanOrEqualTo(height));
|
||||
expect(bodySize!.height, closeTo(height - headerSize.height, .01));
|
||||
await tester.tap(find.text('Switch'));
|
||||
await tester.pump();
|
||||
expect(activated, 1);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
testWidgets('peek header reserves real body space and keeps reading state', (
|
||||
tester,
|
||||
|
||||
@@ -3,56 +3,47 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace_entrance.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('retained entrance moves the same child ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
tester.platformDispatcher.accessibilityFeaturesTestValue =
|
||||
const FakeAccessibilityFeatures(disableAnimations: false);
|
||||
addTearDown(
|
||||
tester.platformDispatcher.clearAccessibilityFeaturesTestValue,
|
||||
);
|
||||
final childKey = GlobalKey();
|
||||
final child = TextField(key: childKey);
|
||||
Widget host(bool visible, {bool reduced = false}) => MaterialApp(
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(disableAnimations: reduced),
|
||||
child: SizedBox.expand(
|
||||
child: ChatWorkspaceEntrance(
|
||||
visible: visible,
|
||||
cupertino: cupertino,
|
||||
child: Material(child: child),
|
||||
),
|
||||
testWidgets('retained entrance moves the same child', (tester) async {
|
||||
tester.platformDispatcher.accessibilityFeaturesTestValue =
|
||||
const FakeAccessibilityFeatures(disableAnimations: false);
|
||||
addTearDown(tester.platformDispatcher.clearAccessibilityFeaturesTestValue);
|
||||
final childKey = GlobalKey();
|
||||
final child = TextField(key: childKey);
|
||||
Widget host(bool visible, {bool reduced = false}) => MaterialApp(
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(disableAnimations: reduced),
|
||||
child: SizedBox.expand(
|
||||
child: ChatWorkspaceEntrance(
|
||||
visible: visible,
|
||||
cupertino: false,
|
||||
child: Material(child: child),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(host(false));
|
||||
final element = childKey.currentContext;
|
||||
final state = childKey.currentState;
|
||||
expect(find.byKey(childKey), findsNothing);
|
||||
await tester.pumpWidget(host(true));
|
||||
final start = tester.getTopLeft(find.byKey(childKey));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 80));
|
||||
final middle = tester.getTopLeft(find.byKey(childKey));
|
||||
await tester.pumpAndSettle();
|
||||
final end = tester.getTopLeft(find.byKey(childKey));
|
||||
expect(cupertino ? middle.dx : middle.dy, greaterThan(0));
|
||||
expect(
|
||||
cupertino ? middle.dx : middle.dy,
|
||||
lessThan(cupertino ? start.dx : start.dy),
|
||||
);
|
||||
expect(end, Offset.zero);
|
||||
expect(childKey.currentContext, same(element));
|
||||
expect(childKey.currentState, same(state));
|
||||
await tester.enterText(find.byType(TextField), 'Retained draft');
|
||||
await tester.pumpWidget(host(false));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(host(true, reduced: true));
|
||||
expect(tester.getTopLeft(find.byKey(childKey)), Offset.zero);
|
||||
expect(find.text('Retained draft'), findsOneWidget);
|
||||
expect(childKey.currentState, same(state));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(host(false));
|
||||
final element = childKey.currentContext;
|
||||
final state = childKey.currentState;
|
||||
expect(find.byKey(childKey), findsNothing);
|
||||
await tester.pumpWidget(host(true));
|
||||
final start = tester.getTopLeft(find.byKey(childKey));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 80));
|
||||
final middle = tester.getTopLeft(find.byKey(childKey));
|
||||
await tester.pumpAndSettle();
|
||||
final end = tester.getTopLeft(find.byKey(childKey));
|
||||
expect(middle.dy, greaterThan(0));
|
||||
expect(middle.dy, lessThan(start.dy));
|
||||
expect(end, Offset.zero);
|
||||
expect(childKey.currentContext, same(element));
|
||||
expect(childKey.currentState, same(state));
|
||||
await tester.enterText(find.byType(TextField), 'Retained draft');
|
||||
await tester.pumpWidget(host(false));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(host(true, reduced: true));
|
||||
expect(tester.getTopLeft(find.byKey(childKey)), Offset.zero);
|
||||
expect(find.text('Retained draft'), findsOneWidget);
|
||||
expect(childKey.currentState, same(state));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user