Merge branch 'worktree-agent-ac4392b2750312e98'
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/chat/screen.dart';
|
||||
@@ -175,7 +176,8 @@ void main() {
|
||||
final background = appLightTheme().scaffoldBackgroundColor;
|
||||
expect(origin.color, isNot(background), reason: 'the chat colour tints it');
|
||||
expect(origin.color.a, 1);
|
||||
expect(origin.markerWidth, 10);
|
||||
// The open row's one bar, as every list marks its open row.
|
||||
expect(origin.markerWidth, kAppListRowBarWidth);
|
||||
expect(origin.marker, isNotNull);
|
||||
});
|
||||
|
||||
|
||||
@@ -58,13 +58,17 @@ void main() {
|
||||
of: row,
|
||||
matching: find.byKey(appListRowSurfaceKey),
|
||||
);
|
||||
// The lists' shared open-row style: the tonal fill and one bar.
|
||||
final color = tester.widget<Material>(surface).color;
|
||||
expect(color, const Color(0x00000000));
|
||||
final highlight = tester.widget<AnimatedContainer>(
|
||||
find.byKey(ValueKey('chat-visibility-$id')),
|
||||
final context = tester.element(row);
|
||||
expect(color == AppListRow.selectedColor(context), active);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(ValueKey('chat-visibility-$id')),
|
||||
matching: find.byKey(appListRowSelectionKey),
|
||||
),
|
||||
active ? findsOneWidget : findsNothing,
|
||||
);
|
||||
final fill = (highlight.decoration as BoxDecoration).color;
|
||||
expect(fill != null && fill.a > 0, active);
|
||||
}
|
||||
|
||||
expectRow('a', true);
|
||||
|
||||
@@ -210,16 +210,16 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
final surface = tester.widget<Material>(find.byKey(appListRowSurfaceKey));
|
||||
expect(surface.color, Colors.transparent);
|
||||
final highlight = tester.widget<AnimatedContainer>(
|
||||
find.byKey(const ValueKey('chat-visibility-s1')),
|
||||
);
|
||||
// The selected row is filled in its own colour.
|
||||
final fill = (highlight.decoration as BoxDecoration).color!;
|
||||
expect(fill.a, greaterThan(0));
|
||||
// The shared open-row style: the tonal fill, and its one bar in the
|
||||
// chat's own colour.
|
||||
final context = tester.element(find.byType(ChatSessionRow));
|
||||
expect(fill.withValues(alpha: 1), chatColorShade(context, 'amber'));
|
||||
final surface = tester.widget<Material>(find.byKey(appListRowSurfaceKey));
|
||||
expect(surface.color, AppListRow.selectedColor(context));
|
||||
final bar = tester.widget<DecoratedBox>(find.byKey(appListRowSelectionKey));
|
||||
final side =
|
||||
((bar.decoration as BoxDecoration).border as BorderDirectional).start;
|
||||
expect(side.color, chatColorShade(context, 'amber'));
|
||||
expect(side.width, kAppListRowBarWidth);
|
||||
expect(find.byKey(appListRowAccentKey), findsNothing);
|
||||
expect(find.byKey(const ValueKey('chat-visibility-s1')), findsOneWidget);
|
||||
});
|
||||
|
||||
@@ -25,9 +25,20 @@ BorderSide edge(WidgetTester tester, String id) {
|
||||
return ((box.decoration as BoxDecoration).border as BorderDirectional).start;
|
||||
}
|
||||
|
||||
/// The shared open-row bar [AppListRow] draws on the selected row of [id].
|
||||
BorderSide? selectionBar(WidgetTester tester, String id) {
|
||||
final bar = find.descendant(
|
||||
of: find.byKey(ValueKey('chat-visibility-$id')),
|
||||
matching: find.byKey(appListRowSelectionKey),
|
||||
);
|
||||
if (bar.evaluate().isEmpty) return null;
|
||||
final box = tester.widget<DecoratedBox>(bar);
|
||||
return ((box.decoration as BoxDecoration).border as BorderDirectional).start;
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'only visible chats have an edge; active edge widens continuously',
|
||||
'visible chats have a thin edge; the open chat has the shared selection',
|
||||
(tester) async {
|
||||
tester.platformDispatcher.accessibilityFeaturesTestValue =
|
||||
const FakeAccessibilityFeatures(disableAnimations: false);
|
||||
@@ -72,19 +83,25 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
// A selected chat not shown in a pane wears only the shared selection.
|
||||
expect(edge(tester, 'off').style, BorderStyle.none);
|
||||
expect(selectionBar(tester, 'off')!.width, kAppListRowBarWidth);
|
||||
// A chat visible elsewhere keeps its thin edge.
|
||||
expect(edge(tester, 'on').width, 3);
|
||||
expect(selectionBar(tester, 'on'), isNull);
|
||||
expect(find.byKey(appListRowAccentKey), findsNothing);
|
||||
update(() => active = true);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
expect(edge(tester, 'on').width, greaterThan(3));
|
||||
expect(edge(tester, 'on').width, lessThan(8));
|
||||
await tester.pumpAndSettle();
|
||||
expect(edge(tester, 'on').width, 8);
|
||||
// Opened, it is marked exactly like any open row: one bar in the
|
||||
// chat's colour over the tonal fill, and no second edge.
|
||||
expect(edge(tester, 'on').style, BorderStyle.none);
|
||||
final bar = selectionBar(tester, 'on')!;
|
||||
expect(bar.width, kAppListRowBarWidth);
|
||||
expect(bar.color, isNot(Colors.transparent));
|
||||
update(() => active = false);
|
||||
await tester.pumpAndSettle();
|
||||
expect(edge(tester, 'on').width, 3);
|
||||
expect(selectionBar(tester, 'on'), isNull);
|
||||
},
|
||||
);
|
||||
testWidgets('compact chats keep identity colours and visible/active edges', (
|
||||
@@ -128,7 +145,18 @@ void main() {
|
||||
await tester.tap(find.byTooltip('New chat'));
|
||||
expect(newChatPressed, isTrue);
|
||||
expect(find.byTooltip('Expand chat list'), findsOneWidget);
|
||||
expect(edge(tester, 'a').width, 8);
|
||||
// The open chat: no second edge, the shared fill and bar instead.
|
||||
expect(edge(tester, 'a').style, BorderStyle.none);
|
||||
final open = tester
|
||||
.widgetList<AnimatedContainer>(
|
||||
find.descendant(
|
||||
of: find.byKey(const ValueKey('chat-visibility-a')),
|
||||
matching: find.byType(AnimatedContainer),
|
||||
),
|
||||
)
|
||||
.singleWhere((box) => box.foregroundDecoration != null);
|
||||
final bar = (open.foregroundDecoration as BoxDecoration).border;
|
||||
expect((bar as BorderDirectional).start.width, kAppListRowBarWidth);
|
||||
expect(edge(tester, 'b').width, 3);
|
||||
expect(edge(tester, 'c').style, BorderStyle.none);
|
||||
final avatars = tester
|
||||
|
||||
@@ -48,31 +48,36 @@ void main() {
|
||||
.setMockMethodCallHandler(SystemChannels.platform, null),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'fenced code reveals Copy without shifting and copies exact whitespace',
|
||||
(tester) async {
|
||||
const code = ' final x = 1;\n\tkeep spaces ';
|
||||
await tester.pumpWidget(_host('```dart\n$code\n```'));
|
||||
await tester.pumpAndSettle();
|
||||
final before = tester.getTopLeft(find.text(code));
|
||||
expect(find.text('Copy').hitTestable(), findsNothing);
|
||||
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
|
||||
await mouse.addPointer(location: const Offset(1, 1));
|
||||
await mouse.moveTo(tester.getCenter(find.text(code)));
|
||||
await tester.pump();
|
||||
expect(find.text('Copy').hitTestable(), findsOneWidget);
|
||||
expect(tester.getTopLeft(find.text(code)), before);
|
||||
await tester.tap(find.text('Copy').hitTestable());
|
||||
await tester.pump();
|
||||
expect(copied, code);
|
||||
expect(find.text('Copied').hitTestable(), findsOneWidget);
|
||||
await mouse.moveTo(const Offset(1, 1));
|
||||
await tester.pump();
|
||||
expect(find.text('Copied').hitTestable(), findsNothing);
|
||||
await mouse.removePointer();
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
},
|
||||
);
|
||||
testWidgets('fenced code has a header strip with its language and Copy', (
|
||||
tester,
|
||||
) async {
|
||||
const code = ' final x = 1;\n\tkeep spaces ';
|
||||
await tester.pumpWidget(_host('```dart\n$code\n```'));
|
||||
await tester.pumpAndSettle();
|
||||
// One framed block: the header strip (label and Copy) sits on top of
|
||||
// the code, inside the block, and Copy needs no hover (touch has none).
|
||||
final header = tester.getRect(find.byKey(const Key('chat-code-header')));
|
||||
final block = tester.getRect(find.byKey(const Key('chat-code-body')));
|
||||
final label = tester.getRect(find.text('dart'));
|
||||
final copy = tester.getRect(find.text('Copy').hitTestable());
|
||||
expect(header.top, block.top);
|
||||
expect(header.contains(label.center), isTrue);
|
||||
expect(header.contains(copy.center), isTrue);
|
||||
expect(tester.getTopLeft(find.text(code)).dy, greaterThan(header.bottom));
|
||||
expect(block.contains(tester.getCenter(find.text(code))), isTrue);
|
||||
final before = tester.getTopLeft(find.text(code));
|
||||
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
|
||||
await mouse.addPointer(location: const Offset(1, 1));
|
||||
await mouse.moveTo(tester.getCenter(find.text(code)));
|
||||
await tester.pump();
|
||||
expect(tester.getTopLeft(find.text(code)), before);
|
||||
await tester.tap(find.text('Copy').hitTestable());
|
||||
await tester.pump();
|
||||
expect(copied, code);
|
||||
expect(find.text('Copied').hitTestable(), findsOneWidget);
|
||||
await mouse.removePointer();
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'inline spans retain selection, hover transfer and copy the right raw snippet',
|
||||
@@ -168,11 +173,11 @@ void main() {
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
});
|
||||
|
||||
testWidgets('keyboard focus exposes the reserved block action', (
|
||||
testWidgets('the block action is reachable from the keyboard', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(_host('```text\nraw\n```'));
|
||||
expect(find.text('Copy').hitTestable(), findsNothing);
|
||||
expect(find.text('Copy').hitTestable(), findsOneWidget);
|
||||
// The selectable transcript itself is the first focus stop.
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
|
||||
await tester.pump();
|
||||
|
||||
@@ -45,6 +45,9 @@ Widget _host({
|
||||
);
|
||||
}
|
||||
|
||||
/// The chevron over the faded side with more content.
|
||||
Finder _more(String side) => find.byKey(Key('chat-horizontal-more-$side'));
|
||||
|
||||
ScrollController _controller(WidgetTester tester) =>
|
||||
tester.widget<Scrollbar>(find.byType(Scrollbar)).controller!;
|
||||
|
||||
@@ -55,14 +58,16 @@ void main() {
|
||||
(tester) async {
|
||||
await tester.pumpWidget(_host(brightness: brightness));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Scroll horizontally'), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-horizontal-fade')), findsOneWidget);
|
||||
final controller = _controller(tester);
|
||||
expect(controller.position.maxScrollExtent, 640);
|
||||
expect(
|
||||
tester.widget<Scrollbar>(find.byType(Scrollbar)).thumbVisibility,
|
||||
isTrue,
|
||||
);
|
||||
expect(find.byIcon(Icons.arrow_forward), findsOneWidget);
|
||||
// More content to the right: that side fades under a chevron.
|
||||
expect(_more('right'), findsOneWidget);
|
||||
expect(_more('left'), findsNothing);
|
||||
final focus = tester
|
||||
.widgetList<Focus>(find.byType(Focus))
|
||||
.firstWhere(
|
||||
@@ -73,15 +78,17 @@ void main() {
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.offset, 80);
|
||||
expect(find.byIcon(Icons.swap_horiz), findsOneWidget);
|
||||
expect(_more('left'), findsOneWidget);
|
||||
expect(_more('right'), findsOneWidget);
|
||||
controller.jumpTo(controller.position.maxScrollExtent);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byIcon(Icons.arrow_back), findsOneWidget);
|
||||
expect(_more('left'), findsOneWidget);
|
||||
expect(_more('right'), findsNothing);
|
||||
await tester.pumpWidget(
|
||||
_host(brightness: brightness, contentWidth: 120),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Scroll horizontally'), findsNothing);
|
||||
expect(find.byKey(const Key('chat-horizontal-fade')), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
@@ -92,9 +99,10 @@ void main() {
|
||||
(tester) async {
|
||||
await tester.pumpWidget(_host(direction: TextDirection.rtl));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byIcon(Icons.arrow_back), findsOneWidget);
|
||||
expect(_more('left'), findsOneWidget);
|
||||
expect(_more('right'), findsNothing);
|
||||
expect(
|
||||
tester.widget<Icon>(find.byIcon(Icons.arrow_back)).textDirection,
|
||||
tester.widget<Icon>(_more('left')).textDirection,
|
||||
TextDirection.ltr,
|
||||
);
|
||||
final controller = _controller(tester);
|
||||
@@ -169,7 +177,7 @@ void main() {
|
||||
find.bySemanticsLabel('Horizontally scrollable table'),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.text('Scroll horizontally'), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-horizontal-fade')), findsOneWidget);
|
||||
final viewport = tester.getRect(find.byType(ChatMarkdownView));
|
||||
expect(
|
||||
tester.getRect(find.byType(Table)).right,
|
||||
|
||||
@@ -27,7 +27,7 @@ void main() {
|
||||
'| No | Text | Ok |\n| --- | --- | --- |\n'
|
||||
'| one | ${List.filled(30, 'word').join(' ')} | done |',
|
||||
);
|
||||
expect(find.text('Scroll horizontally'), findsNothing);
|
||||
expect(find.byKey(const Key('chat-horizontal-fade')), findsNothing);
|
||||
expect(tableRect(tester).right, lessThanOrEqualTo(screenRight));
|
||||
final description = tester.getSize(find.textContaining('word word'));
|
||||
final status = tester.getSize(find.text('done'));
|
||||
@@ -55,7 +55,7 @@ void main() {
|
||||
'| --- | --- | --- | --- | --- | --- | --- |\n'
|
||||
'| a b | c d | e f | g h | i j | k l | m n |',
|
||||
);
|
||||
expect(find.text('Scroll horizontally'), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-horizontal-fade')), findsOneWidget);
|
||||
expect(
|
||||
find.bySemanticsLabel('Horizontally scrollable table'),
|
||||
findsOneWidget,
|
||||
@@ -76,7 +76,7 @@ void main() {
|
||||
'| Column | Notes |\n| --- | --- |\n'
|
||||
'| x | ${List.filled(40, 'note').join(' ')} |',
|
||||
);
|
||||
expect(find.text('Scroll horizontally'), findsNothing);
|
||||
expect(find.byKey(const Key('chat-horizontal-fade')), findsNothing);
|
||||
expect(tableRect(tester).right, lessThanOrEqualTo(screenRight));
|
||||
final header = tester.getSize(find.text('Column')).height;
|
||||
expect(header, tester.getSize(find.text('x')).height);
|
||||
|
||||
Reference in New Issue
Block a user