357affe207
The inactive (peek) pane no longer shows the chat's bar: ChatPanePresentation tells the conversation its role and ChatPaneBarReveal keeps a resting peek's bar offstage (zero height, not painted), so the peek reads its transcript from the top. A drag on the peek scrolls that transcript; a tap anywhere on it, even over a button or link, activates the chat (ChatPeekTapRecognizer accepts on release ahead of the arena sweep and yields to drags past the slop). The 'chat-peek-<id>' semantics stay a labelled button. Switching animates (260 ms, Cubic(.2,.8,.2,1)): the tapped chat rises over the active one with its bottom edge pinned, then the covered chat slides up into the slot from the bottom edge; each bar fades and slides in or out over the rise. Content boxes keep their fixed size, so ticks move and clip retained pictures without laying a transcript out again. Reduced motion jumps. The old focus stripe is gone.
123 lines
3.7 KiB
Dart
123 lines
3.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/chat/conversation/chat_pane_presentation.dart';
|
|
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
|
import 'package:pipelines_app/features/chat/conversation/chat_transcript_scroll_view.dart';
|
|
|
|
import 'chat_thread_fixtures.dart';
|
|
|
|
/// The conversation's bar under a workspace presentation: shown for the
|
|
/// active chat, offstage for a resting peek (whose transcript starts at the
|
|
/// top), fading out in place while the chat is becoming the peek.
|
|
|
|
Future<void> _pump(
|
|
WidgetTester tester, {
|
|
required bool peek,
|
|
required double reveal,
|
|
}) async {
|
|
final gateway = FakeChatGateway();
|
|
addTearDown(gateway.close);
|
|
gateway.history = (_) async => chatPage([
|
|
for (var index = 0; index < 4; index++)
|
|
chatMessage(
|
|
'm$index',
|
|
index.isEven ? 'user' : 'assistant',
|
|
parts: [
|
|
{'type': 'text', 'text': 'Message $index'},
|
|
],
|
|
),
|
|
]);
|
|
gateway.subscribe = () async => const {};
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
body: ChatPanePresentation(
|
|
peek: peek,
|
|
barReveal: AlwaysStoppedAnimation(reveal),
|
|
child: ChatThreadView(
|
|
gateway: gateway,
|
|
sessionId: 's',
|
|
title: 'Presented',
|
|
onBack: () {},
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
void main() {
|
|
final header = find.byKey(const Key('chat-thread-header'));
|
|
double listTop(WidgetTester tester) => tester
|
|
.widget<ChatTranscriptScrollView>(
|
|
find.byKey(const ValueKey('chat-thread-s')),
|
|
)
|
|
.padding
|
|
.top;
|
|
|
|
testWidgets('the active chat shows its bar and keeps the list clear', (
|
|
tester,
|
|
) async {
|
|
await _pump(tester, peek: false, reveal: 1);
|
|
expect(header, findsOneWidget);
|
|
expect(listTop(tester), greaterThan(8));
|
|
expect(listTop(tester), closeTo(tester.getSize(header).height + 8, .5));
|
|
});
|
|
|
|
testWidgets('a resting peek keeps its bar offstage and reads from the top', (
|
|
tester,
|
|
) async {
|
|
await _pump(tester, peek: true, reveal: 0);
|
|
expect(header, findsNothing);
|
|
expect(
|
|
find.byKey(const Key('chat-thread-header'), skipOffstage: false),
|
|
findsOneWidget,
|
|
);
|
|
expect(listTop(tester), 8);
|
|
expect(find.text('Message 0'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('a leaving bar fades in place, keeping the list clear', (
|
|
tester,
|
|
) async {
|
|
await _pump(tester, peek: true, reveal: .4);
|
|
expect(header, findsOneWidget);
|
|
expect(listTop(tester), closeTo(tester.getSize(header).height + 8, .5));
|
|
final fade = tester.widget<FadeTransition>(
|
|
find.ancestor(of: header, matching: find.byType(FadeTransition)).first,
|
|
);
|
|
expect(fade.opacity.value, .4);
|
|
expect(
|
|
find.ancestor(of: header, matching: find.byType(IgnorePointer)),
|
|
findsWidgets,
|
|
);
|
|
});
|
|
|
|
testWidgets('without a presentation the bar is itself', (tester) async {
|
|
final gateway = FakeChatGateway();
|
|
addTearDown(gateway.close);
|
|
gateway.history = (_) async => chatPage(const []);
|
|
gateway.subscribe = () async => const {};
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
body: ChatThreadView(
|
|
gateway: gateway,
|
|
sessionId: 's',
|
|
title: 'Alone',
|
|
onBack: () {},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(header, findsOneWidget);
|
|
Widget? child;
|
|
tester
|
|
.element(find.byType(ChatPaneBarReveal))
|
|
.visitChildren((element) => child = element.widget);
|
|
expect(child?.key, const Key('chat-thread-header'));
|
|
});
|
|
}
|