Files
pipelines/app/test/features/runs/ui/run_detail_visit_test.dart
T
alan bc4e638475 Keep artifact tests on Material platform
Remove the unused Cupertino test variants so the reviewed artifact changes match the app's Material-only execution path.
2026-11-11 04:50:14 +00:00

170 lines
5.6 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/ui/run_detail_timeline.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_session.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_session_state.dart';
import 'run_detail_graph_support.dart';
import 'run_detail_visit_support.dart';
void main() {
for (final platform in const [RunDetailTestPlatform.material]) {
testWidgets('${platform.name} visit shows only its recorded facts', (
tester,
) async {
await openVisit(tester, platform);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
// The page bar names the stage over its visit and run; the body does
// not repeat them.
final heading = find.byKey(const Key('run-visit-title'));
expect(
find.descendant(of: heading, matching: find.text('plan')),
findsOneWidget,
);
expect(
find.descendant(
of: heading,
matching: find.text('Visit 1 · Run 77 · Visit run'),
),
findsOneWidget,
);
expect(find.text('plan'), findsOneWidget);
expect(find.text('Visit 1'), findsNothing);
// Each fact as its label over its value; several share a line.
for (final (label, value) in [
('Status', 'completed'),
('Outcome', 'success'),
('Duration', '2m 5s'),
('Provider/model', 'anthropic / claude-x'),
('Target', 'build'),
]) {
expect(find.text(label), findsWidgets, reason: label);
expect(find.text(value), findsWidgets, reason: value);
}
for (final value in ['approve', 'Looks good.', 'Plan checked.']) {
expect(find.text(value), findsOneWidget, reason: value);
}
expect(find.text('Verdict'), findsOneWidget);
expect(find.text('Diagnostic'), findsOneWidget);
// The title is the bar's header; the facts lead the scrolled Summary
// below the bar at rest.
expect(
tester.getSemantics(find.text('plan')),
matchesSemantics(isHeader: true, label: 'plan'),
);
final facts = tester.getRect(
find.byKey(const Key('run-visit-facts-grid')),
);
expect(facts.top, greaterThanOrEqualTo(tester.getRect(heading).bottom));
// Status and duration share a line.
expect(
tester.getTopLeft(find.text('completed')).dy,
moreOrLessEquals(tester.getTopLeft(find.text('2m 5s')).dy, epsilon: 4),
);
});
testWidgets('${platform.name} duration hides without both timestamps', (
tester,
) async {
await openVisit(
tester,
platform,
run: visitRunFixture(bothTimestamps: false),
);
expect(find.textContaining('Duration'), findsNothing);
expect(find.textContaining('0s'), findsNothing);
expect(find.text('completed'), findsOneWidget);
});
testWidgets('${platform.name} absent provider/model is not invented', (
tester,
) async {
await openVisit(
tester,
platform,
run: visitRunFixture(providerModel: false),
);
expect(find.textContaining('Provider/model'), findsNothing);
expect(find.textContaining('anthropic / claude-x'), findsNothing);
});
testWidgets('${platform.name} Back closes the visit pane', (tester) async {
await openVisit(tester, platform);
await tester.tap(find.byKey(const Key('run-visit-back')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-pane')), findsNothing);
expect(find.byType(RunTimelineList), findsOneWidget);
expect(find.text('plan · Visit 1'), findsOneWidget);
});
testWidgets('${platform.name} visit pane at 320 with 2x dark text', (
tester,
) async {
await openVisit(
tester,
platform,
size: const Size(320, 568),
scale: 2,
brightness: Brightness.dark,
);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(tester.takeException(), isNull);
});
testWidgets('${platform.name} long stage identity fits the bar at 2x', (
tester,
) async {
final run = visitRunFixture();
firstVisitStep(run)['stage'] =
'review-generated-release-artifacts-and-verify-evidence';
await openVisit(
tester,
platform,
run: run,
size: const Size(320, 568),
scale: 2,
);
// The bar's one-line title ellipsises a long stage instead of
// overflowing.
expect(
find.text('review-generated-release-artifacts-and-verify-evidence'),
findsOneWidget,
);
expect(find.text('Visit 1 · Run 77 · Visit run'), findsOneWidget);
expect(tester.takeException(), isNull);
});
}
testWidgets('session export with no configured endpoint states the hint', (
tester,
) async {
final step = (visitRunFixture()['steps'] as List).first as JsonMap;
final artifacts = step['artifacts'] as List;
(artifacts[1] as JsonMap)['url'] = '/artifacts/session.html';
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: RunVisitSession(
run: visitRunFor(step),
step: step,
gateway: RunDetailFakeGateway(visitRunFor(step)),
onRunChanged: (_) {},
configuredEndpoint: '',
),
),
),
);
expect(find.text('Open session.html'), findsNothing);
expect(find.text(visitSessionEndpointMissing), findsOneWidget);
});
}