Merge commit '591e1eec3a69099d7ae95ddcdd07d727b4bdeb27' into pipelines/run-20261111-0432-cupertino-out-pipelines-56b8

This commit is contained in:
2026-11-11 04:55:37 +00:00
52 changed files with 1000 additions and 1992 deletions
@@ -1,6 +1,5 @@
import 'dart:typed_data';
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';
@@ -59,7 +58,6 @@ Future<ArtifactFetchResult> _fetch(Uri uri) async =>
ArtifactFetchResult(status: 200, bytes: _bytes);
Widget _row({
required bool cupertino,
ArtifactFileBridge? bridge,
ArtifactRecord? artifact,
ArtifactFetch? fetch,
@@ -70,19 +68,11 @@ Widget _row({
fetch: fetch ?? _fetch,
bridge: bridge ?? _bridge(),
);
return cupertino
? CupertinoApp(
home: CupertinoPageScaffold(
child: SafeArea(
child: Padding(padding: const EdgeInsets.all(8), child: actions),
),
),
)
: MaterialApp(
home: Scaffold(
body: Padding(padding: const EdgeInsets.all(8), child: actions),
),
);
return MaterialApp(
home: Scaffold(
body: Padding(padding: const EdgeInsets.all(8), child: actions),
),
);
}
TextButton _materialButton(WidgetTester tester, String label) =>
@@ -92,24 +82,12 @@ TextButton _materialButton(WidgetTester tester, String label) =>
.first,
);
CupertinoButton _cupertinoButton(WidgetTester tester, String label) =>
tester.widget<CupertinoButton>(
find
.ancestor(
of: find.text(label),
matching: find.byType(CupertinoButton),
)
.first,
);
void main() {
testWidgets('Download saves the exact named bytes and reports it', (
tester,
) async {
final saved = <ArtifactFile>[];
await tester.pumpWidget(
_row(cupertino: false, bridge: _bridge(saved: saved)),
);
await tester.pumpWidget(_row(bridge: _bridge(saved: saved)));
await tester.tap(find.text('Download'));
await tester.pumpAndSettle();
@@ -123,9 +101,7 @@ void main() {
testWidgets('Share starts one file transfer, not a link', (tester) async {
final shared = <ArtifactFile>[];
await tester.pumpWidget(
_row(cupertino: false, bridge: _bridge(shared: shared)),
);
await tester.pumpWidget(_row(bridge: _bridge(shared: shared)));
await tester.tap(find.text('Share'));
await tester.pumpAndSettle();
@@ -140,10 +116,7 @@ void main() {
) async {
final saved = <ArtifactFile>[];
await tester.pumpWidget(
_row(
cupertino: false,
bridge: _bridge(saved: saved, shareSupported: false),
),
_row(bridge: _bridge(saved: saved, shareSupported: false)),
);
expect(find.text('No share on this host.'), findsOneWidget);
@@ -160,7 +133,6 @@ void main() {
) async {
await tester.pumpWidget(
_row(
cupertino: false,
bridge: _bridge(),
fetch: (_) => Future<ArtifactFetchResult>.delayed(
const Duration(seconds: 30),
@@ -183,9 +155,7 @@ void main() {
await tester.pump(const Duration(seconds: 31));
});
testWidgets('both hosts keep the file actions whole at 320/2x dark', (
tester,
) async {
testWidgets('the file actions stay whole at 320/2x dark', (tester) async {
tester.view.physicalSize = const Size(640, 1200);
tester.view.devicePixelRatio = 2;
tester.platformDispatcher.textScaleFactorTestValue = 2;
@@ -195,20 +165,12 @@ void main() {
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);
for (final cupertino in <bool>[false, true]) {
await tester.pumpWidget(_row(cupertino: cupertino));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
expect(find.text('Download'), findsOneWidget);
expect(find.text('Share'), findsOneWidget);
if (cupertino) {
expect(_cupertinoButton(tester, 'Download').onPressed, isNotNull);
expect(find.byType(TextButton), findsNothing);
} else {
expect(_materialButton(tester, 'Download').onPressed, isNotNull);
expect(find.byType(CupertinoButton), findsNothing);
}
}
await tester.pumpWidget(_row());
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
expect(find.text('Download'), findsOneWidget);
expect(find.text('Share'), findsOneWidget);
expect(_materialButton(tester, 'Download').onPressed, isNotNull);
});
testWidgets('the gallery selection offers both file actions in its dialog', (
@@ -315,44 +277,27 @@ void main() {
],
),
];
for (final cupertino in <bool>[false, true]) {
await tester.pumpWidget(
cupertino
? CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.dark),
home: ArtifactGalleryPage(
steps: steps,
configuredEndpoint: _endpoint,
fetch: _fetch,
fileBridge: _bridge(),
),
)
: MaterialApp(
theme: ThemeData(brightness: Brightness.dark),
home: ArtifactGalleryPage(
steps: steps,
configuredEndpoint: _endpoint,
fetch: _fetch,
fileBridge: _bridge(),
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.text('report.zip'));
await tester.pumpAndSettle();
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(brightness: Brightness.dark),
home: ArtifactGalleryPage(
steps: steps,
configuredEndpoint: _endpoint,
fetch: _fetch,
fileBridge: _bridge(),
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.text('report.zip'));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
expect(find.text('Download'), findsOneWidget);
expect(find.text('Share'), findsOneWidget);
expect(
cupertino
? find.byType(CupertinoAlertDialog)
: find.byType(AlertDialog),
findsOneWidget,
);
await tester.tap(find.text('Close'));
await tester.pumpAndSettle();
}
expect(tester.takeException(), isNull);
expect(find.text('Download'), findsOneWidget);
expect(find.text('Share'), findsOneWidget);
expect(find.byType(AlertDialog), findsOneWidget);
await tester.tap(find.text('Close'));
await tester.pumpAndSettle();
});
testWidgets(
@@ -1,6 +1,5 @@
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -33,9 +32,8 @@ final ArtifactGroup _group = visitGroup(artifacts: [_report, _log]);
typedef _Rendered = List<(String, bool)>;
Future<({_Rendered rendered, List<Uri> opened})> _pump(
WidgetTester tester, {
bool cupertino = false,
}) async {
WidgetTester tester,
) async {
final rendered = <(String, bool)>[];
final opened = <Uri>[];
final page = ArtifactViewerPage(
@@ -61,17 +59,13 @@ Future<({_Rendered rendered, List<Uri> opened})> _pump(
children: [
Expanded(
child: Navigator(
onGenerateRoute: (_) => cupertino
? CupertinoPageRoute<void>(builder: (_) => page)
: MaterialPageRoute<void>(builder: (_) => page),
onGenerateRoute: (_) => MaterialPageRoute<void>(builder: (_) => page),
),
),
const SizedBox(key: _shellBar, height: 56, child: Text('Tabs')),
],
);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell),
);
await tester.pumpWidget(MaterialApp(home: shell));
await tester.pumpAndSettle();
return (rendered: rendered, opened: opened);
}
@@ -81,61 +75,53 @@ Future<void> _enter(WidgetTester tester) async {
await tester.pumpAndSettle();
}
/// A bar control by its accessible name: the Material button's tooltip, the
/// Cupertino button's semantics label.
Finder _named(bool cupertino, String name) =>
cupertino ? find.bySemanticsLabel(name) : find.byTooltip(name);
/// A bar control by its Material tooltip.
Finder _named(String name) => find.byTooltip(name);
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('the bottom actions offer Full screen', (tester) async {
final result = await _pump(tester);
final bar = find.byKey(const Key('artifact-viewer-actions'));
expect(
find.descendant(of: bar, matching: find.byKey(artifactFullscreenKey)),
findsOneWidget,
);
expect(_named('Full screen'), findsOneWidget);
expect(result.rendered.single, ('<h1>Hi</h1>', false));
});
testWidgets('$host: the bottom actions offer Full screen', (tester) async {
final result = await _pump(tester, cupertino: cupertino);
final bar = find.byKey(const Key('artifact-viewer-actions'));
expect(
find.descendant(of: bar, matching: find.byKey(artifactFullscreenKey)),
findsOneWidget,
);
expect(_named(cupertino, 'Full screen'), findsOneWidget);
expect(result.rendered.single, ('<h1>Hi</h1>', false));
});
testWidgets('full screen covers the shell, keeps the actions and '
'renders the fetched document in the app', (tester) async {
final result = await _pump(tester);
await _enter(tester);
testWidgets('$host: full screen covers the shell, keeps the actions and '
'renders the fetched document in the app', (tester) async {
final result = await _pump(tester, cupertino: cupertino);
await _enter(tester);
expect(find.byKey(_shellBar), findsNothing);
// The same document, fetched once with the app's session, now in the
// full-screen scope; nothing was handed to the system browser.
expect(result.rendered.last, ('<h1>Hi</h1>', true));
expect(result.opened, isEmpty);
final bar = find.byKey(const Key('artifact-viewer-actions'));
expect(bar, findsOneWidget);
for (final key in const [
Key('artifact-open'),
Key('artifact-copy-link'),
artifactPreviousKey,
artifactNextKey,
]) {
expect(find.descendant(of: bar, matching: find.byKey(key)), findsOne);
}
expect(_named('Exit full screen'), findsOneWidget);
expect(_named('Open in browser'), findsOneWidget);
});
expect(find.byKey(_shellBar), findsNothing);
// The same document, fetched once with the app's session, now in the
// full-screen scope; nothing was handed to the system browser.
expect(result.rendered.last, ('<h1>Hi</h1>', true));
expect(result.opened, isEmpty);
final bar = find.byKey(const Key('artifact-viewer-actions'));
expect(bar, findsOneWidget);
for (final key in const [
Key('artifact-open'),
Key('artifact-copy-link'),
artifactPreviousKey,
artifactNextKey,
]) {
expect(find.descendant(of: bar, matching: find.byKey(key)), findsOne);
}
expect(_named(cupertino, 'Exit full screen'), findsOneWidget);
expect(_named(cupertino, 'Open in browser'), findsOneWidget);
});
testWidgets('$host: Exit full screen returns to the viewer', (
tester,
) async {
await _pump(tester, cupertino: cupertino);
await _enter(tester);
await tester.tap(find.byKey(artifactFullscreenKey));
await tester.pumpAndSettle();
expect(find.byKey(_shellBar), findsOneWidget);
expect(_named(cupertino, 'Full screen'), findsOneWidget);
});
}
testWidgets('Exit full screen returns to the viewer', (tester) async {
await _pump(tester);
await _enter(tester);
await tester.tap(find.byKey(artifactFullscreenKey));
await tester.pumpAndSettle();
expect(find.byKey(_shellBar), findsOneWidget);
expect(_named('Full screen'), findsOneWidget);
});
testWidgets('Escape and the system back leave full screen', (tester) async {
await _pump(tester);
@@ -1,6 +1,5 @@
import 'dart:typed_data';
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';
@@ -9,8 +8,6 @@ import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_fetch.dart';
import '../domain/artifact_fixtures.dart';
enum _Platform { material, cupertino }
JsonMap _file(String name, String group) => artifact(
name,
contentType: 'text/markdown',
@@ -36,7 +33,7 @@ List<JsonMap> _steps() => <JsonMap>[
),
];
Future<void> _pump(WidgetTester tester, _Platform platform) async {
Future<void> _pump(WidgetTester tester) async {
tester.view.physicalSize = const Size(900, 2600);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
@@ -49,43 +46,37 @@ Future<void> _pump(WidgetTester tester, _Platform platform) async {
ArtifactFetchResult(status: 200, bytes: Uint8List.fromList([35])),
markdownBuilder: (context, value) => Text(value),
);
await tester.pumpWidget(
platform == _Platform.material
? MaterialApp(home: page)
: CupertinoApp(home: page),
);
await tester.pumpWidget(MaterialApp(home: page));
await tester.pumpAndSettle();
}
void main() {
for (final platform in _Platform.values) {
testWidgets('${platform.name}: only deliverables show until Debugging '
'files is revealed', (tester) async {
await _pump(tester, platform);
expect(find.text('public/report.md'), findsOneWidget);
for (final name in [
'history.md',
'memory.md',
'input.md',
'private/scratch.md',
]) {
expect(find.text(name), findsNothing, reason: name);
}
expect(find.text('Debugging files'), findsNothing);
testWidgets('only deliverables show until Debugging '
'files is revealed', (tester) async {
await _pump(tester);
expect(find.text('public/report.md'), findsOneWidget);
for (final name in [
'history.md',
'memory.md',
'input.md',
'private/scratch.md',
]) {
expect(find.text(name), findsNothing, reason: name);
}
expect(find.text('Debugging files'), findsNothing);
await tester.tap(find.byKey(const Key('artifact-debug-toggle')));
await tester.pumpAndSettle();
expect(find.text('Debugging files'), findsOneWidget);
for (final name in [
'history.md',
'memory.md',
'input.md',
'output.md',
'private/scratch.md',
]) {
expect(find.text(name), findsOneWidget, reason: name);
}
expect(find.text('public/report.md'), findsOneWidget);
});
}
await tester.tap(find.byKey(const Key('artifact-debug-toggle')));
await tester.pumpAndSettle();
expect(find.text('Debugging files'), findsOneWidget);
for (final name in [
'history.md',
'memory.md',
'input.md',
'output.md',
'private/scratch.md',
]) {
expect(find.text(name), findsOneWidget, reason: name);
}
expect(find.text('public/report.md'), findsOneWidget);
});
}
@@ -1,6 +1,5 @@
import 'dart:typed_data';
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,8 +10,6 @@ import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_page.dart';
import '../domain/artifact_fixtures.dart';
enum _Platform { material, cupertino }
const String _endpoint = 'ws://127.0.0.1:8081/connect';
JsonMap _recorded(
@@ -48,8 +45,7 @@ List<JsonMap> _steps() => <JsonMap>[
];
Future<void> _pump(
WidgetTester tester,
_Platform platform, {
WidgetTester tester, {
List<JsonMap>? steps,
ArtifactFetch? fetch,
ArtifactExternalOpen? openExternal,
@@ -72,11 +68,7 @@ Future<void> _pump(
),
markdownBuilder: (context, value) => Text(value),
);
await tester.pumpWidget(
platform == _Platform.material
? MaterialApp(home: page)
: CupertinoApp(home: page),
);
await tester.pumpWidget(MaterialApp(home: page));
await tester.pumpAndSettle();
}
@@ -85,230 +77,194 @@ Future<void> _showTurnDocuments(WidgetTester tester) async {
await tester.pumpAndSettle();
}
Finder _dialog(_Platform platform, String text) => find.descendant(
of: find.byType(
platform == _Platform.material ? AlertDialog : CupertinoAlertDialog,
),
matching: find.text(text),
);
Finder _dialog(String text) =>
find.descendant(of: find.byType(AlertDialog), matching: find.text(text));
void main() {
for (final platform in _Platform.values) {
testWidgets('${platform.name}: debug hides documents by default and shows '
'each visit when enabled', (tester) async {
await _pump(tester, platform);
expect(find.text('input.md'), findsNothing);
expect(find.textContaining('Turn documents'), findsNothing);
expect(find.byTooltip('Show debugging files'), findsOneWidget);
await _showTurnDocuments(tester);
expect(find.byTooltip('Hide debugging files'), findsOneWidget);
expect(find.text('input.md'), findsNWidgets(2));
expect(find.text('output.md'), findsNWidgets(2));
expect(find.text('session.html'), findsNWidgets(2));
expect(find.text('memory.md'), findsNWidgets(2));
expect(find.text('text/markdown · 120\u00a0B'), findsOneWidget);
expect(find.text('text/plain · 512\u00a0B'), findsOneWidget);
});
testWidgets('debug hides documents by default and shows '
'each visit when enabled', (tester) async {
await _pump(tester);
expect(find.text('input.md'), findsNothing);
expect(find.textContaining('Turn documents'), findsNothing);
expect(find.byTooltip('Show debugging files'), findsOneWidget);
await _showTurnDocuments(tester);
expect(find.byTooltip('Hide debugging files'), findsOneWidget);
expect(find.text('input.md'), findsNWidgets(2));
expect(find.text('output.md'), findsNWidgets(2));
expect(find.text('session.html'), findsNWidgets(2));
expect(find.text('memory.md'), findsNWidgets(2));
expect(find.text('text/markdown · 120\u00a0B'), findsOneWidget);
expect(find.text('text/plain · 512\u00a0B'), findsOneWidget);
});
testWidgets('${platform.name}: missing documents show exact wording', (
testWidgets('missing documents show exact wording', (tester) async {
await _pump(tester);
await _showTurnDocuments(tester);
expect(find.text('No memory recorded for this visit.'), findsOneWidget);
expect(find.text('No output recorded.'), findsOneWidget);
expect(find.text('This visit has no harness session.'), findsOneWidget);
expect(find.text('No input recorded.'), findsNothing);
});
testWidgets('markdown opens the existing renderer', (tester) async {
await _pump(tester);
await _showTurnDocuments(tester);
await tester.tap(find.text('input.md').first);
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsOneWidget);
expect(find.text('# Recorded input'), findsOneWidget);
await tester.tap(find.byKey(const Key('artifact-info')));
await tester.pumpAndSettle();
expect(find.text('review · visit 1'), findsOneWidget);
expect(find.text('text/markdown · 120\u00a0B'), findsOneWidget);
});
testWidgets('absent rows are informational, not controls', (tester) async {
await _pump(tester);
await _showTurnDocuments(tester);
final absence = find.text('No output recorded.');
expect(absence, findsOneWidget);
// Not disabled: the absence line is content, not a skipped action, and
// is painted with the normal secondary label colour.
final tile = tester.widget<ListTile>(
find.ancestor(of: absence, matching: find.byType(ListTile)),
);
expect(tile.enabled, isTrue);
expect(tile.onTap, isNull);
expect(
tester.widget<Text>(absence).style?.color,
Theme.of(tester.element(absence)).colorScheme.onSurfaceVariant,
);
await tester.tap(absence);
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsNothing);
expect(find.byType(AlertDialog), findsNothing);
});
testWidgets('session.html stays external-only', (tester) async {
final opened = <Uri>[];
await _pump(
tester,
) async {
await _pump(tester, platform);
await _showTurnDocuments(tester);
expect(find.text('No memory recorded for this visit.'), findsOneWidget);
expect(find.text('No output recorded.'), findsOneWidget);
expect(find.text('This visit has no harness session.'), findsOneWidget);
expect(find.text('No input recorded.'), findsNothing);
});
testWidgets('${platform.name}: markdown opens the existing renderer', (
tester,
) async {
await _pump(tester, platform);
await _showTurnDocuments(tester);
await tester.tap(find.text('input.md').first);
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsOneWidget);
expect(find.text('# Recorded input'), findsOneWidget);
await tester.tap(find.byKey(const Key('artifact-info')));
await tester.pumpAndSettle();
expect(find.text('review · visit 1'), findsOneWidget);
expect(find.text('text/markdown · 120\u00a0B'), findsOneWidget);
});
testWidgets(
'${platform.name}: absent rows are informational, not controls',
(tester) async {
await _pump(tester, platform);
await _showTurnDocuments(tester);
final absence = find.text('No output recorded.');
expect(absence, findsOneWidget);
if (platform == _Platform.material) {
// Not disabled: the absence line is content, not a skipped action, and
// is painted with the normal secondary label colour.
final tile = tester.widget<ListTile>(
find.ancestor(of: absence, matching: find.byType(ListTile)),
);
expect(tile.enabled, isTrue);
expect(tile.onTap, isNull);
expect(
tester.widget<Text>(absence).style?.color,
Theme.of(tester.element(absence)).colorScheme.onSurfaceVariant,
);
} else {
expect(
find.ancestor(of: absence, matching: find.byType(CupertinoButton)),
findsNothing,
);
}
await tester.tap(absence);
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsNothing);
expect(find.byType(AlertDialog), findsNothing);
expect(find.byType(CupertinoAlertDialog), findsNothing);
openExternal: (uri) async {
opened.add(uri);
return true;
},
fetch: (_) async => throw StateError('x'),
);
await _showTurnDocuments(tester);
await tester.tap(find.text('session.html').first);
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsNothing);
expect(_dialog('session.html'), findsOneWidget);
expect(_dialog('text/plain · 512\u00a0B'), findsOneWidget);
await tester.tap(_dialog('Open in browser'));
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsNothing);
expect(opened, [
Uri.parse('http://127.0.0.1:8081/artifacts/1/1/session.html'),
]);
});
testWidgets('a stage artifact pages only through stage '
'artifacts while Debug is off', (tester) async {
await _pump(tester);
// report.csv (visit 1) and notes.md (visit 2) are the only stage
// artifacts; the visits' turn documents stay out of the viewer.
await tester.tap(find.text('report.csv'));
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsOneWidget);
expect(find.text('1 of 2 · text/csv'), findsOneWidget);
});
testWidgets('with Debug on, a stage artifact pages '
'through turn documents too', (tester) async {
await _pump(tester);
await _showTurnDocuments(tester);
await tester.tap(find.text('report.csv'));
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsOneWidget);
// Both stage artifacts plus the recorded viewer documents
// (session.html opens externally only).
expect(find.text('1 of 6 · text/csv'), findsOneWidget);
});
testWidgets('documents do not count as artifacts and '
'viewer paging stays within documents', (tester) async {
await _pump(
tester,
steps: [
step(
stage: 'review',
visit: 1,
artifacts: [
_recorded('report.csv', contentType: 'text/csv', sizeBytes: 23),
_recorded('input.md', contentType: 'text/markdown', sizeBytes: 1),
_recorded('output.md', contentType: 'text/markdown', sizeBytes: 1),
],
),
],
);
testWidgets('${platform.name}: session.html stays external-only', (
expect(find.text('Artifact · 1 recorded'), findsOneWidget);
expect(find.text('report.csv'), findsOneWidget);
expect(find.text('input.md'), findsNothing);
await _showTurnDocuments(tester);
await tester.tap(find.text('input.md'));
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsOneWidget);
expect(find.text('1 of 2 · text/markdown'), findsOneWidget);
});
testWidgets('document-only visits retain an honest empty '
'artifact state', (tester) async {
await _pump(
tester,
) async {
final opened = <Uri>[];
await _pump(
tester,
platform,
openExternal: (uri) async {
opened.add(uri);
return true;
},
fetch: (_) async => throw StateError('x'),
);
await _showTurnDocuments(tester);
await tester.tap(find.text('session.html').first);
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsNothing);
expect(_dialog(platform, 'session.html'), findsOneWidget);
expect(_dialog(platform, 'text/plain · 512\u00a0B'), findsOneWidget);
await tester.tap(_dialog(platform, 'Open in browser'));
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsNothing);
expect(opened, [
Uri.parse('http://127.0.0.1:8081/artifacts/1/1/session.html'),
]);
});
steps: [
step(
stage: 'review',
visit: 1,
artifacts: [
_recorded('input.md', contentType: 'text/markdown', sizeBytes: 1),
],
),
],
);
testWidgets('${platform.name}: a stage artifact pages only through stage '
'artifacts while Debug is off', (tester) async {
await _pump(tester, platform);
expect(find.text('No artifacts recorded for this run.'), findsOneWidget);
expect(find.text('input.md'), findsNothing);
await _showTurnDocuments(tester);
expect(find.text('input.md'), findsOneWidget);
});
// report.csv (visit 1) and notes.md (visit 2) are the only stage
// artifacts; the visits' turn documents stay out of the viewer.
await tester.tap(find.text('report.csv'));
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsOneWidget);
expect(find.text('1 of 2 · text/csv'), findsOneWidget);
});
testWidgets('${platform.name}: with Debug on, a stage artifact pages '
'through turn documents too', (tester) async {
await _pump(tester, platform);
await _showTurnDocuments(tester);
await tester.tap(find.text('report.csv'));
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsOneWidget);
// Both stage artifacts plus the recorded viewer documents
// (session.html opens externally only).
expect(find.text('1 of 6 · text/csv'), findsOneWidget);
});
testWidgets('${platform.name}: documents do not count as artifacts and '
'viewer paging stays within documents', (tester) async {
await _pump(
tester,
platform,
steps: [
step(
stage: 'review',
visit: 1,
artifacts: [
_recorded('report.csv', contentType: 'text/csv', sizeBytes: 23),
_recorded('input.md', contentType: 'text/markdown', sizeBytes: 1),
_recorded(
'output.md',
contentType: 'text/markdown',
sizeBytes: 1,
),
],
),
],
);
expect(find.text('Artifact · 1 recorded'), findsOneWidget);
expect(find.text('report.csv'), findsOneWidget);
expect(find.text('input.md'), findsNothing);
await _showTurnDocuments(tester);
await tester.tap(find.text('input.md'));
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsOneWidget);
expect(find.text('1 of 2 · text/markdown'), findsOneWidget);
});
testWidgets('${platform.name}: document-only visits retain an honest empty '
'artifact state', (tester) async {
await _pump(
tester,
platform,
steps: [
step(
stage: 'review',
visit: 1,
artifacts: [
_recorded('input.md', contentType: 'text/markdown', sizeBytes: 1),
],
),
],
);
expect(find.text('No artifacts recorded for this run.'), findsOneWidget);
expect(find.text('input.md'), findsNothing);
await _showTurnDocuments(tester);
expect(find.text('input.md'), findsOneWidget);
});
testWidgets('${platform.name}: focused document-only visits retain turn '
'documents', (tester) async {
await _pump(
tester,
platform,
focusIndex: 0,
steps: [
step(
stage: 'review',
visit: 1,
artifacts: [
_recorded('input.md', contentType: 'text/markdown', sizeBytes: 1),
],
),
],
);
expect(
find.text('No artifacts recorded for this visit.'),
findsOneWidget,
);
expect(find.text('input.md'), findsNothing);
await _showTurnDocuments(tester);
expect(find.text('input.md'), findsOneWidget);
});
testWidgets('${platform.name}: focused visits retain session documents', (
testWidgets('focused document-only visits retain turn '
'documents', (tester) async {
await _pump(
tester,
) async {
await _pump(tester, platform, focusIndex: 0);
focusIndex: 0,
steps: [
step(
stage: 'review',
visit: 1,
artifacts: [
_recorded('input.md', contentType: 'text/markdown', sizeBytes: 1),
],
),
],
);
expect(find.text('session.html'), findsNothing);
await _showTurnDocuments(tester);
expect(find.text('session.html'), findsOneWidget);
});
}
expect(find.text('No artifacts recorded for this visit.'), findsOneWidget);
expect(find.text('input.md'), findsNothing);
await _showTurnDocuments(tester);
expect(find.text('input.md'), findsOneWidget);
});
testWidgets('focused visits retain session documents', (tester) async {
await _pump(tester, focusIndex: 0);
expect(find.text('session.html'), findsNothing);
await _showTurnDocuments(tester);
expect(find.text('session.html'), findsOneWidget);
});
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -9,8 +8,6 @@ import 'package:pipelines_app/features/artifacts/ui/artifact_visit_list.dart';
import '../domain/artifact_fixtures.dart';
enum _Platform { material, cupertino }
JsonMap _recorded(
String name, {
String url = '',
@@ -51,7 +48,6 @@ List<JsonMap> _steps() => <JsonMap>[
Future<void> _pumpGallery(
WidgetTester tester,
_Platform platform,
List<JsonMap> steps, {
int? focusIndex,
String configuredEndpoint = '',
@@ -77,65 +73,53 @@ Future<void> _pumpGallery(
size: surface,
textScaler: TextScaler.linear(textScale),
),
child: platform == _Platform.material
? MaterialApp(home: page)
: CupertinoApp(home: page),
child: MaterialApp(home: page),
),
);
await tester.pumpAndSettle();
}
Finder _inDialog(_Platform platform, String text) => find.descendant(
of: find.byType(
platform == _Platform.material ? AlertDialog : CupertinoAlertDialog,
),
matching: find.text(text),
);
Finder _inDialog(String text) =>
find.descendant(of: find.byType(AlertDialog), matching: find.text(text));
void main() {
for (final platform in _Platform.values) {
testWidgets('${platform.name}: lists recorded groups and rows', (
tester,
) async {
await _pumpGallery(tester, platform, _steps());
expect(find.text('Artifacts · 4 recorded'), findsOneWidget);
expect(find.text('build · visit 1'), findsOneWidget);
expect(find.text('review · visit 1'), findsOneWidget);
expect(find.text('review · visit 2'), findsOneWidget);
expect(find.text('result.zip'), findsNWidgets(2));
expect(find.text('notes.md'), findsOneWidget);
expect(find.text('text/markdown · 2.0\u00a0KiB'), findsOneWidget);
});
testWidgets('lists recorded groups and rows', (tester) async {
await _pumpGallery(tester, _steps());
expect(find.text('Artifacts · 4 recorded'), findsOneWidget);
expect(find.text('build · visit 1'), findsOneWidget);
expect(find.text('review · visit 1'), findsOneWidget);
expect(find.text('review · visit 2'), findsOneWidget);
expect(find.text('result.zip'), findsNWidgets(2));
expect(find.text('notes.md'), findsOneWidget);
expect(find.text('text/markdown · 2.0\u00a0KiB'), findsOneWidget);
});
testWidgets('${platform.name}: duplicate filename stays visit distinct', (
tester,
) async {
final steps = _steps();
await _pumpGallery(tester, platform, steps);
await tester.tap(find.text('result.zip').at(1));
await tester.pumpAndSettle();
testWidgets('duplicate filename stays visit distinct', (tester) async {
final steps = _steps();
await _pumpGallery(tester, steps);
await tester.tap(find.text('result.zip').at(1));
await tester.pumpAndSettle();
final groups = artifactGroups(steps);
final visitTwo = groups.firstWhere(
(group) => group.stageKey == 'review' && group.visit == 2,
);
final list = tester.widget<ArtifactVisitList>(
find.byType(ArtifactVisitList),
);
expect(
list.selectedIdentity,
artifactVisitIdentity(visitTwo, visitTwo.artifacts.single),
);
expect(_inDialog(platform, 'review · visit 2'), findsOneWidget);
expect(_inDialog(platform, 'review · visit 1'), findsNothing);
expect(_inDialog(platform, 'Artifacts · 1 recorded'), findsOneWidget);
});
}
final groups = artifactGroups(steps);
final visitTwo = groups.firstWhere(
(group) => group.stageKey == 'review' && group.visit == 2,
);
final list = tester.widget<ArtifactVisitList>(
find.byType(ArtifactVisitList),
);
expect(
list.selectedIdentity,
artifactVisitIdentity(visitTwo, visitTwo.artifacts.single),
);
expect(_inDialog('review · visit 2'), findsOneWidget);
expect(_inDialog('review · visit 1'), findsNothing);
expect(_inDialog('Artifacts · 1 recorded'), findsOneWidget);
});
testWidgets('capture notes and partial label come from the visit step', (
tester,
) async {
await _pumpGallery(tester, _Platform.material, [
await _pumpGallery(tester, [
step(
stage: 'review',
visit: 1,
@@ -151,18 +135,15 @@ void main() {
await tester.tap(find.text('result.zip'));
await tester.pumpAndSettle();
expect(
_inDialog(_Platform.material, 'Artifacts · 2 recorded · partial capture'),
_inDialog('Artifacts · 2 recorded · partial capture'),
findsOneWidget,
);
expect(
_inDialog(_Platform.material, '2 files excluded from artifact capture.'),
_inDialog('2 files excluded from artifact capture.'),
findsOneWidget,
);
expect(
_inDialog(
_Platform.material,
'3 files omitted by artifact capture limits.',
),
_inDialog('3 files omitted by artifact capture limits.'),
findsOneWidget,
);
});
@@ -170,7 +151,7 @@ void main() {
testWidgets('an unavailable capture never claims nothing was recorded', (
tester,
) async {
await _pumpGallery(tester, _Platform.material, [
await _pumpGallery(tester, [
step(stage: 'review', visit: 1, includeArtifacts: false),
]);
expect(find.text('Artifacts · capture unavailable'), findsOneWidget);
@@ -180,7 +161,7 @@ void main() {
testWidgets('a recorded empty capture says nothing was recorded', (
tester,
) async {
await _pumpGallery(tester, _Platform.material, [
await _pumpGallery(tester, [
step(stage: 'review', visit: 1, artifacts: const []),
]);
expect(find.text('No artifacts recorded for this run.'), findsOneWidget);
@@ -188,7 +169,7 @@ void main() {
});
testWidgets('a page with no steps says so explicitly', (tester) async {
await _pumpGallery(tester, _Platform.material, const []);
await _pumpGallery(tester, const []);
expect(find.text('No steps recorded for this run.'), findsOneWidget);
});
@@ -196,7 +177,6 @@ void main() {
final opened = <Uri>[];
await _pumpGallery(
tester,
_Platform.material,
[
step(
stage: 'review',
@@ -214,7 +194,7 @@ void main() {
);
await tester.tap(find.text('result.zip'));
await tester.pumpAndSettle();
await tester.tap(_inDialog(_Platform.material, 'Open in browser'));
await tester.tap(_inDialog('Open in browser'));
await tester.pumpAndSettle();
expect(opened, [
@@ -227,7 +207,7 @@ void main() {
testWidgets('an unsafe recorded url offers no open or copy action', (
tester,
) async {
await _pumpGallery(tester, _Platform.material, [
await _pumpGallery(tester, [
step(
stage: 'review',
visit: 1,
@@ -237,20 +217,17 @@ void main() {
await tester.tap(find.text('result.zip'));
await tester.pumpAndSettle();
expect(
_inDialog(
_Platform.material,
'The recorded artifact URL cannot be opened safely.',
),
_inDialog('The recorded artifact URL cannot be opened safely.'),
findsOneWidget,
);
expect(_inDialog(_Platform.material, 'Open in browser'), findsNothing);
expect(_inDialog(_Platform.material, 'Copy link'), findsNothing);
expect(_inDialog('Open in browser'), findsNothing);
expect(_inDialog('Copy link'), findsNothing);
});
testWidgets('a record with no url is explicit and offers no action', (
tester,
) async {
await _pumpGallery(tester, _Platform.material, [
await _pumpGallery(tester, [
step(
stage: 'review',
visit: 1,
@@ -266,11 +243,8 @@ void main() {
]);
await tester.tap(find.text('result.zip'));
await tester.pumpAndSettle();
expect(
_inDialog(_Platform.material, 'No artifact URL recorded.'),
findsOneWidget,
);
expect(_inDialog(_Platform.material, 'Open in browser'), findsNothing);
expect(_inDialog('No artifact URL recorded.'), findsOneWidget);
expect(_inDialog('Open in browser'), findsNothing);
});
testWidgets('Copy link copies the resolved url, separate from Open', (
@@ -295,7 +269,6 @@ void main() {
final opened = <Uri>[];
await _pumpGallery(
tester,
_Platform.material,
[
step(
stage: 'review',
@@ -313,7 +286,7 @@ void main() {
);
await tester.tap(find.text('result.zip'));
await tester.pumpAndSettle();
await tester.tap(_inDialog(_Platform.material, 'Copy link'));
await tester.tap(_inDialog('Copy link'));
await tester.pumpAndSettle();
expect(copied, ['http://127.0.0.1:8081/artifacts/1/1/result.zip']);
@@ -322,7 +295,7 @@ void main() {
});
testWidgets('an executing run says capture pending', (tester) async {
await _pumpGallery(tester, _Platform.material, [
await _pumpGallery(tester, [
step(
stage: 'review',
visit: 1,
@@ -336,7 +309,7 @@ void main() {
testWidgets('the run header names the visit each capture note belongs to', (
tester,
) async {
await _pumpGallery(tester, _Platform.material, [
await _pumpGallery(tester, [
step(
stage: 'review',
visit: 1,
@@ -368,7 +341,7 @@ void main() {
testWidgets('a focused visit header states its own notes without a prefix', (
tester,
) async {
await _pumpGallery(tester, _Platform.material, [
await _pumpGallery(tester, [
step(
stage: 'review',
visit: 1,
@@ -400,7 +373,7 @@ void main() {
});
testWidgets('a complete capture adds no header notes', (tester) async {
await _pumpGallery(tester, _Platform.material, [
await _pumpGallery(tester, [
step(stage: 'review', visit: 1, artifacts: [_recorded('result.zip')]),
]);
@@ -409,103 +382,93 @@ void main() {
expect(find.textContaining('files omitted'), findsNothing);
});
for (final platform in _Platform.values) {
testWidgets(
'${platform.name}: a long run header scrolls with the gallery rows',
(tester) async {
// Ten partial visits at a phone surface: the header is taller than the
// free space a fixed sibling could get without taking the list's.
await _pumpGallery(tester, platform, <JsonMap>[
for (var visit = 1; visit <= 10; visit += 1)
step(
stage: 'review',
sequence: visit,
visit: visit,
artifacts: [_recorded('file$visit.zip')],
skipped: 1,
),
], surface: const Size(360, 640));
testWidgets('a long run header scrolls with the gallery rows', (
tester,
) async {
// Ten partial visits at a phone surface: the header is taller than the
// free space a fixed sibling could get without taking the list's.
await _pumpGallery(tester, <JsonMap>[
for (var visit = 1; visit <= 10; visit += 1)
step(
stage: 'review',
sequence: visit,
visit: visit,
artifacts: [_recorded('file$visit.zip')],
skipped: 1,
),
], surface: const Size(360, 640));
expect(tester.takeException(), isNull);
final list = find.byType(CustomScrollView);
expect(tester.getSize(list).height, greaterThan(0));
// The header belongs to that scroll view, so it scrolls away instead of
// shrinking the list.
expect(
find.descendant(
of: list,
matching: find.text('Artifacts · 10 recorded · partial capture'),
),
findsOneWidget,
);
await tester.scrollUntilVisible(find.text('file10.zip'), 200);
expect(find.text('file10.zip'), findsOneWidget);
},
expect(tester.takeException(), isNull);
final list = find.byType(CustomScrollView);
expect(tester.getSize(list).height, greaterThan(0));
// The header belongs to that scroll view, so it scrolls away instead of
// shrinking the list.
expect(
find.descendant(
of: list,
matching: find.text('Artifacts · 10 recorded · partial capture'),
),
findsOneWidget,
);
await tester.scrollUntilVisible(find.text('file10.zip'), 200);
expect(find.text('file10.zip'), findsOneWidget);
});
testWidgets(
'${platform.name}: focused notes at 2x text keep the artifact list',
(tester) async {
await _pumpGallery(
tester,
platform,
[
step(
stage: 'review',
visit: 1,
artifacts: [
_recorded('result.zip', url: '/artifacts/1/1/result.zip'),
],
skipped: 12,
truncated: 34,
),
testWidgets('focused notes at 2x text keep the artifact list', (
tester,
) async {
await _pumpGallery(
tester,
[
step(
stage: 'review',
visit: 1,
artifacts: [
_recorded('result.zip', url: '/artifacts/1/1/result.zip'),
],
focusIndex: 0,
surface: const Size(320, 568),
textScale: 2,
);
expect(tester.takeException(), isNull);
expect(
tester.getSize(find.byType(CustomScrollView)).height,
greaterThan(0),
);
expect(
find.text('12 files excluded from artifact capture.'),
findsOneWidget,
);
expect(
find.text('34 files omitted by artifact capture limits.'),
findsOneWidget,
);
await tester.scrollUntilVisible(find.text('result.zip'), 200);
expect(find.text('result.zip'), findsOneWidget);
},
skipped: 12,
truncated: 34,
),
],
focusIndex: 0,
surface: const Size(320, 568),
textScale: 2,
);
testWidgets(
'${platform.name}: sheet actions keep Close, Copy, Open order',
(tester) async {
await _pumpGallery(tester, platform, [
step(
stage: 'review',
visit: 1,
artifacts: [
_recorded('result.zip', url: '/artifacts/1/1/result.zip'),
],
),
], configuredEndpoint: 'ws://127.0.0.1:8081/connect');
await tester.tap(find.text('result.zip'));
await tester.pumpAndSettle();
double orderOf(String label) {
final offset = tester.getTopLeft(_inDialog(platform, label));
return platform == _Platform.material ? offset.dx : offset.dy;
}
expect(orderOf('Close'), lessThan(orderOf('Copy link')));
expect(orderOf('Copy link'), lessThan(orderOf('Open in browser')));
},
expect(tester.takeException(), isNull);
expect(
tester.getSize(find.byType(CustomScrollView)).height,
greaterThan(0),
);
}
expect(
find.text('12 files excluded from artifact capture.'),
findsOneWidget,
);
expect(
find.text('34 files omitted by artifact capture limits.'),
findsOneWidget,
);
await tester.scrollUntilVisible(find.text('result.zip'), 200);
expect(find.text('result.zip'), findsOneWidget);
});
testWidgets('sheet actions keep Close, Copy, Open order', (tester) async {
await _pumpGallery(tester, [
step(
stage: 'review',
visit: 1,
artifacts: [_recorded('result.zip', url: '/artifacts/1/1/result.zip')],
),
], configuredEndpoint: 'ws://127.0.0.1:8081/connect');
await tester.tap(find.text('result.zip'));
await tester.pumpAndSettle();
double orderOf(String label) {
final offset = tester.getTopLeft(_inDialog(label));
return offset.dx;
}
expect(orderOf('Close'), lessThan(orderOf('Copy link')));
expect(orderOf('Copy link'), lessThan(orderOf('Open in browser')));
});
}
@@ -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';
@@ -21,7 +20,7 @@ ArtifactGroup _group() => ArtifactGroup(
artifacts: [ArtifactRecord.fromJson(_recorded())],
);
Future<void> _pump(WidgetTester tester, {required bool cupertino}) async {
Future<void> _pump(WidgetTester tester) async {
final group = _group();
final facts = Padding(
padding: const EdgeInsets.all(16),
@@ -37,50 +36,36 @@ Future<void> _pump(WidgetTester tester, {required bool cupertino}) async {
resolved: null,
),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(
home: CupertinoPageScaffold(
backgroundColor: CupertinoColors.systemGroupedBackground,
child: facts,
),
)
: MaterialApp(home: Scaffold(body: facts)),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: facts)));
}
void main() {
for (final cupertino in <bool>[false, true]) {
testWidgets(
'${cupertino ? 'cupertino' : 'material'}: facts lead with metadata, then the visit, then its capture',
(tester) async {
await _pump(tester, cupertino: cupertino);
testWidgets('facts lead with metadata, then the visit, then its capture', (
tester,
) async {
await _pump(tester);
const metadata = 'text/csv · 2.0\u00a0KiB';
const visit = 'review · visit 1';
const summary = 'Artifacts · 1 recorded · partial capture';
const note = '2 files excluded from artifact capture.';
const urlState = 'The recorded artifact URL cannot be opened safely.';
const metadata = 'text/csv · 2.0\u00a0KiB';
const visit = 'review · visit 1';
const summary = 'Artifacts · 1 recorded · partial capture';
const note = '2 files excluded from artifact capture.';
const urlState = 'The recorded artifact URL cannot be opened safely.';
double topOf(String text) => tester.getTopLeft(find.text(text)).dy;
double topOf(String text) => tester.getTopLeft(find.text(text)).dy;
expect(topOf(metadata), lessThan(topOf(visit)));
expect(topOf(visit), lessThan(topOf(summary)));
expect(topOf(summary), lessThan(topOf(note)));
expect(topOf(note), lessThan(topOf(urlState)));
expect(topOf(metadata), lessThan(topOf(visit)));
expect(topOf(visit), lessThan(topOf(summary)));
expect(topOf(summary), lessThan(topOf(note)));
expect(topOf(note), lessThan(topOf(urlState)));
final context = tester.element(find.text(metadata));
final secondary = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
final metadataStyle = tester.widget<Text>(find.text(metadata)).style;
final visitStyle = tester.widget<Text>(find.text(visit)).style;
final summaryStyle = tester.widget<Text>(find.text(summary)).style;
final context = tester.element(find.text(metadata));
final secondary = Theme.of(context).colorScheme.onSurfaceVariant;
final metadataStyle = tester.widget<Text>(find.text(metadata)).style;
final visitStyle = tester.widget<Text>(find.text(visit)).style;
final summaryStyle = tester.widget<Text>(find.text(summary)).style;
expect(metadataStyle?.color, secondary);
expect(visitStyle?.color, secondary);
expect(summaryStyle?.color, isNot(secondary));
},
);
}
expect(metadataStyle?.color, secondary);
expect(visitStyle?.color, secondary);
expect(summaryStyle?.color, isNot(secondary));
});
}
@@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -42,7 +41,6 @@ Future<void> _pumpViewer(
WidgetTester tester, {
required List<ArtifactGroup> groups,
required String selected,
bool cupertino = false,
ArtifactFetch? fetch,
Widget Function(BuildContext, String)? markdownBuilder,
ArtifactExternalOpen? openExternal,
@@ -61,11 +59,7 @@ Future<void> _pumpViewer(
data: MediaQueryData(padding: EdgeInsets.only(bottom: bottomClearance)),
child: page,
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: child)
: MaterialApp(home: Scaffold(body: child)),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: child)));
await tester.pumpAndSettle();
}
@@ -86,7 +80,6 @@ const String _markdownBody =
/// viewer exactly as the run detail does.
Future<void> _openMarkdownFromGallery(
WidgetTester tester, {
required bool cupertino,
String name = 'notes.md',
String contentType = 'text/markdown',
}) async {
@@ -109,9 +102,7 @@ Future<void> _openMarkdownFromGallery(
fetch: (_) async =>
ArtifactFetchResult(status: 200, bytes: utf8.encode(_markdownBody)),
);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: page) : MaterialApp(home: page),
);
await tester.pumpWidget(MaterialApp(home: page));
await tester.pumpAndSettle();
await tester.tap(find.text(name));
await tester.pumpAndSettle();
@@ -533,33 +524,10 @@ void main() {
expect(find.byKey(artifactPreviewRetryKey), findsOneWidget);
});
testWidgets('Cupertino draws the same text preview and controls', (
tester,
) async {
final text = recordedArtifact(
'notes.txt',
url: '/artifacts/1/1/notes.txt',
contentType: 'text/plain',
);
final group = _group([text]);
await _pumpViewer(
tester,
cupertino: true,
groups: [group],
selected: artifactVisitIdentity(group, text),
fetch: (_) async => ArtifactFetchResult(
status: 200,
bytes: utf8.encode('cupertino text'),
),
);
expect(find.text('cupertino text'), findsOneWidget);
expect(find.byType(CupertinoButton), findsWidgets);
});
testWidgets('the gallery previews markdown through the chat renderer', (
tester,
) async {
await _openMarkdownFromGallery(tester, cupertino: false);
await _openMarkdownFromGallery(tester);
expect(find.byType(ArtifactViewerPage), findsOneWidget);
expect(find.byType(ChatMarkdownView), findsOneWidget);
@@ -583,7 +551,6 @@ void main() {
) async {
await _openMarkdownFromGallery(
tester,
cupertino: false,
name: 'notes.markdown',
contentType: '',
);
@@ -597,29 +564,6 @@ void main() {
expect(find.text('type not recorded · 4.0\u00a0KiB'), findsOneWidget);
});
testWidgets('Cupertino markdown preview is native at 320px and 2x text', (
tester,
) async {
tester.view.physicalSize = const Size(640, 1200);
tester.view.devicePixelRatio = 2;
tester.platformDispatcher.textScaleFactorTestValue = 2;
tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);
await _openMarkdownFromGallery(tester, cupertino: true);
expect(tester.takeException(), isNull);
expect(find.byType(ChatMarkdownView), findsOneWidget);
expect(find.text('Report'), findsOneWidget);
expect(find.text('dart'), findsOneWidget);
expect(find.text('1 of 1 · text/markdown'), findsOneWidget);
// The viewer and its markdown add no Material control to a Cupertino host.
expect(find.byType(Material), findsNothing);
});
testWidgets('a swipe moves to the next and previous artifact', (
tester,
) async {
@@ -651,83 +595,71 @@ void main() {
expect(find.textContaining('1 of 2'), findsWidgets);
});
for (final cupertino in [false, true]) {
testWidgets(
'pinch owns image pan and native reset (Cupertino=$cupertino)',
(tester) async {
final first = recordedArtifact(
'a.png',
url: '/artifacts/1/1/a.png',
contentType: 'image/png',
);
final second = recordedArtifact(
'b.png',
url: '/artifacts/1/2/b.png',
contentType: 'image/png',
);
final groups = [
_group([first], visit: 1),
_group([second], visit: 2),
];
await _pumpViewer(
tester,
groups: groups,
cupertino: cupertino,
selected: artifactVisitIdentity(groups[0], first),
);
final viewport = tester.getRect(
find.byKey(const Key('artifact-image-zoom')),
);
final center = viewport.center;
final one = await tester.startGesture(
center + const Offset(-30, 0),
pointer: 1,
);
final two = await tester.startGesture(
center + const Offset(30, 0),
pointer: 2,
);
await one.moveTo(center + const Offset(-110, 0));
await two.moveTo(center + const Offset(110, 0));
await tester.pump();
await one.up();
await two.up();
await tester.pumpAndSettle();
expect(
find.byKey(const Key('artifact-image-reset-zoom')),
findsOneWidget,
);
expect(
tester.widget(find.byKey(const Key('artifact-image-reset-zoom'))),
cupertino ? isA<CupertinoButton>() : isA<IconButton>(),
);
// A one-finger drag now belongs to the zoomed image, not the gallery.
await tester.fling(
find.byKey(const Key('artifact-image-zoom')),
const Offset(-300, 0),
1000,
);
await tester.pumpAndSettle();
expect(find.textContaining('1 of 2'), findsWidgets);
await tester.tap(find.byKey(const Key('artifact-image-reset-zoom')));
await tester.pumpAndSettle();
expect(
find.byKey(const Key('artifact-image-reset-zoom')),
findsNothing,
);
await tester.fling(
find.byKey(const Key('artifact-viewer-swipe')),
const Offset(-300, 0),
1000,
);
await tester.pumpAndSettle();
expect(find.textContaining('2 of 2'), findsWidgets);
},
testWidgets('pinch owns image pan and native reset', (tester) async {
final first = recordedArtifact(
'a.png',
url: '/artifacts/1/1/a.png',
contentType: 'image/png',
);
}
final second = recordedArtifact(
'b.png',
url: '/artifacts/1/2/b.png',
contentType: 'image/png',
);
final groups = [
_group([first], visit: 1),
_group([second], visit: 2),
];
await _pumpViewer(
tester,
groups: groups,
selected: artifactVisitIdentity(groups[0], first),
);
final viewport = tester.getRect(
find.byKey(const Key('artifact-image-zoom')),
);
final center = viewport.center;
final one = await tester.startGesture(
center + const Offset(-30, 0),
pointer: 1,
);
final two = await tester.startGesture(
center + const Offset(30, 0),
pointer: 2,
);
await one.moveTo(center + const Offset(-110, 0));
await two.moveTo(center + const Offset(110, 0));
await tester.pump();
await one.up();
await two.up();
await tester.pumpAndSettle();
expect(find.byKey(const Key('artifact-image-reset-zoom')), findsOneWidget);
expect(
tester.widget(find.byKey(const Key('artifact-image-reset-zoom'))),
isA<IconButton>(),
);
// A one-finger drag now belongs to the zoomed image, not the gallery.
await tester.fling(
find.byKey(const Key('artifact-image-zoom')),
const Offset(-300, 0),
1000,
);
await tester.pumpAndSettle();
expect(find.textContaining('1 of 2'), findsWidgets);
await tester.tap(find.byKey(const Key('artifact-image-reset-zoom')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('artifact-image-reset-zoom')), findsNothing);
await tester.fling(
find.byKey(const Key('artifact-viewer-swipe')),
const Offset(-300, 0),
1000,
);
await tester.pumpAndSettle();
expect(find.textContaining('2 of 2'), findsWidgets);
});
testWidgets('Material paging stays inside 320px at 2x text', (tester) async {
tester.view.physicalSize = const Size(640, 1200);
@@ -770,57 +702,49 @@ void main() {
}
});
for (final cupertino in [false, true]) {
for (final size in [
const Size(390, 844),
const Size(880, 1000),
const Size(1100, 800),
]) {
testWidgets(
'${cupertino ? 'Cupertino' : 'Material'} pager clears stacked bar at $size',
(tester) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final first = recordedArtifact(
'a.png',
url: '/artifacts/1/1/a.png',
contentType: 'image/png',
);
final second = recordedArtifact(
'b.png',
url: '/artifacts/1/2/b.png',
contentType: 'image/png',
);
final groups = [
_group([first], visit: 1),
_group([second], visit: 2),
];
await _pumpViewer(
tester,
groups: groups,
selected: artifactVisitIdentity(groups[0], first),
cupertino: cupertino,
bottomClearance: 120,
);
final pager = tester.getRect(find.byKey(artifactNextKey));
expect(pager.bottom, lessThanOrEqualTo(size.height - 120));
// Right above the stacked bar, not lifted by its clearance twice
// (the bar is one 56 px pill above the inset plus its margin).
expect(pager.bottom, greaterThanOrEqualTo(size.height - 120 - 56));
// The preview sits between the bars, never behind either.
final preview = tester.getRect(
find.byType(ArtifactPreviewBody).first,
);
final actions = tester.getRect(
find.byKey(const Key('artifact-viewer-actions')),
);
final topBar = tester.getRect(find.byType(SegmentedBar).first);
expect(preview.bottom, lessThanOrEqualTo(actions.top));
expect(preview.top, greaterThanOrEqualTo(topBar.bottom - 1));
},
for (final size in [
const Size(390, 844),
const Size(880, 1000),
const Size(1100, 800),
]) {
testWidgets('pager clears stacked bar at $size', (tester) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final first = recordedArtifact(
'a.png',
url: '/artifacts/1/1/a.png',
contentType: 'image/png',
);
}
final second = recordedArtifact(
'b.png',
url: '/artifacts/1/2/b.png',
contentType: 'image/png',
);
final groups = [
_group([first], visit: 1),
_group([second], visit: 2),
];
await _pumpViewer(
tester,
groups: groups,
selected: artifactVisitIdentity(groups[0], first),
bottomClearance: 120,
);
final pager = tester.getRect(find.byKey(artifactNextKey));
expect(pager.bottom, lessThanOrEqualTo(size.height - 120));
// Right above the stacked bar, not lifted by its clearance twice
// (the bar is one 56 px pill above the inset plus its margin).
expect(pager.bottom, greaterThanOrEqualTo(size.height - 120 - 56));
// The preview sits between the bars, never behind either.
final preview = tester.getRect(find.byType(ArtifactPreviewBody).first);
final actions = tester.getRect(
find.byKey(const Key('artifact-viewer-actions')),
);
final topBar = tester.getRect(find.byType(SegmentedBar).first);
expect(preview.bottom, lessThanOrEqualTo(actions.top));
expect(preview.top, greaterThanOrEqualTo(topBar.bottom - 1));
});
}
testWidgets('Escape closes the viewer back to the gallery', (tester) async {
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_record.dart';
@@ -52,10 +51,9 @@ ArtifactGroup visitGroup({
return ArtifactGroup(stageKey: stageKey, visit: visit, artifacts: artifacts);
}
/// The list under the native host it is composed into, with the optional
/// The list under the Material host it is composed into, with the optional
/// grouped page colour a gallery must supply.
Widget artifactListHost({
required bool cupertino,
required List<ArtifactGroup> groups,
String? selectedIdentity,
ArtifactSelected? onSelected,
@@ -73,16 +71,8 @@ Widget artifactListHost({
).copyWith(textScaler: TextScaler.linear(textScale)),
child: child ?? const SizedBox.shrink(),
);
return cupertino
? CupertinoApp(
builder: scaled,
home: CupertinoPageScaffold(
backgroundColor: CupertinoColors.systemGroupedBackground,
child: list,
),
)
: MaterialApp(
builder: scaled,
home: Scaffold(body: list),
);
return MaterialApp(
builder: scaled,
home: Scaffold(body: list),
);
}
@@ -32,35 +32,25 @@ List<ArtifactGroup> _threeGroups() => [
];
void main() {
testWidgets('every group heading is a header node under both hosts', (
tester,
) async {
testWidgets('every group heading is a header node', (tester) async {
final handle = tester.ensureSemantics();
for (final cupertino in <bool>[false, true]) {
await tester.pumpWidget(
artifactListHost(cupertino: cupertino, groups: _threeGroups()),
await tester.pumpWidget(artifactListHost(groups: _threeGroups()));
for (final label in <String>[
'build · visit 1',
'review · visit 1',
'review · visit 2',
]) {
expect(
tester.getSemantics(find.text(label)),
isSemantics(label: label, isHeader: true),
reason: '$label must be exposed as a heading',
);
for (final label in <String>[
'build · visit 1',
'review · visit 1',
'review · visit 2',
]) {
expect(
tester.getSemantics(find.text(label)),
isSemantics(label: label, isHeader: true),
reason:
'${cupertino ? 'Cupertino' : 'Material'} must expose $label as a '
'heading',
);
}
}
handle.dispose();
});
testWidgets('a Cupertino heading stays separate from its single row', (
tester,
) async {
testWidgets('a heading stays separate from its single row', (tester) async {
final handle = tester.ensureSemantics();
final group = visitGroup(
visit: 2,
@@ -74,7 +64,7 @@ void main() {
],
);
await tester.pumpWidget(
artifactListHost(cupertino: true, groups: [group], onSelected: (_, _) {}),
artifactListHost(groups: [group], onSelected: (_, _) {}),
);
final heading = tester.getSemantics(find.text('review · visit 2'));
@@ -105,9 +95,7 @@ void main() {
handle.dispose();
});
testWidgets('rows without a callback expose no tap action under both hosts', (
tester,
) async {
testWidgets('rows without a callback expose no tap action', (tester) async {
final handle = tester.ensureSemantics();
final group = visitGroup(
artifacts: [
@@ -115,24 +103,20 @@ void main() {
],
);
for (final cupertino in <bool>[false, true]) {
await tester.pumpWidget(
artifactListHost(cupertino: cupertino, groups: [group]),
);
final row = tester.getSemantics(find.text('result.csv'));
expect(
row.getSemanticsData().hasAction(SemanticsAction.tap),
isFalse,
reason: 'without onSelected the row is read-only',
);
expect(
row,
isSemantics(isButton: false),
reason: 'a read-only row must not expose a button role',
);
await tester.tap(find.text('result.csv'));
expect(tester.takeException(), isNull);
}
await tester.pumpWidget(artifactListHost(groups: [group]));
final row = tester.getSemantics(find.text('result.csv'));
expect(
row.getSemanticsData().hasAction(SemanticsAction.tap),
isFalse,
reason: 'without onSelected the row is read-only',
);
expect(
row,
isSemantics(isButton: false),
reason: 'a read-only row must not expose a button role',
);
await tester.tap(find.text('result.csv'));
expect(tester.takeException(), isNull);
handle.dispose();
});
@@ -150,7 +134,6 @@ void main() {
);
await tester.pumpWidget(
artifactListHost(
cupertino: true,
groups: [first, second],
selectedIdentity: artifactVisitIdentity(
second,
@@ -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/features/artifacts/ui/artifact_tile.dart';
@@ -10,31 +9,20 @@ import 'package:pipelines_app/ui/layout/sticky_section.dart';
import 'artifact_visit_list_fixture.dart';
void main() {
for (final cupertino in [false, true]) {
testWidgets(
'${cupertino ? 'Cupertino' : 'Material'} artifact groups start collapsed and expand',
(tester) async {
final group = visitGroup(artifacts: [recordedArtifact('result.csv')]);
await tester.pumpWidget(
cupertino
? CupertinoApp(
home: CupertinoPageScaffold(
child: ArtifactVisitList(groups: [group]),
),
)
: MaterialApp(
home: Scaffold(body: ArtifactVisitList(groups: [group])),
),
);
expect(find.byType(ArtifactTile), findsNothing);
expect(find.bySemanticsLabel('review · visit 1'), findsOneWidget);
await tester.tap(find.byType(StickySectionTitle));
await tester.pumpAndSettle();
expect(find.byType(ArtifactTile), findsOneWidget);
},
testWidgets('artifact groups start collapsed and expand', (tester) async {
final group = visitGroup(artifacts: [recordedArtifact('result.csv')]);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(body: ArtifactVisitList(groups: [group])),
),
);
}
expect(find.byType(ArtifactTile), findsNothing);
expect(find.bySemanticsLabel('review · visit 1'), findsOneWidget);
await tester.tap(find.byType(StickySectionTitle));
await tester.pumpAndSettle();
expect(find.byType(ArtifactTile), findsOneWidget);
});
test('a shared filename in two visits has distinct identities', () {
const url = '/artifacts/7/result.csv';
@@ -112,7 +100,6 @@ void main() {
ArtifactRecord? pickedArtifact;
await tester.pumpWidget(
artifactListHost(
cupertino: false,
groups: [first, second],
selectedIdentity: artifactVisitIdentity(
second,
@@ -147,48 +134,7 @@ void main() {
expect(pickedArtifact!.url, '/artifacts/7/2/result.csv');
});
testWidgets('Cupertino shows a grid of tiles and selects per visit', (
tester,
) async {
final first = visitGroup(
visit: 1,
artifacts: [
recordedArtifact('result.csv', url: '/artifacts/7/1/result.csv'),
],
);
final second = visitGroup(
visit: 2,
artifacts: [
recordedArtifact('result.csv', url: '/artifacts/7/2/result.csv'),
],
);
ArtifactGroup? pickedGroup;
await tester.pumpWidget(
artifactListHost(
cupertino: true,
groups: [first, second],
selectedIdentity: artifactVisitIdentity(first, first.artifacts.single),
onSelected: (selectedGroup, _) => pickedGroup = selectedGroup,
),
);
// A grid tile per artifact, no Material list tiles.
expect(find.byType(ArtifactTile), findsNWidgets(2));
expect(find.byType(ListTile), findsNothing);
expect(
tester
.widgetList<ArtifactTile>(find.byType(ArtifactTile))
.where((tile) => tile.selected),
hasLength(1),
);
await tester.tap(find.text('result.csv').last);
expect(pickedGroup, same(second));
});
testWidgets('long names fit their tile at 2x under both native hosts', (
tester,
) async {
testWidgets('long names fit their tile at 2x', (tester) async {
tester.view.devicePixelRatio = 2;
tester.view.physicalSize = const Size(780, 1560);
addTearDown(tester.view.resetPhysicalSize);
@@ -206,22 +152,19 @@ void main() {
],
);
for (final cupertino in <bool>[false, true]) {
await tester.pumpWidget(
artifactListHost(
cupertino: cupertino,
groups: [withLongName],
textScale: 2,
onSelected: (_, _) {},
),
);
expect(tester.takeException(), isNull);
// A tile shows one line of the name; its accessible name is whole.
expect(
find.bySemanticsLabel(RegExp(RegExp.escape(longArtifactName))),
findsOneWidget,
);
}
await tester.pumpWidget(
artifactListHost(
groups: [withLongName],
textScale: 2,
onSelected: (_, _) {},
),
);
expect(tester.takeException(), isNull);
// A tile shows one line of the name; its accessible name is whole.
expect(
find.bySemanticsLabel(RegExp(RegExp.escape(longArtifactName))),
findsOneWidget,
);
});
testWidgets('a missing name and content type stay explicit', (tester) async {
@@ -236,9 +179,7 @@ void main() {
),
],
);
await tester.pumpWidget(
artifactListHost(cupertino: false, groups: [group]),
);
await tester.pumpWidget(artifactListHost(groups: [group]));
expect(find.text('(unnamed artifact)'), findsOneWidget);
expect(
@@ -254,9 +195,7 @@ void main() {
});
testWidgets('empty groups keep the honest empty wording', (tester) async {
await tester.pumpWidget(
artifactListHost(cupertino: false, groups: const <ArtifactGroup>[]),
);
await tester.pumpWidget(artifactListHost(groups: const <ArtifactGroup>[]));
expect(find.text('No stage artifacts recorded.'), findsOneWidget);
expect(find.byType(ListTile), findsNothing);
});
@@ -319,11 +258,7 @@ void main() {
],
);
await tester.pumpWidget(
artifactListHost(
cupertino: false,
groups: [group],
onSelected: (_, _) {},
),
artifactListHost(groups: [group], onSelected: (_, _) {}),
);
expect(find.byType(ArtifactTile), findsNWidgets(2));
@@ -25,39 +25,30 @@ void main() {
durationMs: 50,
);
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('Dismiss removes a finished card without a notice', (
tester,
) async {
gateway.runs = [finished('run_done'), shellRecord('run_live')];
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
testWidgets('$host: Dismiss removes a finished card without a notice', (
tester,
) async {
gateway.runs = [finished('run_done'), shellRecord('run_live')];
await tester.pumpWidget(shellThread(gateway, cupertino: cupertino));
await tester.pump();
expect(card(), findsNWidgets(2));
// Only the finished card offers Dismiss; a running one must stop first.
expect(dismiss, findsOneWidget);
expect(find.byTooltip('Dismiss'), findsOneWidget);
expect(card(), findsNWidgets(2));
// Only the finished card offers Dismiss; a running one must stop first.
expect(dismiss, findsOneWidget);
expect(
cupertino
? find.bySemanticsLabel('Dismiss')
: find.byTooltip('Dismiss'),
findsOneWidget,
);
await tester.tap(dismiss);
await tester.pump();
await tester.pump(const Duration(milliseconds: 300));
expect(gateway.bodies('chat_shell_dismiss').single['run_ids'], [
'run_done',
]);
expect(card(), findsOneWidget);
expect(find.text('\$ true'), findsNothing);
expect(notice, findsNothing);
expect(find.text('Command dismissed'), findsNothing);
expect(find.text('Undo'), findsNothing);
});
}
await tester.tap(dismiss);
await tester.pump();
await tester.pump(const Duration(milliseconds: 300));
expect(gateway.bodies('chat_shell_dismiss').single['run_ids'], [
'run_done',
]);
expect(card(), findsOneWidget);
expect(find.text('\$ true'), findsNothing);
expect(notice, findsNothing);
expect(find.text('Command dismissed'), findsNothing);
expect(find.text('Undo'), findsNothing);
});
testWidgets('a refused dismissal brings the card back with the reason', (
tester,
@@ -1,6 +1,5 @@
import 'dart:async';
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';
@@ -168,7 +167,7 @@ String terminalText(WidgetTester tester, {int index = 0}) {
return lines.join('\n');
}
Widget shellThread(ShellGateway gateway, {bool cupertino = false}) {
Widget shellThread(ShellGateway gateway) {
final thread = ChatThreadView(
gateway: gateway,
sessionId: 's',
@@ -176,7 +175,5 @@ Widget shellThread(ShellGateway gateway, {bool cupertino = false}) {
onBack: () {},
drafts: MemoryChatDraftStore(),
);
return cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: thread))
: MaterialApp(home: Scaffold(body: thread));
return MaterialApp(home: Scaffold(body: thread));
}
@@ -14,89 +14,79 @@ void main() {
Finder card() => find.bySemanticsIdentifier('chat-shell-run-card');
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('a running command streams output and stops', (tester) async {
gateway.runs = [shellRecord('run_a', output: 'line 1\n')];
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
testWidgets('$host: a running command streams output and stops', (
tester,
) async {
gateway.runs = [shellRecord('run_a', output: 'line 1\n')];
await tester.pumpWidget(shellThread(gateway, cupertino: cupertino));
await tester.pump();
expect(card(), findsOneWidget);
expect(find.text('\$ make test'), findsOneWidget);
expect(find.byKey(const Key('chat-shell-run-running')), findsOneWidget);
gateway.emitOutput('run_a', 'line 2\n', 7);
await tester.pump();
expect(terminalText(tester), 'line 1\nline 2');
expect(find.byKey(const Key('chat-shell-run-share')), findsNothing);
expect(card(), findsOneWidget);
expect(find.text('\$ make test'), findsOneWidget);
expect(find.byKey(const Key('chat-shell-run-running')), findsOneWidget);
gateway.emitOutput('run_a', 'line 2\n', 7);
await tester.pump();
expect(terminalText(tester), 'line 1\nline 2');
expect(find.byKey(const Key('chat-shell-run-share')), findsNothing);
await tester.tap(find.byKey(const Key('chat-shell-run-stop')));
await tester.pump();
expect(gateway.bodies('chat_shell_stop').single['run_id'], 'run_a');
expect(find.text('Stopping…'), findsOneWidget);
await tester.tap(find.byKey(const Key('chat-shell-run-stop')));
await tester.pump();
expect(gateway.bodies('chat_shell_stop').single['run_id'], 'run_a');
expect(find.text('Stopping…'), findsOneWidget);
gateway.emitRun(shellRecord('run_a', status: 'stopped', durationMs: 2400));
await tester.pump();
expect(find.byKey(const Key('chat-shell-run-running')), findsNothing);
expect(find.text('Stopped · 2.4 s'), findsOneWidget);
expect(find.byKey(const Key('chat-shell-run-stop')), findsNothing);
// The streamed output stays after the lifecycle frame.
expect(terminalText(tester), 'line 1\nline 2');
});
gateway.emitRun(
shellRecord('run_a', status: 'stopped', durationMs: 2400),
);
await tester.pump();
expect(find.byKey(const Key('chat-shell-run-running')), findsNothing);
expect(find.text('Stopped · 2.4 s'), findsOneWidget);
expect(find.byKey(const Key('chat-shell-run-stop')), findsNothing);
// The streamed output stays after the lifecycle frame.
expect(terminalText(tester), 'line 1\nline 2');
});
testWidgets('finished commands show their exit status', (tester) async {
gateway.runs = [
shellRecord(
'run_ok',
command: 'true',
status: 'exited',
exitCode: 0,
output: 'fine\n',
durationMs: 120,
),
shellRecord(
'run_bad',
command: 'false',
status: 'exited',
exitCode: 1,
output: 'broken\n',
durationMs: 3000,
),
];
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
// Finished terminals shrink to their output after their first frame.
await tester.pumpAndSettle();
testWidgets('$host: finished commands show their exit status', (
tester,
) async {
gateway.runs = [
shellRecord(
'run_ok',
command: 'true',
status: 'exited',
exitCode: 0,
output: 'fine\n',
durationMs: 120,
),
shellRecord(
'run_bad',
command: 'false',
status: 'exited',
exitCode: 1,
output: 'broken\n',
durationMs: 3000,
),
];
await tester.pumpWidget(shellThread(gateway, cupertino: cupertino));
await tester.pump();
// Finished terminals shrink to their output after their first frame.
await tester.pumpAndSettle();
expect(card(), findsNWidgets(2));
expect(find.text('Exit 0 · 120 ms'), findsOneWidget);
expect(find.text('Exit 1 · 3.0 s'), findsOneWidget);
expect(find.byKey(const Key('chat-shell-run-copy')), findsNWidgets(2));
});
expect(card(), findsNWidgets(2));
expect(find.text('Exit 0 · 120 ms'), findsOneWidget);
expect(find.text('Exit 1 · 3.0 s'), findsOneWidget);
expect(find.byKey(const Key('chat-shell-run-copy')), findsNWidgets(2));
});
testWidgets('Send to agent shares the run once', (tester) async {
gateway.runs = [
shellRecord('run_a', status: 'exited', exitCode: 0, output: 'ok\n'),
];
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
testWidgets('$host: Send to agent shares the run once', (tester) async {
gateway.runs = [
shellRecord('run_a', status: 'exited', exitCode: 0, output: 'ok\n'),
];
await tester.pumpWidget(shellThread(gateway, cupertino: cupertino));
await tester.pump();
expect(gateway.calls.where((c) => c.type == 'chat_prompt'), isEmpty);
await tester.tap(find.byKey(const Key('chat-shell-run-share')));
await tester.pump();
expect(gateway.bodies('chat_shell_share').single['run_id'], 'run_a');
expect(find.text('Sent to agent'), findsOneWidget);
await tester.tap(find.byKey(const Key('chat-shell-run-share')));
await tester.pump();
expect(gateway.bodies('chat_shell_share'), hasLength(1));
});
}
expect(gateway.calls.where((c) => c.type == 'chat_prompt'), isEmpty);
await tester.tap(find.byKey(const Key('chat-shell-run-share')));
await tester.pump();
expect(gateway.bodies('chat_shell_share').single['run_id'], 'run_a');
expect(find.text('Sent to agent'), findsOneWidget);
await tester.tap(find.byKey(const Key('chat-shell-run-share')));
await tester.pump();
expect(gateway.bodies('chat_shell_share'), hasLength(1));
});
testWidgets('Copy output copies the plain-text rendering', (tester) async {
final copied = <String>[];
@@ -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';
@@ -8,8 +7,6 @@ import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
import '../../artifacts/domain/artifact_fixtures.dart';
enum _Platform { material, cupertino }
class _FakeGateway implements ApiGateway {
_FakeGateway(this.detail);
final JsonMap detail;
@@ -34,7 +31,6 @@ JsonMap _run({required List<JsonMap> steps}) => <String, dynamic>{
Future<void> _pumpDetail(
WidgetTester tester,
_Platform platform,
RunsController controller,
ApiGateway gateway,
) async {
@@ -46,17 +42,7 @@ Future<void> _pumpDetail(
gateway: gateway,
onBack: () {},
);
await tester.pumpWidget(
platform == _Platform.material
? MaterialApp(home: Scaffold(body: view))
: CupertinoApp(
builder: (context, app) => Theme(
data: ThemeData(platform: TargetPlatform.iOS),
child: app!,
),
home: CupertinoPageScaffold(child: view),
),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: view)));
await tester.pumpAndSettle();
}
@@ -67,61 +53,49 @@ Future<RunsController> _loaded(ApiGateway gateway) async {
}
void main() {
for (final platform in _Platform.values) {
testWidgets('${platform.name}: the action opens the recorded groups', (
tester,
) async {
final gateway = _FakeGateway(
_run(
steps: [
step(
stage: 'implementer',
sequence: 1,
artifacts: [
artifact(
'build.log',
contentType: 'text/plain',
sizeBytes: 2337,
),
],
),
step(
stage: 'reviewer',
sequence: 2,
artifacts: [
artifact(
'shot.png',
contentType: 'image/png',
sizeBytes: 80544,
),
],
),
],
),
);
final controller = await _loaded(gateway);
addTearDown(controller.dispose);
await _pumpDetail(tester, platform, controller, gateway);
testWidgets('the action opens the recorded groups', (tester) async {
final gateway = _FakeGateway(
_run(
steps: [
step(
stage: 'implementer',
sequence: 1,
artifacts: [
artifact('build.log', contentType: 'text/plain', sizeBytes: 2337),
],
),
step(
stage: 'reviewer',
sequence: 2,
artifacts: [
artifact('shot.png', contentType: 'image/png', sizeBytes: 80544),
],
),
],
),
);
final controller = await _loaded(gateway);
addTearDown(controller.dispose);
await _pumpDetail(tester, controller, gateway);
expect(
find.byKey(const ValueKey('run-detail-tab-artifacts')),
findsOneWidget,
);
await tester.ensureVisible(
find.byKey(const ValueKey('run-detail-tab-artifacts')),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('run-detail-tab-artifacts')));
await tester.pumpAndSettle();
// Artifact groups start open: the files show without a tap.
expect(
find.byKey(const ValueKey('run-detail-tab-artifacts')),
findsOneWidget,
);
await tester.ensureVisible(
find.byKey(const ValueKey('run-detail-tab-artifacts')),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('run-detail-tab-artifacts')));
await tester.pumpAndSettle();
// Artifact groups start open: the files show without a tap.
expect(find.text('Artifacts · 2 recorded'), findsOneWidget);
expect(find.text('build.log'), findsOneWidget);
expect(find.text('shot.png'), findsOneWidget);
expect(find.text('implementer · visit 1'), findsOneWidget);
expect(find.text('reviewer · visit 1'), findsOneWidget);
});
}
expect(find.text('Artifacts · 2 recorded'), findsOneWidget);
expect(find.text('build.log'), findsOneWidget);
expect(find.text('shot.png'), findsOneWidget);
expect(find.text('implementer · visit 1'), findsOneWidget);
expect(find.text('reviewer · visit 1'), findsOneWidget);
});
testWidgets('the action is offered only when the detail has steps', (
tester,
@@ -129,7 +103,7 @@ void main() {
final gateway = _FakeGateway(_run(steps: const []));
final controller = await _loaded(gateway);
addTearDown(controller.dispose);
await _pumpDetail(tester, _Platform.material, controller, gateway);
await _pumpDetail(tester, controller, gateway);
expect(
find.byKey(const ValueKey('run-detail-tab-artifacts')),
findsNothing,
@@ -146,7 +120,7 @@ void main() {
);
final controller = await _loaded(gateway);
addTearDown(controller.dispose);
await _pumpDetail(tester, _Platform.material, controller, gateway);
await _pumpDetail(tester, controller, gateway);
await tester.ensureVisible(
find.byKey(const ValueKey('run-detail-tab-artifacts')),
@@ -167,7 +141,7 @@ void main() {
);
final controller = await _loaded(gateway);
addTearDown(controller.dispose);
await _pumpDetail(tester, _Platform.material, controller, gateway);
await _pumpDetail(tester, controller, gateway);
await tester.ensureVisible(
find.byKey(const ValueKey('run-detail-tab-artifacts')),
@@ -21,7 +21,7 @@ void main() {
)
.position;
for (final platform in RunDetailTestPlatform.values) {
for (final platform in const [RunDetailTestPlatform.material]) {
testWidgets('${platform.name} run header floats under the bar and the '
'tab scrolls behind both', (tester) async {
await pumpRunDetail(tester, platform, size: const Size(390, 520));
@@ -26,13 +26,15 @@ void main() {
expect(tester.takeException(), isNull);
});
testWidgets('${platform.name} the stage Session nests no group in a '
'group', (tester) async {
await openVisit(tester, platform);
await openVisitTab(tester, RunVisitSection.session);
expect(find.text('Turn documents'), findsOneWidget);
expect(find.byType(CupertinoListSection), findsNothing);
});
if (platform == RunDetailTestPlatform.material) {
testWidgets('${platform.name} the stage Session nests no group in a '
'group', (tester) async {
await openVisit(tester, platform);
await openVisitTab(tester, RunVisitSection.session);
expect(find.text('Turn documents'), findsOneWidget);
expect(find.byType(CupertinoListSection), findsNothing);
});
}
testWidgets('${platform.name} beside a list the tabs and the header '
'share one row', (tester) async {
@@ -1,6 +1,5 @@
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -20,7 +19,7 @@ JsonMap document(String name, int sequence, {String? url}) => {
};
void main() {
for (final platform in RunDetailTestPlatform.values) {
for (final platform in const [RunDetailTestPlatform.material]) {
testWidgets(
'${platform.name} Session exposes exact repeated visit documents',
(tester) async {
@@ -87,11 +86,7 @@ void main() {
},
);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pumpWidget(
platform == RunDetailTestPlatform.cupertino
? CupertinoApp(home: preview)
: MaterialApp(home: preview),
);
await tester.pumpWidget(MaterialApp(home: preview));
await tester.pumpAndSettle();
expect(fetched.single.path, '/artifacts/3/$name');
expect(find.text('Raw $name visit 3'), findsOneWidget);
@@ -17,7 +17,7 @@ Future<void> _showTurnDocuments(WidgetTester tester) async {
}
void main() {
for (final platform in RunDetailTestPlatform.values) {
for (final platform in const [RunDetailTestPlatform.material]) {
testWidgets('${platform.name} stage tabs sit at the bottom with one Back', (
tester,
) async {
@@ -221,7 +221,7 @@ void main() {
});
}
for (final platform in RunDetailTestPlatform.values) {
for (final platform in const [RunDetailTestPlatform.material]) {
for (final size in const [
Size(390, 844),
Size(884, 832),
@@ -8,7 +8,7 @@ import 'run_detail_graph_support.dart';
import 'run_detail_visit_support.dart';
void main() {
for (final platform in RunDetailTestPlatform.values) {
for (final platform in const [RunDetailTestPlatform.material]) {
testWidgets('${platform.name} legacy session.html stays openable', (
tester,
) async {
@@ -9,7 +9,7 @@ import 'run_detail_graph_support.dart';
import 'run_detail_visit_support.dart';
void main() {
for (final platform in RunDetailTestPlatform.values) {
for (final platform in const [RunDetailTestPlatform.material]) {
testWidgets('${platform.name} visit shows only its recorded facts', (
tester,
) async {
@@ -107,7 +107,7 @@ void _expectSummarySection(RunSearchTarget target, RunSummarySection? section) {
const _origin = 'http://127.0.0.1:8096';
void main() {
for (final platform in RunDetailTestPlatform.values) {
for (final platform in const [RunDetailTestPlatform.material]) {
testWidgets('${platform.name} artifact hit opens its recorded visit', (
tester,
) async {
@@ -145,7 +145,7 @@ void main() {
return {...run, 'steps': steps};
}
for (final platform in RunDetailTestPlatform.values) {
for (final platform in const [RunDetailTestPlatform.material]) {
testWidgets('${platform.name} artifact hit opens that artifact over the '
'Artifacts tab, and the timeline keeps working afterwards', (
tester,