Merge commit '544cd8128d5b360a0c8a552fe0987024a311a22a' into pipelines/run-20261111-0449-cupertino-out-settings-part-1-c39d
This commit is contained in:
@@ -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));
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/pipelines/screen.dart';
|
||||
@@ -52,19 +50,13 @@ FakeGateway archiveGateway(PipelineFixture fixture, {String? refusal}) {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> pump(
|
||||
WidgetTester tester,
|
||||
FakeGateway gateway, {
|
||||
bool cupertino = false,
|
||||
}) async {
|
||||
Future<void> pump(WidgetTester tester, FakeGateway gateway) async {
|
||||
tester.view.physicalSize = const Size(1100, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final screen = PipelinesScreen(gateway: gateway);
|
||||
await tester.pumpWidget(
|
||||
cupertino ? CupertinoApp(home: screen) : MaterialApp(home: screen),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: screen));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
@@ -161,24 +153,4 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(rowNamed('Alpha review'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino archives through the action sheet and alert', (
|
||||
tester,
|
||||
) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
||||
try {
|
||||
final gateway = archiveGateway(PipelineFixture());
|
||||
await pump(tester, gateway, cupertino: true);
|
||||
await tester.tap(rowNamed('Beta deploy'));
|
||||
await tester.pumpAndSettle();
|
||||
await openMenuItem(tester, 'pipeline-archive');
|
||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('pipeline-archive-confirm')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.callsOf('archive_pipeline'), hasLength(1));
|
||||
expect(rowNamed('Beta deploy'), findsNothing);
|
||||
} finally {
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
@@ -21,44 +20,31 @@ class _Gateway implements ApiGateway {
|
||||
Stream<JsonMap> get frames => const Stream.empty();
|
||||
}
|
||||
|
||||
Widget _host(
|
||||
_Gateway gateway, {
|
||||
bool cupertino = false,
|
||||
String source = '# stage build',
|
||||
}) {
|
||||
Widget _host(_Gateway gateway, {String source = '# stage build'}) {
|
||||
final body = Column(
|
||||
children: [
|
||||
const Text('Pipeline source remains available'),
|
||||
PipelineDefinitionValidation(gateway: gateway, source: source),
|
||||
],
|
||||
);
|
||||
return cupertino
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: body)),
|
||||
)
|
||||
: MaterialApp(home: Scaffold(body: body));
|
||||
return MaterialApp(home: Scaffold(body: body));
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'definition warnings stay visible on ${cupertino ? 'Cupertino' : 'Material'}',
|
||||
(tester) async {
|
||||
final gateway = _Gateway()
|
||||
..answer = () async => {
|
||||
'type': 'validated',
|
||||
'warnings': ['Review prompt exceeds 2000 bytes.', '', 42],
|
||||
};
|
||||
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Definition warnings'), findsOneWidget);
|
||||
expect(find.text('Review prompt exceeds 2000 bytes.'), findsOneWidget);
|
||||
expect(find.text('42'), findsNothing);
|
||||
expect(gateway.calls.single, {'source': '# stage build'});
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
testWidgets('definition warnings stay visible', (tester) async {
|
||||
final gateway = _Gateway()
|
||||
..answer = () async => {
|
||||
'type': 'validated',
|
||||
'warnings': ['Review prompt exceeds 2000 bytes.', '', 42],
|
||||
};
|
||||
await tester.pumpWidget(_host(gateway));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Definition warnings'), findsOneWidget);
|
||||
expect(find.text('Review prompt exceeds 2000 bytes.'), findsOneWidget);
|
||||
expect(find.text('42'), findsNothing);
|
||||
expect(gateway.calls.single, {'source': '# stage build'});
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'loading validation never hides detail and a source is checked once',
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
@@ -211,34 +209,4 @@ void main() {
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino keeps the shared row with the same row identity', (
|
||||
tester,
|
||||
) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
||||
tester.view.physicalSize = const Size(1100, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
try {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: PipelinesScreen(gateway: gatewayFor(PipelineFixture())),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
tester
|
||||
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
|
||||
.cupertino,
|
||||
isTrue,
|
||||
);
|
||||
expect(find.text('2 stages · 1 schedule'), findsOneWidget);
|
||||
expect(find.textContaining('v2 · #'), findsNothing);
|
||||
expect(find.byKey(const Key('pipeline-avatar-1')), findsOneWidget);
|
||||
expect(find.byKey(const Key('pipeline-status-1')), findsOneWidget);
|
||||
} finally {
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,45 +1,35 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/pipelines/widgets/pipeline_scope_control.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final width in [120.0, 500.0]) {
|
||||
testWidgets(
|
||||
'native scope remains usable at $width, Cupertino=$cupertino',
|
||||
(tester) async {
|
||||
var scope = PipelineScope.all;
|
||||
final control = StatefulBuilder(
|
||||
builder: (context, setState) => Center(
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
child: PipelineScopeControl(
|
||||
scope: scope,
|
||||
onSelected: (value) => setState(() => scope = value),
|
||||
),
|
||||
),
|
||||
for (final width in [120.0, 500.0]) {
|
||||
testWidgets('native scope remains usable at $width', (tester) async {
|
||||
var scope = PipelineScope.all;
|
||||
final control = StatefulBuilder(
|
||||
builder: (context, setState) => Center(
|
||||
child: SizedBox(
|
||||
width: width,
|
||||
child: PipelineScopeControl(
|
||||
scope: scope,
|
||||
onSelected: (value) => setState(() => scope = value),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: control))
|
||||
: MaterialApp(home: Scaffold(body: control)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
if (width == 120) {
|
||||
await tester.tap(find.byKey(const Key('pipeline-scope')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Scheduled').last);
|
||||
} else {
|
||||
await tester.tap(find.text('Scheduled'));
|
||||
}
|
||||
await tester.pumpAndSettle();
|
||||
expect(scope, PipelineScope.scheduled);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: control)));
|
||||
await tester.pumpAndSettle();
|
||||
if (width == 120) {
|
||||
await tester.tap(find.byKey(const Key('pipeline-scope')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Scheduled').last);
|
||||
} else {
|
||||
await tester.tap(find.text('Scheduled'));
|
||||
}
|
||||
await tester.pumpAndSettle();
|
||||
expect(scope, PipelineScope.scheduled);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('wide scope control hugs its labels', (tester) async {
|
||||
|
||||
@@ -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/pipelines/screen.dart';
|
||||
@@ -8,68 +7,62 @@ import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
|
||||
import 'fixtures.dart';
|
||||
|
||||
/// The pipeline Summary is flat on both hosts: facts in the shared grid,
|
||||
/// Schedules with Add as its heading's only action (no body Refresh), and
|
||||
/// versions as the shared list row.
|
||||
/// The pipeline Summary is flat: facts in the shared grid, Schedules with Add
|
||||
/// as its heading's only action (no body Refresh), and versions as the shared
|
||||
/// list row.
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('pipeline Summary is a facts grid with flat sections '
|
||||
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
|
||||
final gateway = FakeGateway((type, fields) {
|
||||
return switch (type) {
|
||||
'list_pipelines' => pipelineListReply([
|
||||
pipelineSummary(id: 1, name: 'Alpha review', version: 3),
|
||||
]),
|
||||
'list_runs' => runListReply([]),
|
||||
'get_pipeline' => pipelineDetailReply(
|
||||
pipelineDetail(
|
||||
id: 1,
|
||||
name: 'Alpha review',
|
||||
version: 3,
|
||||
latestVersion: 3,
|
||||
versions: [versionSummary(2), versionSummary(3)],
|
||||
),
|
||||
testWidgets('pipeline Summary is a facts grid with flat sections', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = FakeGateway((type, fields) {
|
||||
return switch (type) {
|
||||
'list_pipelines' => pipelineListReply([
|
||||
pipelineSummary(id: 1, name: 'Alpha review', version: 3),
|
||||
]),
|
||||
'list_runs' => runListReply([]),
|
||||
'get_pipeline' => pipelineDetailReply(
|
||||
pipelineDetail(
|
||||
id: 1,
|
||||
name: 'Alpha review',
|
||||
version: 3,
|
||||
latestVersion: 3,
|
||||
versions: [versionSummary(2), versionSummary(3)],
|
||||
),
|
||||
'list_schedules' => {'type': 'schedules', 'schedules': <dynamic>[]},
|
||||
_ => errorReply('unexpected $type'),
|
||||
};
|
||||
});
|
||||
tester.view.physicalSize = const Size(1100, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final screen = PipelinesScreen(gateway: gateway);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
|
||||
: MaterialApp(home: screen),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(pipelineSummaryFactsKey), findsOneWidget);
|
||||
// Short facts share a line instead of one label/value row each.
|
||||
final latest = tester.getRect(
|
||||
find.byKey(const ValueKey('pipeline-summary-latest-version')),
|
||||
);
|
||||
final versionCreated = tester.getRect(
|
||||
find.byKey(const ValueKey('pipeline-summary-version-created')),
|
||||
);
|
||||
expect(versionCreated.top, moreOrLessEquals(latest.top));
|
||||
expect(versionCreated.left, greaterThan(latest.right));
|
||||
|
||||
expect(find.text('Refresh'), findsNothing);
|
||||
expect(find.text(scheduleAddLabel), findsNothing);
|
||||
expect(find.byKey(scheduleAddKey), findsOneWidget);
|
||||
expect(find.byType(CupertinoListSection), findsNothing);
|
||||
expect(find.byType(ListTile), findsNothing);
|
||||
final row = tester.widget<AppListRow>(
|
||||
find.byKey(const Key('pipeline-version-3')),
|
||||
);
|
||||
expect(row.selected, isTrue);
|
||||
expect(row.cupertino, cupertino);
|
||||
expect(tester.takeException(), isNull);
|
||||
),
|
||||
'list_schedules' => {'type': 'schedules', 'schedules': <dynamic>[]},
|
||||
_ => errorReply('unexpected $type'),
|
||||
};
|
||||
});
|
||||
}
|
||||
tester.view.physicalSize = const Size(1100, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final screen = PipelinesScreen(gateway: gateway);
|
||||
await tester.pumpWidget(MaterialApp(home: screen));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(pipelineSummaryFactsKey), findsOneWidget);
|
||||
// Short facts share a line instead of one label/value row each.
|
||||
final latest = tester.getRect(
|
||||
find.byKey(const ValueKey('pipeline-summary-latest-version')),
|
||||
);
|
||||
final versionCreated = tester.getRect(
|
||||
find.byKey(const ValueKey('pipeline-summary-version-created')),
|
||||
);
|
||||
expect(versionCreated.top, moreOrLessEquals(latest.top));
|
||||
expect(versionCreated.left, greaterThan(latest.right));
|
||||
|
||||
expect(find.text('Refresh'), findsNothing);
|
||||
expect(find.text(scheduleAddLabel), findsNothing);
|
||||
expect(find.byKey(scheduleAddKey), findsOneWidget);
|
||||
expect(find.byType(ListTile), findsNothing);
|
||||
final row = tester.widget<AppListRow>(
|
||||
find.byKey(const Key('pipeline-version-3')),
|
||||
);
|
||||
expect(row.selected, isTrue);
|
||||
expect(row.cupertino, isFalse);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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/pipelines/widgets/pipeline_tabs.dart';
|
||||
@@ -26,64 +25,52 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final width in [320.0, 390.0, 720.0, 1200.0]) {
|
||||
testWidgets('floating tabs at $width, 2x, Cupertino=$cupertino', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = Size(width, 640);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
PipelineDetailTab? selected;
|
||||
final body = Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: PipelineDetailTabs(
|
||||
selected: PipelineDetailTab.summary,
|
||||
onSelected: (value) => selected = value,
|
||||
),
|
||||
for (final width in [320.0, 390.0, 720.0, 1200.0]) {
|
||||
testWidgets('floating tabs at $width, 2x', (tester) async {
|
||||
tester.view.physicalSize = Size(width, 640);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
PipelineDetailTab? selected;
|
||||
final body = Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: PipelineDetailTabs(
|
||||
selected: PipelineDetailTab.summary,
|
||||
onSelected: (value) => selected = value,
|
||||
),
|
||||
);
|
||||
Widget scaled(BuildContext context, Widget? child) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(2)),
|
||||
child: child!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(builder: scaled, home: Scaffold(body: body)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
// One floating bar of separate round tab buttons.
|
||||
expect(find.byType(FloatingDestinationBar), findsOneWidget);
|
||||
final pill = tester.getRect(find.byKey(FloatingDestinationBar.rowKey));
|
||||
// Sized to its three tabs at the right edge, on a phone as when wide.
|
||||
expect(pill.right, width - 16);
|
||||
expect(
|
||||
pill.width,
|
||||
FloatingDestinationBar.rowWidth(
|
||||
cupertino: false,
|
||||
tabs: PipelineDetailTab.values.length,
|
||||
),
|
||||
);
|
||||
for (final tab in PipelineDetailTab.values) {
|
||||
final rect = tester.getRect(
|
||||
find.byKey(ValueKey('pipeline-detail-tab-${tab.name}')),
|
||||
);
|
||||
Widget scaled(BuildContext context, Widget? child) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(2)),
|
||||
child: child!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
builder: scaled,
|
||||
home: CupertinoPageScaffold(child: body),
|
||||
)
|
||||
: MaterialApp(
|
||||
builder: scaled,
|
||||
home: Scaffold(body: body),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
// One floating bar of separate round tab buttons.
|
||||
expect(find.byType(FloatingDestinationBar), findsOneWidget);
|
||||
final pill = tester.getRect(find.byKey(FloatingDestinationBar.rowKey));
|
||||
// Sized to its three tabs at the right edge, on a phone as when wide.
|
||||
expect(pill.right, width - 16);
|
||||
expect(
|
||||
pill.width,
|
||||
FloatingDestinationBar.rowWidth(
|
||||
cupertino: cupertino,
|
||||
tabs: PipelineDetailTab.values.length,
|
||||
),
|
||||
);
|
||||
for (final tab in PipelineDetailTab.values) {
|
||||
final rect = tester.getRect(
|
||||
find.byKey(ValueKey('pipeline-detail-tab-${tab.name}')),
|
||||
);
|
||||
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
|
||||
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
|
||||
}
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(selected, PipelineDetailTab.source);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
|
||||
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
|
||||
}
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(selected, PipelineDetailTab.source);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import '../../native_back.dart';
|
||||
import 'package:pipelines_app/features/graph/widgets/definition_graph_view.dart';
|
||||
import 'package:pipelines_app/features/pipelines/pipeline_repository.dart';
|
||||
import 'package:pipelines_app/features/pipelines/pipelines_controller.dart';
|
||||
import 'package:pipelines_app/features/pipelines/screen.dart';
|
||||
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_panel.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
|
||||
import 'fixtures.dart';
|
||||
import 'test_helpers.dart';
|
||||
@@ -110,66 +106,6 @@ void main() {
|
||||
expect(find.byKey(const Key('pipeline-detail')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('iOS uses Cupertino scaffolds, list tiles and segmented tabs', (
|
||||
tester,
|
||||
) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
||||
tester.view.physicalSize = const Size(1100, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final fixture = PipelineFixture();
|
||||
try {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(home: PipelinesScreen(gateway: gatewayFor(fixture))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(CupertinoPageScaffold), findsOneWidget);
|
||||
// The shared list row, in its Cupertino form.
|
||||
expect(
|
||||
tester
|
||||
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
|
||||
.cupertino,
|
||||
isTrue,
|
||||
);
|
||||
expect(find.byType(CupertinoActionSheet), findsNothing);
|
||||
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
||||
await tester.pumpAndSettle();
|
||||
// The tabs are the floating glass Cupertino tab bar.
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('pipeline-detail-tabs')),
|
||||
matching: find.byType(FloatingDestinationBar),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
// Versions are the shared row in its Cupertino form, flat on the page.
|
||||
expect(
|
||||
tester
|
||||
.widget<AppListRow>(find.byKey(const Key('pipeline-version-1')))
|
||||
.cupertino,
|
||||
isTrue,
|
||||
);
|
||||
expect(find.byType(CupertinoListSection), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(const Key('pipeline-version-1')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Viewing v1 (latest v2).'), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
|
||||
await tester.pump();
|
||||
expect(
|
||||
selectableText(
|
||||
'name: Alpha review\nstages:\n review:\n type: model\n'
|
||||
'# selected version 1',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
} finally {
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('3x text in a very short panel keeps the tabs reachable', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -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/pipelines/screen.dart';
|
||||
@@ -136,21 +135,15 @@ void main() {
|
||||
expect(find.text('Beta deploy'), findsOneWidget);
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('Schedules opens from the bar (cupertino: $cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
var opened = 0;
|
||||
final screen = PipelinesScreen(
|
||||
gateway: gatewayFor(PipelineFixture()),
|
||||
onOpenSchedules: () => opened++,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino ? CupertinoApp(home: screen) : MaterialApp(home: screen),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('pipelines-open-schedules')));
|
||||
expect(opened, 1);
|
||||
});
|
||||
}
|
||||
testWidgets('Schedules opens from the bar', (tester) async {
|
||||
var opened = 0;
|
||||
final screen = PipelinesScreen(
|
||||
gateway: gatewayFor(PipelineFixture()),
|
||||
onOpenSchedules: () => opened++,
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: screen));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('pipelines-open-schedules')));
|
||||
expect(opened, 1);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -53,17 +52,14 @@ JsonMap noRun() => {'type': 'run', 'run_detail': null};
|
||||
Future<void> pumpScreen(
|
||||
WidgetTester tester,
|
||||
FakeGateway gateway,
|
||||
List<int> navigated, {
|
||||
bool cupertino = false,
|
||||
}) async {
|
||||
List<int> navigated,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(1100, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final screen = PipelinesScreen(gateway: gateway, onRunStarted: navigated.add);
|
||||
await tester.pumpWidget(
|
||||
cupertino ? CupertinoApp(home: screen) : MaterialApp(home: screen),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: screen));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
@@ -582,74 +578,6 @@ void main() {
|
||||
expect(navigated, [86]);
|
||||
});
|
||||
|
||||
testWidgets('the Cupertino host shows the same native prompt and words', (
|
||||
tester,
|
||||
) async {
|
||||
final fixture = PipelineFixture();
|
||||
final navigated = <int>[];
|
||||
final gateway = launchGateway(
|
||||
fixture,
|
||||
onLaunch: (fields) => acceptedRun(84),
|
||||
);
|
||||
await pumpScreen(tester, gateway, navigated, cupertino: true);
|
||||
await openDetail(tester);
|
||||
await tester.tap(find.byKey(runPipelineActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
||||
expect(find.byType(AlertDialog), findsNothing);
|
||||
expect(find.text('Run Alpha review'), findsOneWidget);
|
||||
expect(find.text(runPipelinePromptLabel), findsOneWidget);
|
||||
expect(find.text(runPipelineWorkspaceLabel), findsOneWidget);
|
||||
expect(find.text(runPipelineNotifyLabel), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(CupertinoAlertDialog),
|
||||
matching: find.text(runPipelineConfirmLabel),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text(runPipelineCancelLabel), findsOneWidget);
|
||||
expect(gateway.callsOf('run_pipeline'), isEmpty);
|
||||
|
||||
await tester.tap(find.byKey(runPipelineCancelKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoAlertDialog), findsNothing);
|
||||
expect(gateway.callsOf('run_pipeline'), isEmpty);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino field labels and helper use theme label roles', (
|
||||
tester,
|
||||
) async {
|
||||
final fixture = PipelineFixture();
|
||||
final gateway = launchGateway(
|
||||
fixture,
|
||||
onLaunch: (fields) => acceptedRun(87),
|
||||
);
|
||||
await pumpScreen(tester, gateway, <int>[], cupertino: true);
|
||||
await openDetail(tester);
|
||||
await tester.tap(find.byKey(runPipelineActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final context = tester.element(find.byType(CupertinoAlertDialog));
|
||||
final theme = CupertinoTheme.of(context);
|
||||
final labelStyle = theme.textTheme.textStyle;
|
||||
for (final label in [
|
||||
runPipelinePromptLabel,
|
||||
runPipelineWorkspaceLabel,
|
||||
runPipelineNotifyLabel,
|
||||
]) {
|
||||
final style = tester.widget<Text>(find.text(label)).style;
|
||||
expect(style?.color, labelStyle.color, reason: label);
|
||||
expect(style?.fontSize, labelStyle.fontSize, reason: label);
|
||||
}
|
||||
final helper = tester
|
||||
.widget<Text>(find.text(runPipelineWorkspaceHelper))
|
||||
.style;
|
||||
expect(helper?.color, CupertinoColors.secondaryLabel.resolveFrom(context));
|
||||
expect(helper?.fontSize, theme.textTheme.tabLabelTextStyle.fontSize);
|
||||
});
|
||||
|
||||
testWidgets('Schedule… leaves the run dialog for the schedule editor', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user