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);
});
}
}