Files
pipelines/app/test/features/chat/conversation/chat_composer_placeholder_test.dart
T
alan 027c2f800e feat(chat): ChatGPT-style transcript and composer
Agent replies sit on the page without a bubble and get a copy control;
the operator's turn is a neutral rounded bubble; the composer is one
filled pill with +, a borderless field and a round Send, and its
placeholder names the chat's folder. Also fixes two picker tests left
stale by the native picker.
2026-10-30 15:56:39 +00:00

77 lines
2.8 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/conversation/chat_composer_bar.dart';
import 'chat_composer_bar_fixtures.dart';
void main() {
testWidgets('an empty Cupertino composer holds its whole placeholder at '
'320px with 2x text', (tester) async {
tester.view.physicalSize = const Size(640, 1400);
tester.view.devicePixelRatio = 2;
tester.platformDispatcher.textScaleFactorTestValue = 2;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
final gateway = ComposerBarGateway();
addTearDown(gateway.close);
await tester.pumpWidget(composerThread(gateway, cupertino: true));
await tester.pumpAndSettle();
final field = tester.getRect(find.byType(CupertinoTextField));
final placeholder = find.text(chatComposerPlaceholder);
final rect = tester.getRect(placeholder);
expect(rect.bottom, lessThanOrEqualTo(field.bottom));
// Longer than three lines it ends in an ellipsis, never a clipped line.
final paragraph = tester.renderObject<RenderParagraph>(placeholder);
if (paragraph.didExceedMaxLines) {
expect(paragraph.overflow, TextOverflow.ellipsis);
}
});
test('the placeholder names the chat\'s folder when it has one', () {
expect(chatComposerPlaceholderFor('/Users/ada/repos/tank'), 'Work on tank');
expect(
chatComposerPlaceholderFor('/Users/ada/repos/tank/'),
'Work on tank',
);
expect(chatComposerPlaceholderFor(r'C:\\work\\tank'), 'Work on tank');
expect(chatComposerPlaceholderFor(' '), chatComposerPlaceholder);
expect(chatComposerPlaceholderFor('/'), chatComposerPlaceholder);
});
for (final cupertino in [false, true]) {
testWidgets('the composer is one pill holding attach, field and Send '
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
final gateway = ComposerBarGateway();
addTearDown(gateway.close);
await tester.pumpWidget(
composerThread(
gateway,
cupertino: cupertino,
session: const {'id': 's', 'directory': '/Users/ada/repos/tank'},
),
);
await tester.pumpAndSettle();
final pill = find.byKey(const Key('chat-composer-pill'));
for (final key in [
'chat-composer-attach',
'chat-composer-field',
'chat-composer-primary',
]) {
expect(
find.descendant(of: pill, matching: find.byKey(Key(key))),
findsOneWidget,
);
}
expect(
find.descendant(of: pill, matching: find.text('Work on tank')),
findsOneWidget,
);
});
}
}