Skip to content

Commit 86edc84

Browse files
committed
[red] cover multi-delete shell and disposal gates
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent c5d6607 commit 86edc84

3 files changed

Lines changed: 286 additions & 0 deletions

File tree

‎app/test/unit/file_explorer_controller_test.dart‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,34 @@ void main() {
651651
},
652652
);
653653

654+
test(
655+
'surfaces reconciliation failure separately after every delete succeeds',
656+
() async {
657+
final h = await batchReady(files: <String>['alpha.py', 'beta.py']);
658+
h.connection.nextListFailure = const EIo(
659+
'scripted post-success reconciliation failure',
660+
);
661+
662+
final FileDeleteBatchResult result = await ctrl(
663+
h.container,
664+
).deleteMany(<String>['beta.py', 'alpha.py']);
665+
666+
expect(result.outcome, FileDeleteBatchOutcome.complete);
667+
expect(result.succeededPaths, <String>['/alpha.py', '/beta.py']);
668+
expect(result.failedPath, isNull);
669+
expect(result.unattemptedPaths, isEmpty);
670+
expect(result.failure, isNull);
671+
expect(h.connection.batchLog, <String>[
672+
'delete:/alpha.py',
673+
'delete:/beta.py',
674+
'list:/',
675+
]);
676+
expect(h.connection.listedPaths, <String>['/']);
677+
expect(state(h.container).error, FileErrorKind.io);
678+
expect(state(h.container).errorPath, '/');
679+
},
680+
);
681+
654682
test(
655683
'session replacement starts no later delete and never lists the successor',
656684
() async {

‎app/test/widget/app_shell_test.dart‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
// toolbar action slots) without weakening any of it.
2222
// HAND-OFF provenance: lib/app → app-architect; lib/pble → app-protocol-engineer.
2323

24+
import 'dart:typed_data';
25+
2426
import 'package:flutter/material.dart';
2527
import 'package:flutter/rendering.dart';
2628
import 'package:flutter_test/flutter_test.dart';
@@ -459,6 +461,64 @@ void main() {
459461
});
460462
});
461463

464+
group('A-30 Files selection shell lifecycle (ADR-0043)', () {
465+
testWidgets('stacked navigation away clears temporary file selection', (
466+
WidgetTester tester,
467+
) async {
468+
final FakeConnection connection = fakeConnection(
469+
initial: ConnState.ready,
470+
);
471+
await connection.putFile('/alpha.py', Uint8List.fromList(<int>[97, 10]));
472+
await pumpShell(tester, connection: connection, surface: ipadPortrait);
473+
474+
Finder destination(String label) => find.descendant(
475+
of: find.byType(NavigationBar),
476+
matching: find.text(label),
477+
);
478+
479+
await tester.tap(destination('Files'));
480+
await tester.pumpAndSettle();
481+
await tester.tap(find.byKey(kFilesSelectActionKey));
482+
await tester.pumpAndSettle();
483+
expect(find.byKey(kFilesSelectionBarKey), findsOneWidget);
484+
485+
await tester.tap(destination('Editor'));
486+
await tester.pumpAndSettle();
487+
await tester.tap(destination('Files'));
488+
await tester.pumpAndSettle();
489+
490+
expect(find.byKey(kFilesSelectionBarKey), findsNothing);
491+
expect(find.byKey(kFilesSelectActionKey), findsOneWidget);
492+
});
493+
494+
testWidgets(
495+
'landscape Editor to Console focus keeps the visible Files selection',
496+
(WidgetTester tester) async {
497+
final FakeConnection connection = fakeConnection(
498+
initial: ConnState.ready,
499+
);
500+
await connection.putFile(
501+
'/alpha.py',
502+
Uint8List.fromList(<int>[97, 10]),
503+
);
504+
await pumpShell(tester, connection: connection, surface: ipadLandscape);
505+
506+
await tester.tap(find.byKey(kFilesSelectActionKey));
507+
await tester.pumpAndSettle();
508+
expect(find.byKey(kFilesSelectionBarKey), findsOneWidget);
509+
510+
final Finder console = find.descendant(
511+
of: find.byType(NavigationRail),
512+
matching: find.text('Console'),
513+
);
514+
await tester.tap(console);
515+
await tester.pumpAndSettle();
516+
517+
expect(find.byKey(kFilesSelectionBarKey), findsOneWidget);
518+
},
519+
);
520+
});
521+
462522
group('A-31 responsive Blocks reachability', () {
463523
testWidgets(
464524
'landscape NavigationRail opens a dedicated focused Blocks workspace',

‎app/test/widget/files_view_test.dart‎

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,31 @@ class _DisappearingDeleteConnection extends RecordingConnection {
8383
}
8484
}
8585

86+
/// Holds exactly one requested listing while leaving the previous rows visible.
87+
class _HeldListConnection extends RecordingConnection {
88+
_HeldListConnection() : super(initial: ConnState.ready);
89+
90+
Completer<void> listStarted = Completer<void>();
91+
Completer<void> releaseList = Completer<void>();
92+
bool _holdNext = false;
93+
94+
void holdNextList() {
95+
listStarted = Completer<void>();
96+
releaseList = Completer<void>();
97+
_holdNext = true;
98+
}
99+
100+
@override
101+
Future<List<RemoteEntry>> listDir(String path) async {
102+
if (_holdNext) {
103+
_holdNext = false;
104+
listStarted.complete();
105+
await releaseList.future;
106+
}
107+
return super.listDir(path);
108+
}
109+
}
110+
86111
void main() {
87112
Uint8List b(String s) => Uint8List.fromList(utf8.encode(s));
88113
Key entryKey(String n) => ValueKey<String>('fileEntry_$n');
@@ -493,6 +518,73 @@ void main() {
493518
expect(rec.getFileCalls, isEmpty);
494519
});
495520

521+
testWidgets('Space toggles the keyboard-focused file checkbox', (
522+
WidgetTester tester,
523+
) async {
524+
final RecordingConnection rec = RecordingConnection(
525+
initial: ConnState.ready,
526+
);
527+
addTearDown(rec.dispose);
528+
await rec.putFile('/alpha.py', b('print("alpha")\n'));
529+
await pumpSurface(tester, const FilesView(), connection: rec);
530+
await tester.pumpAndSettle();
531+
532+
await enterSelection(tester);
533+
final Finder checkbox = find.byKey(selectKey('alpha.py'));
534+
for (
535+
int step = 0;
536+
step < 8 && !primaryFocusIsWithin(tester, checkbox);
537+
step += 1
538+
) {
539+
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
540+
await tester.pump();
541+
}
542+
expect(
543+
primaryFocusIsWithin(tester, checkbox),
544+
isTrue,
545+
reason: 'the selected-file checkbox participates in focus traversal',
546+
);
547+
548+
await tester.sendKeyEvent(LogicalKeyboardKey.space);
549+
await tester.pump();
550+
551+
expect(tester.widget<Checkbox>(checkbox).value, isTrue);
552+
expect(rec.getFileCalls, isEmpty);
553+
});
554+
555+
testWidgets(
556+
'long press cannot enter selection while refresh is in flight',
557+
(WidgetTester tester) async {
558+
final _HeldListConnection rec = _HeldListConnection();
559+
addTearDown(() {
560+
if (!rec.releaseList.isCompleted) rec.releaseList.complete();
561+
rec.dispose();
562+
});
563+
await rec.putFile('/alpha.py', b('alpha\n'));
564+
await pumpSurface(tester, const FilesView(), connection: rec);
565+
await tester.pumpAndSettle();
566+
567+
rec.holdNextList();
568+
final Future<void> pending = containerOf(
569+
tester,
570+
).read(fileExplorerProvider.notifier).refresh();
571+
await rec.listStarted.future;
572+
await tester.pump();
573+
574+
final TextButton selectAction = tester.widget<TextButton>(
575+
find.byKey(kFilesSelectActionKey),
576+
);
577+
expect(selectAction.onPressed, isNull);
578+
await tester.longPress(find.byKey(entryKey('alpha.py')));
579+
await tester.pump();
580+
expect(find.byKey(kFilesSelectionBarKey), findsNothing);
581+
582+
rec.releaseList.complete();
583+
await pending;
584+
await tester.pumpAndSettle();
585+
},
586+
);
587+
496588
testWidgets(
497589
'folders and protected root or scratch entries stay locked and excluded',
498590
(WidgetTester tester) async {
@@ -1041,6 +1133,112 @@ void main() {
10411133
},
10421134
);
10431135

1136+
testWidgets('a running delete locks progress, selection, and mutations', (
1137+
WidgetTester tester,
1138+
) async {
1139+
final _HeldDeleteConnection rec = _HeldDeleteConnection();
1140+
addTearDown(() {
1141+
if (!rec.release.isCompleted) rec.release.complete();
1142+
rec.dispose();
1143+
});
1144+
await rec.putFile('/alpha.py', b('alpha\n'));
1145+
await rec.putFile('/beta.py', b('beta\n'));
1146+
await pumpSurface(tester, const FilesView(), connection: rec);
1147+
await tester.pumpAndSettle();
1148+
final AppLocalizations l10n = l10nOf(tester);
1149+
1150+
await enterSelection(tester);
1151+
await selectAllShown(tester);
1152+
await tester.tap(find.byKey(kFilesBulkDeleteActionKey));
1153+
await tester.pumpAndSettle();
1154+
await tester.tap(
1155+
find.descendant(
1156+
of: find.byType(AlertDialog),
1157+
matching: find.widgetWithText(FilledButton, l10n.commonDelete),
1158+
),
1159+
);
1160+
await tester.pump();
1161+
expect(rec.started.isCompleted, isTrue);
1162+
1163+
final String progress = l10n.filesDeleteSelectedProgress(
1164+
'alpha.py',
1165+
0,
1166+
2,
1167+
);
1168+
final Finder progressText = find.text(progress);
1169+
expect(progressText, findsOneWidget);
1170+
final Finder liveProgress = find.ancestor(
1171+
of: progressText,
1172+
matching: find.byWidgetPredicate(
1173+
(Widget widget) =>
1174+
widget is Semantics && widget.properties.liveRegion == true,
1175+
),
1176+
);
1177+
expect(liveProgress, findsOneWidget);
1178+
expect(tester.widget<Semantics>(liveProgress).properties.label, progress);
1179+
1180+
final Finder cancel = find.ancestor(
1181+
of: find.byTooltip(l10n.filesSelectionCancel),
1182+
matching: find.byType(IconButton),
1183+
);
1184+
expect(tester.widget<IconButton>(cancel).onPressed, isNull);
1185+
expect(
1186+
tester
1187+
.widget<IconButton>(find.byKey(kFilesSelectAllShownKey))
1188+
.onPressed,
1189+
isNull,
1190+
);
1191+
expect(
1192+
tester
1193+
.widget<IconButton>(find.byKey(kFilesBulkDeleteActionKey))
1194+
.onPressed,
1195+
isNull,
1196+
);
1197+
for (final String name in <String>['alpha.py', 'beta.py']) {
1198+
expect(
1199+
tester.widget<Checkbox>(find.byKey(selectKey(name))).onChanged,
1200+
isNull,
1201+
);
1202+
expect(
1203+
tester.widget<ListTile>(find.byKey(entryKey(name))).onTap,
1204+
isNull,
1205+
);
1206+
}
1207+
expect(find.byType(RefreshIndicator), findsNothing);
1208+
expect(find.text(l10n.filesSelectionSelectedCount(2)), findsOneWidget);
1209+
1210+
rec.release.complete();
1211+
await tester.pumpAndSettle();
1212+
});
1213+
1214+
testWidgets(
1215+
'disconnect dismisses an open exact confirmation with zero I/O',
1216+
(WidgetTester tester) async {
1217+
final RecordingConnection rec = RecordingConnection(
1218+
initial: ConnState.ready,
1219+
);
1220+
addTearDown(rec.dispose);
1221+
await rec.putFile('/alpha.py', b('alpha\n'));
1222+
await pumpSurface(tester, const FilesView(), connection: rec);
1223+
await tester.pumpAndSettle();
1224+
final AppLocalizations l10n = l10nOf(tester);
1225+
1226+
await enterSelection(tester);
1227+
await tester.tap(find.byKey(entryKey('alpha.py')));
1228+
await tester.pump();
1229+
await tester.tap(find.byKey(kFilesBulkDeleteActionKey));
1230+
await tester.pumpAndSettle();
1231+
expect(find.byType(AlertDialog), findsOneWidget);
1232+
1233+
rec.emit(ConnState.disconnected);
1234+
await tester.pumpAndSettle();
1235+
1236+
expect(find.byType(AlertDialog), findsNothing);
1237+
expect(find.text(l10n.filesDisconnectedTitle), findsOneWidget);
1238+
expect(rec.deleteCalls, isEmpty);
1239+
},
1240+
);
1241+
10441242
testWidgets('a replaced listing dismisses a stale confirmation safely', (
10451243
WidgetTester tester,
10461244
) async {

0 commit comments

Comments
 (0)