Merge 2b.4: chat details and file details as dialogs on desktop
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -11,11 +10,6 @@ Widget _host(Widget child) => MaterialApp(
|
||||
home: Scaffold(body: child),
|
||||
);
|
||||
|
||||
Widget _cupertinoHost(Widget child) => CupertinoApp(
|
||||
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
||||
home: CupertinoPageScaffold(child: child),
|
||||
);
|
||||
|
||||
JsonMap _usageFrame(JsonMap usage) => {
|
||||
'session_id': 's',
|
||||
'kind': 'usage',
|
||||
@@ -24,7 +18,7 @@ JsonMap _usageFrame(JsonMap usage) => {
|
||||
|
||||
Future<FakeChatGateway> _thread(
|
||||
WidgetTester tester, {
|
||||
bool cupertino = false,
|
||||
Size size = const Size(800, 600),
|
||||
}) async {
|
||||
final gateway = FakeChatGateway();
|
||||
addTearDown(gateway.close);
|
||||
@@ -34,7 +28,10 @@ Future<FakeChatGateway> _thread(
|
||||
sessionId: 's',
|
||||
onBack: () {},
|
||||
);
|
||||
await tester.pumpWidget(cupertino ? _cupertinoHost(thread) : _host(thread));
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(_host(thread));
|
||||
await tester.pumpAndSettle();
|
||||
return gateway;
|
||||
}
|
||||
@@ -146,9 +143,21 @@ void main() {
|
||||
expect(find.text('\$0.0000'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('the native sheet dismisses from Done and the barrier', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('wide details use a dialog', (tester) async {
|
||||
await _thread(tester, size: const Size(1280, 800));
|
||||
await _openInfo(tester);
|
||||
expect(find.byType(Dialog), findsOneWidget);
|
||||
expect(find.byType(BottomSheet), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('phone details use a bottom sheet', (tester) async {
|
||||
await _thread(tester, size: const Size(430, 900));
|
||||
await _openInfo(tester);
|
||||
expect(find.byType(BottomSheet), findsOneWidget);
|
||||
expect(find.byType(Dialog), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('details dismiss from Done and the barrier', (tester) async {
|
||||
final gateway = await _thread(tester);
|
||||
gateway.emitEvent(_usageFrame({'scope': 'session', 'total_tokens': 5}));
|
||||
await tester.pump();
|
||||
@@ -170,22 +179,4 @@ void main() {
|
||||
expect(find.byKey(const Key('chat-info-sheet')), findsNothing);
|
||||
expect(find.byKey(const Key('chat-info')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('the Cupertino host opens and closes the native popup', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = await _thread(tester, cupertino: true);
|
||||
gateway.emitEvent(_usageFrame({'scope': 'session', 'total_tokens': 42}));
|
||||
await tester.pump();
|
||||
|
||||
await _openInfo(tester);
|
||||
expect(find.text('Chat information'), findsOneWidget);
|
||||
expect(find.text('Done'), findsOneWidget);
|
||||
expect(find.text('42'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-info-close')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('chat-info-sheet')), findsNothing);
|
||||
expect(find.byKey(const Key('chat-info')), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_external_open.dart';
|
||||
import 'package:pipelines_app/features/chat/data/directory_listing.dart';
|
||||
import 'package:pipelines_app/features/chat/files/files_details.dart';
|
||||
|
||||
const _entry = DirectoryEntry(
|
||||
name: 'report.txt',
|
||||
path: '/home/report.txt',
|
||||
isDir: false,
|
||||
isGitRepo: false,
|
||||
hidden: false,
|
||||
size: 1024,
|
||||
modified: '2026-01-02T03:04:05Z',
|
||||
);
|
||||
|
||||
Widget _app() {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) => TextButton(
|
||||
onPressed: () => showFileDetails(
|
||||
context,
|
||||
entry: _entry,
|
||||
urls: null,
|
||||
download: null,
|
||||
openExternal: ((_) async => false) as ArtifactExternalOpen,
|
||||
),
|
||||
child: const Text('Details'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _size(WidgetTester tester, Size size) {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('wide file details use a dialog', (tester) async {
|
||||
_size(tester, const Size(1280, 800));
|
||||
await tester.pumpWidget(_app());
|
||||
await tester.tap(find.text('Details'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(Dialog), findsOneWidget);
|
||||
expect(find.byType(BottomSheet), findsNothing);
|
||||
expect(find.text('report.txt'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('phone file details use a bottom sheet', (tester) async {
|
||||
_size(tester, const Size(430, 900));
|
||||
await tester.pumpWidget(_app());
|
||||
await tester.tap(find.text('Details'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(BottomSheet), findsOneWidget);
|
||||
expect(find.byType(Dialog), findsNothing);
|
||||
});
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:pipelines_app/features/chat/files/files_preview.dart';
|
||||
import 'package:pipelines_app/features/artifacts/domain/artifact_kind.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -243,31 +242,6 @@ void main() {
|
||||
expect(filesThumbnailDecodeSize(10), 224);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
testWidgets('Cupertino unknown file and menu use native controls', (
|
||||
tester,
|
||||
) async {
|
||||
final controller = FilesController(
|
||||
gateway: Gateway(),
|
||||
initialPath: '/home/demo',
|
||||
);
|
||||
addTearDown(controller.dispose);
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
||||
home: CupertinoPageScaffold(child: FilesPanel(controller: controller)),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
Theme.of(tester.element(find.byType(ListTile).first)).brightness,
|
||||
Brightness.dark,
|
||||
);
|
||||
await tester.tap(find.text('archive.zip'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Download'), findsOneWidget);
|
||||
expect(find.byType(CupertinoButton), findsWidgets);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
testWidgets('PDF external-open failures keep download available', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user