merge(app): land chat-layout
This commit is contained in:
@@ -205,7 +205,9 @@ void main() {
|
||||
await tester.pump();
|
||||
expect(find.text('A live line arrived.'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text(cupertino ? 'Back' : 'Back to chats'));
|
||||
// One compact icon-only Back control in the thread header; its
|
||||
// accessible name is the destination, and both hosts share the key.
|
||||
await tester.tap(find.byKey(const Key('chat-back')));
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/chat');
|
||||
expect(find.byType(ChatThreadView), findsNothing);
|
||||
|
||||
@@ -89,7 +89,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('model-b'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Back to chats'));
|
||||
await tester.tap(find.byKey(const Key('chat-back')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('model-b'), findsNothing);
|
||||
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||
|
||||
import 'chat_thread_fixtures.dart';
|
||||
|
||||
const _title = 'A conversation title long enough to need an ellipsis at 320px';
|
||||
const _session = <String, dynamic>{
|
||||
'id': 's',
|
||||
'backend': 'opencode',
|
||||
'model': 'provider/an-extremely-long-recorded-model-id',
|
||||
'model_provider': 'p1',
|
||||
};
|
||||
|
||||
Widget _host(Widget child, {required bool cupertino}) => cupertino
|
||||
? CupertinoApp(
|
||||
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
||||
home: CupertinoPageScaffold(child: child),
|
||||
)
|
||||
: MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
home: Scaffold(body: child),
|
||||
);
|
||||
|
||||
void _useNarrowText(WidgetTester tester) {
|
||||
tester.view.physicalSize = const Size(320, 640);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.platformDispatcher.textScaleFactorTestValue = 2;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host header keeps back, title, model and actions on one row', (
|
||||
tester,
|
||||
) async {
|
||||
_useNarrowText(tester);
|
||||
final semantics = tester.ensureSemantics();
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
gateway.history = (_) async => chatPage(const []);
|
||||
gateway.subscribe = () async => const {};
|
||||
var backed = 0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
_host(
|
||||
ChatThreadView(
|
||||
gateway: gateway,
|
||||
sessionId: 's',
|
||||
title: _title,
|
||||
session: _session,
|
||||
onBack: () => backed++,
|
||||
),
|
||||
cupertino: cupertino,
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final title = find.text(_title);
|
||||
final model = find.byKey(const Key('chat-model'));
|
||||
final info = find.byKey(const Key('chat-info'));
|
||||
final back = find.byKey(const Key('chat-back'));
|
||||
expect(title, findsOneWidget);
|
||||
expect(model, findsOneWidget);
|
||||
expect(info, findsOneWidget);
|
||||
expect(back, findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
// The icon-only control still states its destination for assistive use.
|
||||
if (cupertino) {
|
||||
expect(find.bySemanticsLabel('Back to chats'), findsOneWidget);
|
||||
} else {
|
||||
expect(find.byTooltip('Back to chats'), findsOneWidget);
|
||||
}
|
||||
|
||||
// One row, in the web's order: back, title, model, information. A wrapped
|
||||
// header would put the controls on a different line from the title.
|
||||
double centerY(Finder finder) => tester.getCenter(finder).dy;
|
||||
expect((centerY(back) - centerY(title)).abs(), lessThan(16));
|
||||
expect((centerY(model) - centerY(title)).abs(), lessThan(16));
|
||||
expect((centerY(info) - centerY(title)).abs(), lessThan(16));
|
||||
double right(Finder finder) => tester.getTopRight(finder).dx;
|
||||
expect(right(back), lessThanOrEqualTo(tester.getTopLeft(title).dx));
|
||||
expect(right(title), lessThanOrEqualTo(tester.getTopLeft(model).dx));
|
||||
expect(right(model), lessThanOrEqualTo(tester.getTopLeft(info).dx));
|
||||
|
||||
await tester.tap(back);
|
||||
await tester.pump();
|
||||
expect(backed, 1);
|
||||
semantics.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('a conversation without a model keeps the same compact row', (
|
||||
tester,
|
||||
) async {
|
||||
_useNarrowText(tester);
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
gateway.history = (_) async => chatPage(const []);
|
||||
gateway.subscribe = () async => const {};
|
||||
|
||||
await tester.pumpWidget(
|
||||
_host(
|
||||
ChatThreadView(
|
||||
gateway: gateway,
|
||||
sessionId: 's',
|
||||
title: _title,
|
||||
session: {..._session, 'backend': 'claude'},
|
||||
onBack: () {},
|
||||
),
|
||||
cupertino: false,
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text(_title), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-model')), findsNothing);
|
||||
expect(
|
||||
(tester.getCenter(find.byKey(const Key('chat-info'))).dy -
|
||||
tester.getCenter(find.text(_title)).dy)
|
||||
.abs(),
|
||||
lessThan(16),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
@@ -54,18 +54,18 @@ void main() {
|
||||
],
|
||||
};
|
||||
await pumpMaterialChat(tester, gateway);
|
||||
expect(find.text('/work · New'), findsNothing);
|
||||
expect(find.text('New'), findsNothing);
|
||||
|
||||
updatedAt = 2000;
|
||||
await tester.tap(find.byKey(const Key('chat-refresh')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('/work · New'), findsOneWidget);
|
||||
expect(find.text('New'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-row-s1')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('chat-refresh')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('/work · New'), findsNothing);
|
||||
expect(find.text('New'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('a closed row never reports New after newer activity', (
|
||||
@@ -86,7 +86,7 @@ void main() {
|
||||
],
|
||||
};
|
||||
await pumpMaterialChat(tester, gateway);
|
||||
expect(find.text('/work · New'), findsNothing);
|
||||
expect(find.text('New'), findsNothing);
|
||||
|
||||
// Another device moved the chat on and closed it after this device read it.
|
||||
updatedAt = 2000;
|
||||
@@ -94,8 +94,14 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('chat-refresh')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('/work · New'), findsNothing);
|
||||
expect(find.text('Closed'), findsOneWidget);
|
||||
expect(find.text('New'), findsNothing);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('chat-row-s1')),
|
||||
matching: find.text('Closed'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Material row refusal is readable at 320px 2x dark', (
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_list_cupertino.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_row_style.dart';
|
||||
|
||||
/// A grouped Cupertino list, the host the web client runs on macOS/iOS.
|
||||
Future<void> _pumpRows(
|
||||
WidgetTester tester,
|
||||
List<JsonMap> sessions, {
|
||||
bool Function(JsonMap)? isUnseen,
|
||||
}) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
||||
home: CupertinoPageScaffold(
|
||||
child: CupertinoSessionList(
|
||||
sections: [(title: 'Chats', sessions: sessions)],
|
||||
emptyMessage: null,
|
||||
duplicateTitles: const {},
|
||||
onOpen: (_) {},
|
||||
onRename: (_) {},
|
||||
onClose: (_) {},
|
||||
onReopen: (_) {},
|
||||
onStar: (_) {},
|
||||
onHide: (_) {},
|
||||
onClearSearch: null,
|
||||
isUnseen: isUnseen ?? (_) => false,
|
||||
errorFor: (_) => null,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
void _useNarrowText(WidgetTester tester) {
|
||||
tester.view.physicalSize = const Size(320, 640);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.platformDispatcher.textScaleFactorTestValue = 2;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||
}
|
||||
|
||||
/// The resolved style a text is painted with, after merging with the host's
|
||||
/// own `DefaultTextStyle`.
|
||||
TextStyle _styleOf(WidgetTester tester, String text) =>
|
||||
tester.renderObject<RenderParagraph>(find.text(text)).text.style!;
|
||||
|
||||
void main() {
|
||||
test('relative recency uses the web wording and never invents a time', () {
|
||||
final now = DateTime(2026, 10, 22, 12);
|
||||
final from = now.subtract;
|
||||
|
||||
expect(relativeChatSessionTime(null, now: now), '');
|
||||
expect(relativeChatSessionTime(0, now: now), '');
|
||||
expect(
|
||||
relativeChatSessionTime(now.millisecondsSinceEpoch, now: now),
|
||||
'just now',
|
||||
);
|
||||
expect(
|
||||
relativeChatSessionTime(
|
||||
from(const Duration(minutes: 5)).millisecondsSinceEpoch,
|
||||
now: now,
|
||||
),
|
||||
'5 min ago',
|
||||
);
|
||||
expect(
|
||||
relativeChatSessionTime(
|
||||
from(const Duration(hours: 3)).millisecondsSinceEpoch,
|
||||
now: now,
|
||||
),
|
||||
'3 hr ago',
|
||||
);
|
||||
expect(
|
||||
relativeChatSessionTime(
|
||||
from(const Duration(hours: 25)).millisecondsSinceEpoch,
|
||||
now: now,
|
||||
),
|
||||
'1 day ago',
|
||||
);
|
||||
expect(
|
||||
relativeChatSessionTime(
|
||||
from(const Duration(days: 3)).millisecondsSinceEpoch,
|
||||
now: now,
|
||||
),
|
||||
'3 days ago',
|
||||
);
|
||||
expect(
|
||||
relativeChatSessionTime(
|
||||
DateTime(2026, 10, 1, 9).millisecondsSinceEpoch,
|
||||
now: now,
|
||||
),
|
||||
'1 Oct',
|
||||
);
|
||||
// The web formats with `Intl.DateTimeFormat('en-GB', …)`, whose short
|
||||
// September is `Sept`; its own test asserts `12 Sept`.
|
||||
expect(
|
||||
relativeChatSessionTime(
|
||||
DateTime(2026, 9, 12, 9).millisecondsSinceEpoch,
|
||||
now: now,
|
||||
),
|
||||
'12 Sept',
|
||||
);
|
||||
});
|
||||
|
||||
test('meta and status come only from the row', () {
|
||||
expect(
|
||||
chatSessionMeta({'directory': '/work', 'model': 'model-a'}),
|
||||
'/work · model-a',
|
||||
);
|
||||
expect(chatSessionMeta({'directory': '/work'}), '/work');
|
||||
expect(chatSessionMeta({}), '');
|
||||
|
||||
expect(chatSessionRowStatus({}, unseen: false), isNull);
|
||||
expect(chatSessionRowStatus({}, unseen: true), 'New');
|
||||
// The web suppresses the streaming word; the row's activity icon carries it.
|
||||
expect(chatSessionRowStatus({'running': true}, unseen: true), isNull);
|
||||
expect(chatSessionRowStatus({'running': true}, unseen: false), isNull);
|
||||
expect(
|
||||
chatSessionRowStatus({'closed_at': '2026-01-01'}, unseen: true),
|
||||
'Closed',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('a row reads title, muted meta and trailing recency/unread', (
|
||||
tester,
|
||||
) async {
|
||||
final now = DateTime.now();
|
||||
final sessions = <JsonMap>[
|
||||
{
|
||||
'id': 's1',
|
||||
'title': 'Starred chat',
|
||||
'directory': '/work',
|
||||
'model': 'model-a',
|
||||
'updated_at': now
|
||||
.subtract(const Duration(minutes: 5))
|
||||
.millisecondsSinceEpoch,
|
||||
},
|
||||
{
|
||||
'id': 's2',
|
||||
'title': 'Open chat',
|
||||
'directory': '/work',
|
||||
'updated_at': now
|
||||
.subtract(const Duration(hours: 2, minutes: 30))
|
||||
.millisecondsSinceEpoch,
|
||||
},
|
||||
];
|
||||
await _pumpRows(
|
||||
tester,
|
||||
sessions,
|
||||
isUnseen: (session) => session['id'] == 's1',
|
||||
);
|
||||
|
||||
// The unread word trails the muted meta line; the recency trails the title.
|
||||
expect(find.text('Starred chat'), findsOneWidget);
|
||||
expect(find.text('/work · model-a'), findsOneWidget);
|
||||
expect(find.text('5 min ago'), findsOneWidget);
|
||||
expect(find.text('New'), findsOneWidget);
|
||||
expect(find.text('/work'), findsOneWidget);
|
||||
expect(find.text('2 hr ago'), findsOneWidget);
|
||||
|
||||
// The meta line keeps `CupertinoListTile`'s native 12pt subtitle style; it
|
||||
// must not be rendered at the title's body size. The colour-only style the
|
||||
// row passes merges with the tile's own `DefaultTextStyle`.
|
||||
final titleStyle = _styleOf(tester, 'Starred chat');
|
||||
final metaStyle = _styleOf(tester, '/work · model-a');
|
||||
expect(metaStyle.fontSize, lessThan(titleStyle.fontSize!));
|
||||
expect(metaStyle.fontSize, 12.0);
|
||||
expect(_styleOf(tester, 'New').fontSize, metaStyle.fontSize);
|
||||
|
||||
// Each session is still its own native tile with its own actions, so the
|
||||
// inset group draws the separator between them.
|
||||
expect(find.byType(CupertinoListTile), findsNWidgets(2));
|
||||
expect(find.byKey(const Key('chat-star-s1')), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-actions-s2')), findsOneWidget);
|
||||
expect(
|
||||
tester.getTopLeft(find.byKey(const Key('chat-row-s2'))).dy,
|
||||
greaterThan(
|
||||
tester.getBottomLeft(find.byKey(const Key('chat-row-s1'))).dy,
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('at 320px 2x the long title and meta ellipsise, the word does not', (
|
||||
tester,
|
||||
) async {
|
||||
_useNarrowText(tester);
|
||||
final now = DateTime.now();
|
||||
await _pumpRows(tester, [
|
||||
{
|
||||
'id': 's1',
|
||||
'title': 'A conversation title long enough to need an ellipsis',
|
||||
'directory': '/a/very/long/directory/that/must/ellipsise',
|
||||
'model': 'provider/an-extremely-long-recorded-model-id',
|
||||
'updated_at': now
|
||||
.subtract(const Duration(days: 3))
|
||||
.millisecondsSinceEpoch,
|
||||
},
|
||||
{
|
||||
'id': 'c1',
|
||||
'title': 'A closed conversation',
|
||||
'directory': '/work',
|
||||
'closed_at': '2026-01-01',
|
||||
},
|
||||
], isUnseen: (session) => session['id'] == 's1');
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
const title = 'A conversation title long enough to need an ellipsis';
|
||||
const meta =
|
||||
'/a/very/long/directory/that/must/ellipsise · '
|
||||
'provider/an-extremely-long-recorded-model-id';
|
||||
final titleParagraph = tester.renderObject<RenderParagraph>(
|
||||
find.text(title),
|
||||
);
|
||||
expect(titleParagraph.maxLines, 1);
|
||||
expect(titleParagraph.didExceedMaxLines, isTrue);
|
||||
final metaParagraph = tester.renderObject<RenderParagraph>(find.text(meta));
|
||||
expect(metaParagraph.maxLines, 1);
|
||||
expect(metaParagraph.didExceedMaxLines, isTrue);
|
||||
|
||||
// The state word is the row's only unread marker: at the smallest supported
|
||||
// surface with 2x text it stays whole (it is scaled down only when even the
|
||||
// full text column cannot hold it) and inside the tile's trailing edge.
|
||||
for (final row in ['s1', 'c1']) {
|
||||
final word = row == 's1' ? 'New' : 'Closed';
|
||||
final paragraph = tester.renderObject<RenderParagraph>(find.text(word));
|
||||
expect(paragraph.maxLines, 1);
|
||||
expect(paragraph.didExceedMaxLines, isFalse, reason: '$word is clipped');
|
||||
final rect = tester.getRect(find.text(word));
|
||||
expect(rect.width, greaterThan(0));
|
||||
expect(
|
||||
rect.right,
|
||||
lessThanOrEqualTo(
|
||||
tester.getRect(find.byKey(Key('chat-row-$row'))).right,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// The recency is supplementary, so it is the part that ellipsises here; it
|
||||
// still keeps its single line at the trailing edge of the title line.
|
||||
final recency = tester.renderObject<RenderParagraph>(
|
||||
find.text('3 days ago'),
|
||||
);
|
||||
expect(recency.maxLines, 1);
|
||||
expect(recency.didExceedMaxLines, isTrue);
|
||||
expect(
|
||||
(tester.getCenter(find.text(title)).dy -
|
||||
tester.getCenter(find.text('3 days ago')).dy)
|
||||
.abs(),
|
||||
lessThan(20),
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_list_material.dart';
|
||||
|
||||
/// The Android host: a Material grouped list with its native separators.
|
||||
Future<void> _pumpRows(
|
||||
WidgetTester tester,
|
||||
List<JsonMap> sessions, {
|
||||
bool Function(JsonMap)? isUnseen,
|
||||
String section = 'Chats',
|
||||
}) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(
|
||||
platform: TargetPlatform.android,
|
||||
brightness: Brightness.dark,
|
||||
),
|
||||
home: Scaffold(
|
||||
body: MaterialSessionList(
|
||||
sections: [(title: section, sessions: sessions)],
|
||||
emptyMessage: null,
|
||||
duplicateTitles: const {},
|
||||
onOpen: (_) {},
|
||||
onRename: (_) {},
|
||||
onClose: (_) {},
|
||||
onReopen: (_) {},
|
||||
onStar: (_) {},
|
||||
onHide: (_) {},
|
||||
onClearSearch: null,
|
||||
isUnseen: isUnseen ?? (_) => false,
|
||||
errorFor: (_) => null,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
void _useNarrowText(WidgetTester tester) {
|
||||
tester.view.physicalSize = const Size(320, 640);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.platformDispatcher.textScaleFactorTestValue = 2;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('a Material row reads title, muted meta and trailing recency', (
|
||||
tester,
|
||||
) async {
|
||||
final now = DateTime.now();
|
||||
await _pumpRows(tester, [
|
||||
{
|
||||
'id': 's1',
|
||||
'title': 'Starred chat',
|
||||
'directory': '/work',
|
||||
'model': 'model-a',
|
||||
'updated_at': now
|
||||
.subtract(const Duration(minutes: 5))
|
||||
.millisecondsSinceEpoch,
|
||||
},
|
||||
{
|
||||
'id': 's2',
|
||||
'title': 'Open chat',
|
||||
'directory': '/work',
|
||||
'updated_at': now
|
||||
.subtract(const Duration(hours: 2, minutes: 30))
|
||||
.millisecondsSinceEpoch,
|
||||
},
|
||||
], isUnseen: (session) => session['id'] == 's1');
|
||||
|
||||
expect(find.text('Starred chat'), findsOneWidget);
|
||||
expect(find.text('/work · model-a'), findsOneWidget);
|
||||
expect(find.text('5 min ago'), findsOneWidget);
|
||||
expect(find.text('New'), findsOneWidget);
|
||||
expect(find.text('/work'), findsOneWidget);
|
||||
expect(find.text('2 hr ago'), findsOneWidget);
|
||||
|
||||
// The meta line is the theme's muted colour, not the title colour.
|
||||
final meta = tester.widget<Text>(find.text('/work · model-a'));
|
||||
final context = tester.element(find.text('/work · model-a'));
|
||||
expect(meta.style?.color, Theme.of(context).colorScheme.onSurfaceVariant);
|
||||
|
||||
// Native Material separators sit between rows, not around the group.
|
||||
expect(find.byType(Divider), findsOneWidget);
|
||||
expect(
|
||||
tester.getTopLeft(find.byKey(const Key('chat-row-s2'))).dy,
|
||||
greaterThan(
|
||||
tester.getBottomLeft(find.byKey(const Key('chat-row-s1'))).dy,
|
||||
),
|
||||
);
|
||||
expect(find.byKey(const Key('chat-star-s1')), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-actions-s2')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('a closed Material row carries Closed on the row itself', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpRows(tester, [
|
||||
{
|
||||
'id': 'c1',
|
||||
'title': 'Closed chat',
|
||||
'directory': '/work',
|
||||
'closed_at': '2026-01-01',
|
||||
},
|
||||
], section: 'Closed');
|
||||
|
||||
// The section header also says Closed; the row's trailing word is its own.
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('chat-row-c1')),
|
||||
matching: find.text('Closed'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('New'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('at 320px 2x the Material row ellipsises text, not its word', (
|
||||
tester,
|
||||
) async {
|
||||
_useNarrowText(tester);
|
||||
final now = DateTime.now();
|
||||
await _pumpRows(tester, [
|
||||
{
|
||||
'id': 's1',
|
||||
'title': 'A conversation title long enough to need an ellipsis',
|
||||
'directory': '/a/very/long/directory/that/must/ellipsise',
|
||||
'model': 'provider/an-extremely-long-recorded-model-id',
|
||||
'updated_at': now
|
||||
.subtract(const Duration(days: 3))
|
||||
.millisecondsSinceEpoch,
|
||||
},
|
||||
{
|
||||
'id': 'c1',
|
||||
'title': 'A closed conversation',
|
||||
'directory': '/work',
|
||||
'closed_at': '2026-01-01',
|
||||
},
|
||||
], isUnseen: (session) => session['id'] == 's1');
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
const title = 'A conversation title long enough to need an ellipsis';
|
||||
const meta =
|
||||
'/a/very/long/directory/that/must/ellipsise · '
|
||||
'provider/an-extremely-long-recorded-model-id';
|
||||
final titleParagraph = tester.renderObject<RenderParagraph>(
|
||||
find.text(title),
|
||||
);
|
||||
expect(titleParagraph.maxLines, 1);
|
||||
expect(titleParagraph.didExceedMaxLines, isTrue);
|
||||
final metaParagraph = tester.renderObject<RenderParagraph>(find.text(meta));
|
||||
expect(metaParagraph.maxLines, 1);
|
||||
expect(metaParagraph.didExceedMaxLines, isTrue);
|
||||
|
||||
// `New`/`Closed` is the row's only unread marker; it stays whole at the
|
||||
// smallest supported surface with 2x text.
|
||||
for (final row in ['s1', 'c1']) {
|
||||
final word = row == 's1' ? 'New' : 'Closed';
|
||||
final paragraph = tester.renderObject<RenderParagraph>(find.text(word));
|
||||
expect(paragraph.maxLines, 1);
|
||||
expect(paragraph.didExceedMaxLines, isFalse, reason: '$word is clipped');
|
||||
final rect = tester.getRect(find.text(word));
|
||||
expect(rect.width, greaterThan(0));
|
||||
expect(
|
||||
rect.right,
|
||||
lessThanOrEqualTo(
|
||||
tester.getRect(find.byKey(Key('chat-row-$row'))).right,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Two lines: the title/recency line, then the muted meta line.
|
||||
expect(
|
||||
tester.getCenter(find.text(meta)).dy,
|
||||
greaterThan(tester.getCenter(find.text(title)).dy),
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -15,7 +15,23 @@ void main() {
|
||||
|
||||
expect(find.text('Starred'), findsOneWidget);
|
||||
expect(find.text('Chats'), findsNWidgets(2));
|
||||
expect(find.text('Closed'), findsOneWidget);
|
||||
// The Closed section header, and each closed row's trailing word.
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(widget) =>
|
||||
widget is ExpansionTile &&
|
||||
widget.title is Text &&
|
||||
(widget.title as Text).data == 'Closed',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('chat-row-s4')),
|
||||
matching: find.text('Closed'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Starred chat'), findsOneWidget);
|
||||
expect(find.text('Starred closed'), findsOneWidget);
|
||||
expect(find.text('Open chat'), findsOneWidget);
|
||||
|
||||
Reference in New Issue
Block a user