feat(app): add debug toggle for turn documents

This commit is contained in:
2026-10-31 15:22:33 +00:00
parent 6962d0bfe0
commit f84948153b
4 changed files with 137 additions and 87 deletions
@@ -80,12 +80,9 @@ Future<void> _pump(
await tester.pumpAndSettle();
}
Future<void> _expandTurnDocuments(WidgetTester tester) async {
final headings = find.textContaining('Turn documents');
for (var index = 0; index < headings.evaluate().length; index += 1) {
await tester.tap(headings.at(index));
await tester.pumpAndSettle();
}
Future<void> _showTurnDocuments(WidgetTester tester) async {
await tester.tap(find.byKey(const Key('artifact-debug-toggle')));
await tester.pumpAndSettle();
}
Finder _dialog(_Platform platform, String text) => find.descendant(
@@ -97,16 +94,14 @@ Finder _dialog(_Platform platform, String text) => find.descendant(
void main() {
for (final platform in _Platform.values) {
testWidgets('${platform.name}: every recorded document is an entry', (
tester,
) async {
testWidgets('${platform.name}: debug hides documents by default and shows '
'each visit when enabled', (tester) async {
await _pump(tester, platform);
expect(find.textContaining('Turn documents'), findsNWidgets(2));
// The generated artifact grid remains primary; debugging evidence is
// deliberately hidden until its own section is opened.
expect(find.text('input.md'), findsNothing);
expect(find.text('For debugging.'), findsNothing);
await _expandTurnDocuments(tester);
expect(find.textContaining('Turn documents'), findsNothing);
expect(find.byTooltip('Show turn documents'), findsOneWidget);
await _showTurnDocuments(tester);
expect(find.byTooltip('Hide turn documents'), findsOneWidget);
expect(find.text('input.md'), findsNWidgets(2));
expect(find.text('output.md'), findsNWidgets(2));
expect(find.text('session.html'), findsNWidgets(2));
@@ -119,7 +114,7 @@ void main() {
tester,
) async {
await _pump(tester, platform);
await _expandTurnDocuments(tester);
await _showTurnDocuments(tester);
expect(find.text('No memory recorded for this visit.'), findsOneWidget);
expect(find.text('No output recorded.'), findsOneWidget);
expect(find.text('This visit has no harness session.'), findsOneWidget);
@@ -130,7 +125,7 @@ void main() {
tester,
) async {
await _pump(tester, platform);
await _expandTurnDocuments(tester);
await _showTurnDocuments(tester);
await tester.tap(find.text('input.md').first);
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsOneWidget);
@@ -145,7 +140,7 @@ void main() {
'${platform.name}: absent rows are informational, not controls',
(tester) async {
await _pump(tester, platform);
await _expandTurnDocuments(tester);
await _showTurnDocuments(tester);
final absence = find.text('No output recorded.');
expect(absence, findsOneWidget);
if (platform == _Platform.material) {
@@ -187,7 +182,7 @@ void main() {
},
fetch: (_) async => throw StateError('x'),
);
await _expandTurnDocuments(tester);
await _showTurnDocuments(tester);
await tester.tap(find.text('session.html').first);
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsNothing);
@@ -226,8 +221,7 @@ void main() {
expect(find.text('Artifact · 1 recorded'), findsOneWidget);
expect(find.text('report.csv'), findsOneWidget);
expect(find.text('input.md'), findsNothing);
await _expandTurnDocuments(tester);
expect(find.text('For debugging.'), findsOneWidget);
await _showTurnDocuments(tester);
await tester.tap(find.text('input.md'));
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsOneWidget);
@@ -252,9 +246,8 @@ void main() {
expect(find.text('No artifacts recorded for this run.'), findsOneWidget);
expect(find.text('input.md'), findsNothing);
await _expandTurnDocuments(tester);
await _showTurnDocuments(tester);
expect(find.text('input.md'), findsOneWidget);
expect(find.text('For debugging.'), findsOneWidget);
});
testWidgets('${platform.name}: focused document-only visits retain turn '
@@ -279,9 +272,8 @@ void main() {
findsOneWidget,
);
expect(find.text('input.md'), findsNothing);
await _expandTurnDocuments(tester);
await _showTurnDocuments(tester);
expect(find.text('input.md'), findsOneWidget);
expect(find.text('For debugging.'), findsOneWidget);
});
testWidgets('${platform.name}: focused visits retain session documents', (
@@ -290,9 +282,8 @@ void main() {
await _pump(tester, platform, focusIndex: 0);
expect(find.text('session.html'), findsNothing);
await _expandTurnDocuments(tester);
await _showTurnDocuments(tester);
expect(find.text('session.html'), findsOneWidget);
expect(find.text('For debugging.'), findsOneWidget);
});
}
}
@@ -12,7 +12,7 @@ import 'package:pipelines_app/ui/layout/sticky_section.dart';
import 'run_detail_graph_support.dart';
import 'run_detail_visit_support.dart';
Future<void> _expandArtifactGroup(WidgetTester tester) async {
Future<void> _expandArtifactGroups(WidgetTester tester) async {
final sections = find.byType(StickySectionTitle);
for (var index = 0; index < sections.evaluate().length; index += 1) {
await tester.tap(sections.at(index));
@@ -20,6 +20,11 @@ Future<void> _expandArtifactGroup(WidgetTester tester) async {
await tester.pumpAndSettle();
}
Future<void> _showTurnDocuments(WidgetTester tester) async {
await tester.tap(find.byKey(const Key('artifact-debug-toggle')));
await tester.pumpAndSettle();
}
void main() {
for (final platform in RunDetailTestPlatform.values) {
testWidgets('${platform.name} stage tabs sit at the bottom with one Back', (
@@ -79,12 +84,15 @@ void main() {
expect(find.text('ok'), findsOneWidget);
await openVisitTab(tester, RunVisitSection.artifacts);
// The focused gallery keeps generated files primary and makes the session
// evidence reachable in its secondary turn-documents section.
await _expandArtifactGroup(tester);
// The focused gallery keeps generated files primary until debugging is
// explicitly enabled.
expect(find.byType(ArtifactGalleryPage), findsOneWidget);
expect(find.text('plan.csv'), findsOneWidget);
expect(find.text('session.html'), findsNothing);
await _showTurnDocuments(tester);
// Embedded visit sections begin collapsed. Debug opens the visit so its
// diagnostic documents do not require a second tap on the heading.
expect(find.text('session.html'), findsOneWidget);
expect(find.text('plan.csv'), findsOneWidget);
await openVisitTab(tester, RunVisitSection.session);
expect(find.text('Session'), findsWidgets);
@@ -196,7 +204,7 @@ void main() {
await openVisit(tester, platform, run: run, sequence: 2);
expectVisitHeading(tester, 'plan', 2);
await openVisitTab(tester, RunVisitSection.artifacts);
await _expandArtifactGroup(tester);
await _expandArtifactGroups(tester);
expect(find.text('plan-2.csv'), findsOneWidget);
expect(find.text('public/shared.csv'), findsNothing);
expect(find.byType(ArtifactGalleryPage), findsOneWidget);