Skip to content

Commit 1513cfe

Browse files
committed
Add test case for when selectedIdEditStateProvider is reset
1 parent f1ec852 commit 1513cfe

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/providers/ui_providers_test.dart

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,5 +260,44 @@ void main() {
260260
expect(container.read(selectedIdEditStateProvider), isNotNull);
261261
expect((container.read(selectedIdEditStateProvider)).runtimeType, String);
262262
});
263+
264+
testWidgets(
265+
'It should be set back to null when user taps outside name editor',
266+
(tester) async {
267+
await tester.pumpWidget(
268+
const ProviderScope(
269+
child: MaterialApp(
270+
home: CollectionPane(),
271+
),
272+
),
273+
);
274+
275+
// Grab the CollectionPane widget and its ProviderContainer
276+
final collectionPane = tester.element(find.byType(CollectionPane));
277+
final container = ProviderScope.containerOf(collectionPane);
278+
279+
// Tap on the three dots to open the request card menu
280+
await tester.tap(find.byType(RequestList));
281+
await tester.pump();
282+
await tester.tap(find.byType(RequestItem));
283+
await tester.pump();
284+
await tester.tap(find.byIcon(Icons.more_vert).first);
285+
await tester.pumpAndSettle();
286+
287+
// Tap on the "Rename" option in the menu
288+
await tester.tap(find.text('Rename'));
289+
await tester.pumpAndSettle();
290+
291+
// Verify that the selectedIdEditStateProvider is not null
292+
expect(container.read(selectedIdEditStateProvider), isNotNull);
293+
expect((container.read(selectedIdEditStateProvider)).runtimeType, String);
294+
295+
// Tap on the screen to simulate tapping outside the name editor
296+
await tester.tap(find.byType(CollectionPane));
297+
await tester.pumpAndSettle();
298+
299+
// Verify that the selectedIdEditStateProvider is null
300+
expect(container.read(selectedIdEditStateProvider), null);
301+
});
263302
});
264303
}

0 commit comments

Comments
 (0)