Files
pipelines/app/test/features/runs/ui/run_artifacts_action_test.dart
T
alan a6db4ba20e App: run tabs under the header on wide layouts, stable Artifacts tab, spelled-out pipeline status, shared list selection, code block header and edge fades
- Run detail: on a wide window (>= 840, pane >= 600) the tabs are Material
  segments under the run header; phones keep the floating bottom bar.
  Artifacts is always a tab, badged with its count and disabled with 0 (its
  tooltip says why), so Changes never moves.
- Pipelines list: 'Failed · last run 19 Oct' beside the status dot; facts on
  the next line; compact rows keep 'Failed · 19 Oct'.
- Settings: Disconnect is outlined beside a tonal Reconnect.
- Lists: one selection style (tonal fill plus one leading accent bar) for
  runs, pipelines and chats; chat's border, fill and pointer removed.
- Transcript: overflowing blocks fade at the edge with a chevron instead of
  a 'Scroll horizontally' line (semantics hint kept); code blocks get a
  header strip with language and Copy; lighter light-mode code fill.
- Runs list: rows under a day heading show only the time of day.
- Artifact search reveal re-centres once the lazy list's extent settles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 00:55:50 +00:00

171 lines
5.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
import 'package:pipelines_app/ui/adaptive/floating_tab_button.dart';
import '../../artifacts/domain/artifact_fixtures.dart';
class _FakeGateway implements ApiGateway {
_FakeGateway(this.detail);
final JsonMap detail;
@override
Stream<JsonMap> get frames => const Stream<JsonMap>.empty();
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
if (type != 'get_run') throw UnsupportedError(type);
return Future.value({'run_detail': detail});
}
}
JsonMap _run({required List<JsonMap> steps}) => <String, dynamic>{
'id': 21,
'title': 'Artifacts wiring run',
'name': 'gallery',
'status': 'succeeded',
'steps': steps,
};
Future<void> _pumpDetail(
WidgetTester tester,
RunsController controller,
ApiGateway gateway,
) async {
tester.view.physicalSize = const Size(500, 1200);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final view = RunDetailView(
controller: controller,
gateway: gateway,
onBack: () {},
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: view)));
await tester.pumpAndSettle();
}
Future<RunsController> _loaded(ApiGateway gateway) async {
final controller = RunsController(RunsRepository(gateway));
await controller.select(21);
return controller;
}
void main() {
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.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);
});
/// The Artifacts tab keeps its place on a run with none: disabled, badged
/// `0`, and its tooltip (and accessibility hint) says why.
Future<void> expectDisabledArtifacts(WidgetTester tester, String why) async {
final tab = find.byKey(const ValueKey('run-detail-tab-artifacts'));
expect(tab, findsOneWidget);
final button = tester.widget<FloatingTabButton>(tab);
expect(button.enabled, isFalse);
expect(button.tooltip, why);
expect(
find.descendant(
of: tab,
matching: find.byKey(const ValueKey('run-detail-artifacts-count')),
),
findsOneWidget,
);
expect(find.descendant(of: tab, matching: find.text('0')), findsOneWidget);
// A tap does not open an empty gallery: Summary stays.
await tester.tap(tab, warnIfMissed: false);
await tester.pumpAndSettle();
expect(find.text(why), findsNothing);
// Changes, after it, keeps its place.
final order = [
for (final name in ['summary', 'timeline', 'artifacts', 'changes'])
tester.getCenter(find.byKey(ValueKey('run-detail-tab-$name'))).dx,
];
expect(order, orderedEquals([...order]..sort()));
}
testWidgets('a run without steps keeps a disabled Artifacts tab', (
tester,
) async {
final gateway = _FakeGateway(_run(steps: const []));
final controller = await _loaded(gateway);
addTearDown(controller.dispose);
await _pumpDetail(tester, controller, gateway);
await expectDisabledArtifacts(
tester,
'No artifacts recorded for this run.',
);
});
testWidgets('a recorded empty capture keeps its explicit wording', (
tester,
) async {
final gateway = _FakeGateway(
_run(
steps: [step(stage: 'reviewer', visit: 1, artifacts: const [])],
),
);
final controller = await _loaded(gateway);
addTearDown(controller.dispose);
await _pumpDetail(tester, controller, gateway);
await expectDisabledArtifacts(
tester,
'No artifacts recorded for this run.',
);
});
testWidgets('an unavailable capture is never reported as empty', (
tester,
) async {
final gateway = _FakeGateway(
_run(steps: [step(stage: 'reviewer', visit: 1, includeArtifacts: false)]),
);
final controller = await _loaded(gateway);
addTearDown(controller.dispose);
await _pumpDetail(tester, controller, gateway);
await expectDisabledArtifacts(tester, 'Artifacts · capture unavailable');
});
}