Files
pipelines/app/test/features/runs/ui/run_detail_visit_test.dart
T

124 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);
for (final value in [
'Status: completed',
'Outcome: success',
'Duration: 2m 5s',
'Provider/model: anthropic / claude-x',
'Target: build',
]) {
expect(find.textContaining(value), findsOneWidget, 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, its facts and the section tabs share one leading edge; the
// Cupertino control's own default inset used to push the tabs 16 in.
final title = tester.getTopLeft(find.text('plan · visit 1')).dx;
expect(
tester.getTopLeft(find.textContaining('Status: completed')).dx,
title,
);
// A centred segment label sits ~49 in from a 16 inset control (65), but
// 81 behind the control's default 16 inset.
expect(tester.getTopLeft(find.text('Input')).dx, lessThan(title + 56));
});
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.textContaining('Status: 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);
});
}