Place chat recency and actions beside row metadata
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_actions.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final width in [120.0, 360.0]) {
|
||||
testWidgets(
|
||||
'right-side recency/actions, Cupertino=$cupertino width=$width',
|
||||
(tester) async {
|
||||
final star = SessionStarButton(
|
||||
session: const {'id': 's'},
|
||||
onPressed: () {},
|
||||
);
|
||||
final more = SessionActionsButton(
|
||||
session: const {'id': 's'},
|
||||
onSelected: (_) {},
|
||||
);
|
||||
final row = Center(
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
child: ChatSessionRowContent(
|
||||
title: 'Chat title',
|
||||
status: null,
|
||||
recency: '5 min ago',
|
||||
meta: const ['opencode', 'model', '/work'],
|
||||
titleStyle: const TextStyle(fontSize: 17),
|
||||
metaStyle: const TextStyle(fontSize: 12),
|
||||
statusStyle: const TextStyle(fontSize: 12),
|
||||
actions: [
|
||||
KeyedSubtree(key: const Key('star'), child: star),
|
||||
KeyedSubtree(key: const Key('more'), child: more),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: row))
|
||||
: MaterialApp(home: Scaffold(body: row)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final backend = tester.getRect(find.text('opencode'));
|
||||
final time = tester.getRect(find.text('5 min ago'));
|
||||
final favorite = tester.getRect(find.byKey(const Key('star')));
|
||||
final menu = tester.getRect(find.byKey(const Key('more')));
|
||||
expect(time.left, greaterThanOrEqualTo(backend.right));
|
||||
expect(
|
||||
time.top,
|
||||
closeTo(backend.top, 0.1),
|
||||
reason: 'Timestamp belongs beside metadata, not below it',
|
||||
);
|
||||
expect(favorite.left, greaterThanOrEqualTo(backend.right));
|
||||
expect(menu.left, greaterThanOrEqualTo(backend.right));
|
||||
if (width == 360) {
|
||||
expect(
|
||||
favorite.top,
|
||||
lessThan(tester.getRect(find.text('/work')).bottom),
|
||||
);
|
||||
expect(menu.top, closeTo(favorite.top, 0.1));
|
||||
}
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user