-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
122 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import 'package:acter/common/providers/room_providers.dart'; | ||
import 'package:acter/common/providers/space_providers.dart'; | ||
import 'package:acter/common/widgets/acter_search_widget.dart'; | ||
import 'package:acter/features/events/pages/event_list_page.dart'; | ||
import 'package:acter/features/events/providers/event_providers.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import '../../helpers/error_helpers.dart'; | ||
import '../../helpers/test_util.dart'; | ||
|
||
void main() { | ||
group('Event List Error Pages', () { | ||
testWidgets('full list', (tester) async { | ||
bool shouldFail = true; | ||
await tester.pumpProviderWidget( | ||
overrides: [ | ||
eventListSearchFilterProvider.overrideWith((a, b) { | ||
if (shouldFail) { | ||
// toggle failure so the retry works | ||
shouldFail = !shouldFail; | ||
throw 'Expected fail: Space not loaded'; | ||
} | ||
return []; | ||
}), | ||
hasSpaceWithPermissionProvider.overrideWith((_, ref) => false), | ||
], | ||
child: const EventListPage(), | ||
); | ||
await tester.ensureErrorPageWithRetryWorks(); | ||
}); | ||
testWidgets('full list with search', (tester) async { | ||
bool shouldFail = true; | ||
|
||
await tester.pumpProviderWidget( | ||
overrides: [ | ||
searchValueProvider | ||
.overrideWith((_) => 'some string'), // set a search string | ||
|
||
eventListSearchFilterProvider.overrideWith((a, b) { | ||
if (shouldFail) { | ||
// toggle failure so the retry works | ||
shouldFail = !shouldFail; | ||
throw 'Expected fail: Space not loaded'; | ||
} | ||
return []; | ||
}), | ||
hasSpaceWithPermissionProvider.overrideWith((_, ref) => false), | ||
], | ||
child: const EventListPage(), | ||
); | ||
await tester.ensureErrorPageWithRetryWorks(); | ||
}); | ||
|
||
testWidgets('space list', (tester) async { | ||
bool shouldFail = true; | ||
await tester.pumpProviderWidget( | ||
overrides: [ | ||
roomDisplayNameProvider.overrideWith((a, b) => 'test'), | ||
eventListSearchFilterProvider.overrideWith((a, b) { | ||
if (shouldFail) { | ||
// toggle failure so the retry works | ||
shouldFail = !shouldFail; | ||
throw 'Expected fail: Space not loaded'; | ||
} | ||
return []; | ||
}), | ||
hasSpaceWithPermissionProvider.overrideWith((_, ref) => false), | ||
], | ||
child: const EventListPage( | ||
spaceId: '!test', | ||
), | ||
); | ||
await tester.ensureErrorPageWithRetryWorks(); | ||
}); | ||
|
||
testWidgets('space list with search', (tester) async { | ||
bool shouldFail = true; | ||
await tester.pumpProviderWidget( | ||
overrides: [ | ||
roomDisplayNameProvider.overrideWith((a, b) => 'test'), | ||
searchValueProvider | ||
.overrideWith((_) => 'some search'), // set a search string | ||
eventListSearchFilterProvider.overrideWith((a, b) { | ||
if (shouldFail) { | ||
// toggle failure so the retry works | ||
shouldFail = !shouldFail; | ||
throw 'Expected fail: Space not loaded'; | ||
} | ||
return []; | ||
}), | ||
hasSpaceWithPermissionProvider.overrideWith((_, ref) => false), | ||
], | ||
child: const EventListPage( | ||
spaceId: '!test', | ||
), | ||
); | ||
await tester.ensureErrorPageWithRetryWorks(); | ||
}); | ||
}); | ||
} |