Remove Cupertino branches from artifact features

Keep the Material implementation while preserving public parameters needed by callers. Remove Cupertino-only tests and variants because the app runs exclusively under MaterialApp.
This commit is contained in:
2026-11-11 04:36:57 +00:00
parent d365959bf1
commit f46b82e207
33 changed files with 826 additions and 1530 deletions
@@ -1,6 +1,5 @@
import 'dart:typed_data';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
@@ -59,7 +58,6 @@ Future<ArtifactFetchResult> _fetch(Uri uri) async =>
ArtifactFetchResult(status: 200, bytes: _bytes);
Widget _row({
required bool cupertino,
ArtifactFileBridge? bridge,
ArtifactRecord? artifact,
ArtifactFetch? fetch,
@@ -70,19 +68,11 @@ Widget _row({
fetch: fetch ?? _fetch,
bridge: bridge ?? _bridge(),
);
return cupertino
? CupertinoApp(
home: CupertinoPageScaffold(
child: SafeArea(
child: Padding(padding: const EdgeInsets.all(8), child: actions),
),
),
)
: MaterialApp(
home: Scaffold(
body: Padding(padding: const EdgeInsets.all(8), child: actions),
),
);
return MaterialApp(
home: Scaffold(
body: Padding(padding: const EdgeInsets.all(8), child: actions),
),
);
}
TextButton _materialButton(WidgetTester tester, String label) =>
@@ -92,24 +82,12 @@ TextButton _materialButton(WidgetTester tester, String label) =>
.first,
);
CupertinoButton _cupertinoButton(WidgetTester tester, String label) =>
tester.widget<CupertinoButton>(
find
.ancestor(
of: find.text(label),
matching: find.byType(CupertinoButton),
)
.first,
);
void main() {
testWidgets('Download saves the exact named bytes and reports it', (
tester,
) async {
final saved = <ArtifactFile>[];
await tester.pumpWidget(
_row(cupertino: false, bridge: _bridge(saved: saved)),
);
await tester.pumpWidget(_row(bridge: _bridge(saved: saved)));
await tester.tap(find.text('Download'));
await tester.pumpAndSettle();
@@ -123,9 +101,7 @@ void main() {
testWidgets('Share starts one file transfer, not a link', (tester) async {
final shared = <ArtifactFile>[];
await tester.pumpWidget(
_row(cupertino: false, bridge: _bridge(shared: shared)),
);
await tester.pumpWidget(_row(bridge: _bridge(shared: shared)));
await tester.tap(find.text('Share'));
await tester.pumpAndSettle();
@@ -140,10 +116,7 @@ void main() {
) async {
final saved = <ArtifactFile>[];
await tester.pumpWidget(
_row(
cupertino: false,
bridge: _bridge(saved: saved, shareSupported: false),
),
_row(bridge: _bridge(saved: saved, shareSupported: false)),
);
expect(find.text('No share on this host.'), findsOneWidget);
@@ -160,7 +133,6 @@ void main() {
) async {
await tester.pumpWidget(
_row(
cupertino: false,
bridge: _bridge(),
fetch: (_) => Future<ArtifactFetchResult>.delayed(
const Duration(seconds: 30),
@@ -183,9 +155,7 @@ void main() {
await tester.pump(const Duration(seconds: 31));
});
testWidgets('both hosts keep the file actions whole at 320/2x dark', (
tester,
) async {
testWidgets('the file actions stay whole at 320/2x dark', (tester) async {
tester.view.physicalSize = const Size(640, 1200);
tester.view.devicePixelRatio = 2;
tester.platformDispatcher.textScaleFactorTestValue = 2;
@@ -195,20 +165,12 @@ void main() {
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);
for (final cupertino in <bool>[false, true]) {
await tester.pumpWidget(_row(cupertino: cupertino));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
expect(find.text('Download'), findsOneWidget);
expect(find.text('Share'), findsOneWidget);
if (cupertino) {
expect(_cupertinoButton(tester, 'Download').onPressed, isNotNull);
expect(find.byType(TextButton), findsNothing);
} else {
expect(_materialButton(tester, 'Download').onPressed, isNotNull);
expect(find.byType(CupertinoButton), findsNothing);
}
}
await tester.pumpWidget(_row());
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
expect(find.text('Download'), findsOneWidget);
expect(find.text('Share'), findsOneWidget);
expect(_materialButton(tester, 'Download').onPressed, isNotNull);
});
testWidgets('the gallery selection offers both file actions in its dialog', (
@@ -315,44 +277,27 @@ void main() {
],
),
];
for (final cupertino in <bool>[false, true]) {
await tester.pumpWidget(
cupertino
? CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.dark),
home: ArtifactGalleryPage(
steps: steps,
configuredEndpoint: _endpoint,
fetch: _fetch,
fileBridge: _bridge(),
),
)
: MaterialApp(
theme: ThemeData(brightness: Brightness.dark),
home: ArtifactGalleryPage(
steps: steps,
configuredEndpoint: _endpoint,
fetch: _fetch,
fileBridge: _bridge(),
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.text('report.zip'));
await tester.pumpAndSettle();
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(brightness: Brightness.dark),
home: ArtifactGalleryPage(
steps: steps,
configuredEndpoint: _endpoint,
fetch: _fetch,
fileBridge: _bridge(),
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.text('report.zip'));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
expect(find.text('Download'), findsOneWidget);
expect(find.text('Share'), findsOneWidget);
expect(
cupertino
? find.byType(CupertinoAlertDialog)
: find.byType(AlertDialog),
findsOneWidget,
);
await tester.tap(find.text('Close'));
await tester.pumpAndSettle();
}
expect(tester.takeException(), isNull);
expect(find.text('Download'), findsOneWidget);
expect(find.text('Share'), findsOneWidget);
expect(find.byType(AlertDialog), findsOneWidget);
await tester.tap(find.text('Close'));
await tester.pumpAndSettle();
});
testWidgets(