127 lines
4.2 KiB
Dart
127 lines
4.2 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 RunDetailTestPlatform.values) {
|
|
testWidgets('${platform.name} visit shows only its recorded facts', (
|
|
tester,
|
|
) async {
|
|
await openVisit(tester, platform);
|
|
|
|
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
|
expect(find.text('plan · visit 1'), findsOneWidget);
|
|
// 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 and its facts share one leading edge.
|
|
final title = tester.getTopLeft(find.text('plan · visit 1')).dx;
|
|
expect(
|
|
tester.getTopLeft(find.byKey(const Key('run-visit-facts-grid'))).dx,
|
|
title,
|
|
);
|
|
// 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('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);
|
|
});
|
|
}
|