Separate chat identity from pane state and retain compact attention facts
This commit is contained in:
@@ -110,7 +110,7 @@ void main() {
|
||||
expect(tooltip.message, 'Background tasks running (2)');
|
||||
expect(tooltip.triggerMode, TooltipTriggerMode.manual);
|
||||
expect(
|
||||
find.descendant(of: _badge('bg'), matching: find.byIcon(Icons.pending)),
|
||||
find.descendant(of: _badge('bg'), matching: find.text('2')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
@@ -177,17 +177,16 @@ void main() {
|
||||
expect(_badge('s1'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('the Cupertino host draws its own glyph', (tester) async {
|
||||
testWidgets('the Cupertino host shows the background task count', (
|
||||
tester,
|
||||
) async {
|
||||
final fake = FakeChatGateway()
|
||||
..sessionsReply = {
|
||||
'chat_sessions': [_row('bg', activity: _activity(tasks: 1))],
|
||||
};
|
||||
await _pump(tester, fake, cupertino: true);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: _badge('bg'),
|
||||
matching: find.byIcon(CupertinoIcons.ellipsis_circle_fill),
|
||||
),
|
||||
find.descendant(of: _badge('bg'), matching: find.text('1')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(_label(1), findsOneWidget);
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
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/chat_session_state.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_color_palette.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_compact_sidebar.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_controller.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_body.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_session_local.dart';
|
||||
import 'package:pipelines_app/features/chat/data/chat_repository.dart';
|
||||
import 'fake_chat_gateway.dart';
|
||||
import 'chat_test_harness.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('state is readable without identity color at narrow large text', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(320, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: MediaQuery(
|
||||
data: const MediaQueryData(textScaler: TextScaler.linear(2)),
|
||||
child: Scaffold(
|
||||
body: ChatSessionRow(
|
||||
session: const {
|
||||
'id': 'a',
|
||||
'title': 'Task',
|
||||
'color': 'red',
|
||||
'running': true,
|
||||
'background_tasks': 2,
|
||||
'model': 'model',
|
||||
'directory': '/work',
|
||||
},
|
||||
selected: true,
|
||||
visible: true,
|
||||
unseen: true,
|
||||
onOpen: (_) {},
|
||||
onAction: (_) {},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
for (final text in ['Active', 'Working', '2 background', 'New']) {
|
||||
expect(find.text(text), findsOneWidget);
|
||||
}
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'compact rail retains facts in badges and accessible full labels',
|
||||
(tester) async {
|
||||
final gateway = FakeChatGateway()
|
||||
..sessionsReply = {
|
||||
'chat_sessions': [
|
||||
{
|
||||
'id': 'a',
|
||||
'title': 'Alpha review',
|
||||
'directory': '/work/alpha',
|
||||
'model': 'model-a',
|
||||
'activity': {'background_tasks': 2, 'seq': 1},
|
||||
},
|
||||
],
|
||||
};
|
||||
final controller = ChatSessionsController(
|
||||
ChatRepository(gateway),
|
||||
localStore: MemoryChatSessionLocalStore(
|
||||
const ChatSessionLocal(unseen: ['a']),
|
||||
),
|
||||
);
|
||||
final folds = ChatSectionFolds();
|
||||
addTearDown(controller.dispose);
|
||||
addTearDown(folds.dispose);
|
||||
addTearDown(gateway.pushed.close);
|
||||
await controller.refresh();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: ChatCompactSidebar(
|
||||
controller: controller,
|
||||
folds: folds,
|
||||
activeSessionId: null,
|
||||
visibleSessionIds: const {'a'},
|
||||
onOpen: (_) {},
|
||||
onExpand: () {},
|
||||
navigation: const Text('Destinations'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Expand'), findsOneWidget);
|
||||
expect(find.text('Destinations'), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-row-background')), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-compact-unread')), findsOneWidget);
|
||||
final tooltip = tester
|
||||
.widgetList<Tooltip>(find.byType(Tooltip))
|
||||
.firstWhere((t) => t.message!.contains('Alpha review'));
|
||||
expect(tooltip.message, contains('model-a · /work/alpha'));
|
||||
expect(tooltip.message, contains('Background tasks running (2)'));
|
||||
expect(tooltip.message, contains('New messages'));
|
||||
expect(tooltip.message, contains('Visible chat'));
|
||||
},
|
||||
);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final brightness in Brightness.values) {
|
||||
testWidgets(
|
||||
'native metadata and state contrast on tinted rows $cupertino $brightness',
|
||||
(tester) async {
|
||||
late BuildContext context;
|
||||
final theme = ThemeData(brightness: brightness);
|
||||
final body = Builder(
|
||||
builder: (value) {
|
||||
context = value;
|
||||
return const SizedBox();
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
theme: CupertinoThemeData(brightness: brightness),
|
||||
home: body,
|
||||
)
|
||||
: MaterialApp(theme: theme, home: body),
|
||||
);
|
||||
final surface = cupertino
|
||||
? CupertinoDynamicColor.resolve(
|
||||
CupertinoTheme.of(context).scaffoldBackgroundColor,
|
||||
context,
|
||||
)
|
||||
: theme.colorScheme.surface;
|
||||
for (final name in [
|
||||
'red',
|
||||
'orange',
|
||||
'amber',
|
||||
'green',
|
||||
'teal',
|
||||
'blue',
|
||||
'purple',
|
||||
'pink',
|
||||
]) {
|
||||
final color = chatColorShade(context, name)!;
|
||||
final background = Color.alphaBlend(
|
||||
color.withValues(
|
||||
alpha: brightness == Brightness.dark ? .30 : .22,
|
||||
),
|
||||
surface,
|
||||
);
|
||||
for (final foreground in [
|
||||
chatStateForeground(context),
|
||||
chatMetadataForeground(context),
|
||||
]) {
|
||||
final rendered = Color.alphaBlend(foreground, background);
|
||||
final a = rendered.computeLuminance(),
|
||||
b = background.computeLuminance();
|
||||
final ratio = (a > b
|
||||
? (a + .05) / (b + .05)
|
||||
: (b + .05) / (a + .05));
|
||||
expect(
|
||||
ratio,
|
||||
greaterThanOrEqualTo(4.5),
|
||||
reason: '$name metadata contrast',
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user