Merge branch 'main' of https://git.a-wan.net/alan/pipelines
# Conflicts: # app/lib/features/chat/ui/transcript/chat_markdown_view.dart
This commit is contained in:
@@ -149,7 +149,7 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('code and table labels identify the scrollable region', (
|
||||
testWidgets('a code block scrolls sideways while a table wraps', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
@@ -167,9 +167,14 @@ void main() {
|
||||
);
|
||||
expect(
|
||||
find.bySemanticsLabel('Horizontally scrollable table'),
|
||||
findsOneWidget,
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.text('Scroll horizontally'), findsOneWidget);
|
||||
final viewport = tester.getRect(find.byType(ChatMarkdownView));
|
||||
expect(
|
||||
tester.getRect(find.byType(Table)).right,
|
||||
lessThanOrEqualTo(viewport.right),
|
||||
);
|
||||
expect(find.text('Scroll horizontally'), findsNWidgets(2));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/transcript/chat_markdown_view.dart';
|
||||
|
||||
import 'chat_markdown_test_support.dart';
|
||||
|
||||
void main() {
|
||||
Future<void> pumpTable(WidgetTester tester, String text) async {
|
||||
await phoneViewport(tester);
|
||||
await tester.pumpWidget(markdownHost(ChatMarkdownView(text: text)));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
|
||||
Rect tableRect(WidgetTester tester) => tester.getRect(find.byType(Table));
|
||||
// The phone viewport is 390 logical pixels wide.
|
||||
const screenRight = 390.0;
|
||||
|
||||
testWidgets('a wide table wraps its cells inside the transcript', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpTable(
|
||||
tester,
|
||||
'| Item | Description | Status |\n| --- | --- | --- |\n'
|
||||
'| one | ${List.filled(30, 'word').join(' ')} | done |',
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(ChatMarkdownView),
|
||||
matching: find.byType(Scrollable),
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
expect(tableRect(tester).right, lessThanOrEqualTo(screenRight));
|
||||
final description = tester.getSize(find.textContaining('word word'));
|
||||
final status = tester.getSize(find.text('done'));
|
||||
// The long cell wrapped onto several lines; the short one did not.
|
||||
expect(description.height, greaterThan(status.height * 2));
|
||||
});
|
||||
|
||||
testWidgets('an unbreakable token breaks inside its cell', (tester) async {
|
||||
await pumpTable(
|
||||
tester,
|
||||
'| Path | Note |\n| --- | --- |\n'
|
||||
'| ${'a' * 200} | ${'b' * 200} |',
|
||||
);
|
||||
expect(tableRect(tester).right, lessThanOrEqualTo(screenRight));
|
||||
});
|
||||
|
||||
testWidgets('a narrow table keeps its content width', (tester) async {
|
||||
await pumpTable(tester, '| a | b |\n| --- | --- |\n| 1 | 2 |');
|
||||
expect(tableRect(tester).width, lessThan(screenRight / 2));
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/changes/changes.dart';
|
||||
import 'package:pipelines_app/features/chat/domain/chat_shown_items.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/transcript/shown/chat_shown_card.dart';
|
||||
|
||||
JsonMap _file(String path, String kind, String patch) => {
|
||||
'path': path,
|
||||
'kind': kind,
|
||||
'patch': patch,
|
||||
};
|
||||
|
||||
JsonMap _item({
|
||||
List<JsonMap>? files,
|
||||
String status = 'complete',
|
||||
int omitted = 0,
|
||||
bool expired = false,
|
||||
String base = 'main',
|
||||
}) {
|
||||
final list =
|
||||
files ??
|
||||
[
|
||||
_file(
|
||||
'app/lib/a.dart',
|
||||
'modified',
|
||||
'--- a/app/lib/a.dart\n+++ b/app/lib/a.dart\n@@ -1,2 +1,2 @@\n one\n-two\n+TWO\n',
|
||||
),
|
||||
_file('docs/new.md', 'added', '@@ -0,0 +1,2 @@\n+# New\n+text\n'),
|
||||
];
|
||||
return {
|
||||
'id': 'd1',
|
||||
'kind': 'diff',
|
||||
'created_at': 1,
|
||||
'title': 'PR preview',
|
||||
'expired': expired,
|
||||
'diff': {
|
||||
'repo': '/home/op/repos/pipelines',
|
||||
'base': base,
|
||||
'base_commit': 'abc123def456',
|
||||
'head': 'feature',
|
||||
'files': list.length + omitted,
|
||||
'additions': 3,
|
||||
'deletions': 1,
|
||||
if (!expired)
|
||||
'changes': {
|
||||
'status': status,
|
||||
'files': list,
|
||||
'omitted': omitted,
|
||||
'skipped': 0,
|
||||
if (status != 'complete')
|
||||
'diagnostic': 'some patches were left out by the size limit.',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Future<void> _pump(WidgetTester tester, JsonMap item) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: ChatShownCard(
|
||||
row: {'kind': chatShownRowKind, 'item': item},
|
||||
endpoint: 'ws://127.0.0.1:1/connect',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
void main() {
|
||||
test('diff items are a recorded kind and show_diff calls are hidden', () {
|
||||
expect(chatShownKinds, contains('diff'));
|
||||
expect(
|
||||
chatPipelinesToolRepresented({
|
||||
'type': 'tool',
|
||||
'name': 'mcp__pipelines__show_diff',
|
||||
'state': {'status': 'completed'},
|
||||
}),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('a diff card lists its files and opens the diff viewer', (
|
||||
tester,
|
||||
) async {
|
||||
await _pump(tester, _item());
|
||||
expect(find.text('PR preview'), findsOneWidget);
|
||||
expect(
|
||||
find.text('pipelines · feature vs main · with uncommitted work'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('2 files changed +3 -1'), findsOneWidget);
|
||||
expect(find.text('app/lib/a.dart'), findsOneWidget);
|
||||
expect(find.text('docs/new.md'), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-shown-diff-partial')), findsNothing);
|
||||
|
||||
await tester.tap(find.text('app/lib/a.dart'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(FileDiffPage), findsOneWidget);
|
||||
expect(find.textContaining('TWO', findRichText: true), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('a long diff lists the first files until Show all', (
|
||||
tester,
|
||||
) async {
|
||||
final files = [
|
||||
for (var i = 0; i < 12; i++)
|
||||
_file('f$i.txt', 'added', '@@ -0,0 +1 @@\n+x\n'),
|
||||
];
|
||||
await _pump(tester, _item(files: files));
|
||||
expect(find.text('f7.txt'), findsOneWidget);
|
||||
expect(find.text('f8.txt'), findsNothing);
|
||||
await tester.ensureVisible(find.byKey(const Key('chat-shown-diff-all')));
|
||||
await tester.tap(find.byKey(const Key('chat-shown-diff-all')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('f11.txt'), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-shown-diff-all')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('a partial diff says what was left out', (tester) async {
|
||||
await _pump(tester, _item(status: 'partial', omitted: 3));
|
||||
expect(find.byKey(const Key('chat-shown-diff-partial')), findsOneWidget);
|
||||
expect(find.text('3 more files are not listed.'), findsOneWidget);
|
||||
expect(find.text('5 files changed +3 -1'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('an expired diff keeps its summary and says so', (tester) async {
|
||||
await _pump(tester, _item(expired: true));
|
||||
expect(find.text('2 files changed +3 -1'), findsOneWidget);
|
||||
expect(find.text('This diff is no longer retained'), findsOneWidget);
|
||||
expect(find.byType(ChangeFileRow), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('without a base it describes the uncommitted changes', (
|
||||
tester,
|
||||
) async {
|
||||
await _pump(tester, _item(base: ''));
|
||||
expect(
|
||||
find.text('pipelines · feature · uncommitted changes'),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user