Remove Cupertino chat transcript branches
Keep the existing Material transcript path while preserving public Cupertino parameters for callers. Narrow transcript tests to the Material-only behavior and remove Cupertino-only fixtures.
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:pipelines_app/core/api_gateway.dart';
|
||||
@@ -13,11 +12,6 @@ Widget host(Widget child) => MaterialApp(
|
||||
home: Scaffold(body: child),
|
||||
);
|
||||
|
||||
Widget cupertinoHost(Widget child) => CupertinoApp(
|
||||
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
||||
home: CupertinoPageScaffold(child: child),
|
||||
);
|
||||
|
||||
/// A history tall enough that the transcript overflows the test viewport.
|
||||
JsonMap tallPage() => chatPage([
|
||||
for (var index = 0; index < 14; index++)
|
||||
@@ -84,81 +78,70 @@ void main() {
|
||||
expect(find.byKey(const Key('chat-jump-to-latest')), findsNothing);
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'an upward scroll releases follow and the control counts arrivals '
|
||||
'(${cupertino ? 'cupertino' : 'material'})',
|
||||
(tester) async {
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
gateway.history = (_) async => tallPage();
|
||||
testWidgets(
|
||||
'an upward scroll releases follow and the control counts arrivals',
|
||||
(tester) async {
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
gateway.history = (_) async => tallPage();
|
||||
|
||||
await tester.pumpWidget(
|
||||
(cupertino ? cupertinoHost : host)(
|
||||
ChatThreadView(gateway: gateway, sessionId: 's', onBack: () {}),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
host(ChatThreadView(gateway: gateway, sessionId: 's', onBack: () {})),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final scroll = transcriptScroll(tester);
|
||||
await tester.drag(
|
||||
find.byKey(const Key('chat-thread-s')),
|
||||
const Offset(0, 360),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final scroll = transcriptScroll(tester);
|
||||
await tester.drag(
|
||||
find.byKey(const Key('chat-thread-s')),
|
||||
const Offset(0, 360),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final releasedAt = scroll.position.pixels;
|
||||
expect(
|
||||
releasedAt,
|
||||
lessThan(scroll.position.maxScrollExtent - chatFollowThresholdPx),
|
||||
);
|
||||
expect(find.byKey(const Key('chat-jump-to-latest')), findsOneWidget);
|
||||
expect(find.text('Jump to latest'), findsOneWidget);
|
||||
final releasedAt = scroll.position.pixels;
|
||||
expect(
|
||||
releasedAt,
|
||||
lessThan(scroll.position.maxScrollExtent - chatFollowThresholdPx),
|
||||
);
|
||||
expect(find.byKey(const Key('chat-jump-to-latest')), findsOneWidget);
|
||||
expect(find.text('Jump to latest'), findsOneWidget);
|
||||
|
||||
gateway.emitEvent(chatTextFrame('A new answer. ', messageId: 'live-1'));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
gateway.emitEvent(chatTextFrame('A new answer. ', messageId: 'live-1'));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
// The operator's position is not moved by an arrival; only the
|
||||
// control's count changes.
|
||||
expect(scroll.position.pixels, closeTo(releasedAt, 0.5));
|
||||
expect(find.text('Jump to latest · 1 new message'), findsOneWidget);
|
||||
// The operator's position is not moved by an arrival; only the
|
||||
// control's count changes.
|
||||
expect(scroll.position.pixels, closeTo(releasedAt, 0.5));
|
||||
expect(find.text('Jump to latest · 1 new message'), findsOneWidget);
|
||||
|
||||
gateway.emitEvent(
|
||||
chatTextFrame('A second answer. ', messageId: 'live-2'),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(scroll.position.pixels, closeTo(releasedAt, 0.5));
|
||||
expect(find.text('Jump to latest · 2 new messages'), findsOneWidget);
|
||||
gateway.emitEvent(
|
||||
chatTextFrame('A second answer. ', messageId: 'live-2'),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(scroll.position.pixels, closeTo(releasedAt, 0.5));
|
||||
expect(find.text('Jump to latest · 2 new messages'), findsOneWidget);
|
||||
|
||||
if (cupertino) {
|
||||
// The affordance is a standard Cupertino control; no Material
|
||||
// ancestor is introduced into the bare Cupertino host.
|
||||
expect(find.byType(Material), findsNothing);
|
||||
}
|
||||
await tester.tap(find.byKey(const Key('chat-jump-to-latest')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-jump-to-latest')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
scroll.position.pixels,
|
||||
closeTo(scroll.position.maxScrollExtent, 0.5),
|
||||
);
|
||||
expect(find.byKey(const Key('chat-jump-to-latest')), findsNothing);
|
||||
|
||||
expect(
|
||||
scroll.position.pixels,
|
||||
closeTo(scroll.position.maxScrollExtent, 0.5),
|
||||
);
|
||||
expect(find.byKey(const Key('chat-jump-to-latest')), findsNothing);
|
||||
|
||||
// Returning to the end re-arms following for later frames.
|
||||
gateway.emitEvent(chatTextFrame('Pinned again. ', messageId: 'live-3'));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(
|
||||
scroll.position.pixels,
|
||||
closeTo(scroll.position.maxScrollExtent, 0.5),
|
||||
);
|
||||
expect(find.byKey(const Key('chat-jump-to-latest')), findsNothing);
|
||||
},
|
||||
);
|
||||
}
|
||||
// Returning to the end re-arms following for later frames.
|
||||
gateway.emitEvent(chatTextFrame('Pinned again. ', messageId: 'live-3'));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(
|
||||
scroll.position.pixels,
|
||||
closeTo(scroll.position.maxScrollExtent, 0.5),
|
||||
);
|
||||
expect(find.byKey(const Key('chat-jump-to-latest')), findsNothing);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('a reopened conversation restores the position it was left at', (
|
||||
tester,
|
||||
@@ -287,46 +270,4 @@ void main() {
|
||||
expect(scroll.position.maxScrollExtent, 0);
|
||||
expect(find.byKey(const Key('chat-jump-to-latest')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('the control fits a 320px Cupertino viewport at 2x text', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(640, 1200);
|
||||
tester.view.devicePixelRatio = 2;
|
||||
tester.platformDispatcher.textScaleFactorTestValue = 2;
|
||||
tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);
|
||||
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
gateway.history = (_) async => tallPage();
|
||||
|
||||
await tester.pumpWidget(
|
||||
cupertinoHost(
|
||||
ChatThreadView(gateway: gateway, sessionId: 's', onBack: () {}),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.drag(
|
||||
find.byKey(const Key('chat-thread-s')),
|
||||
const Offset(0, 360),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
gateway.emitEvent(chatTextFrame('Arrival. ', messageId: 'live'));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
final control = find.byKey(const Key('chat-jump-to-latest'));
|
||||
expect(control, findsOneWidget);
|
||||
expect(find.text('Jump to latest · 1 new message'), findsOneWidget);
|
||||
final rect = tester.getRect(control);
|
||||
expect(rect.left, greaterThanOrEqualTo(0));
|
||||
expect(rect.right, lessThanOrEqualTo(320));
|
||||
expect(find.byType(Material), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user