This file contains hidden or 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
| export async function teardown() { | |
| useRealProjectId = false; | |
| const appsToClean = [...apps(), ...adminApps]; | |
| return Promise.all(appsToClean.map((app) => app?.delete())); | |
| } |
This file contains hidden or 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
| type User { | |
| name: String | |
| email: String! | |
| organizations: [Organization!] @relation | |
| } | |
| type Organization { | |
| name: String! | |
| description: String |
This file contains hidden or 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
| type User { | |
| name: String | |
| email: String! | |
| organizations: [OrganizationMember!] @relation | |
| } | |
| enum OrganizationMemberRole { | |
| OWNER | |
| MEMBER |
This file contains hidden or 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
| return items.where((item) => activeConditions.any((conditionKey) { | |
| final parsedConditionKey = splitConditionKey(conditionKey); | |
| final property = parsedConditionKey[0]; | |
| final itemValue = item[property]; | |
| final targetValue = parsedConditionKey[1]; | |
| if (itemValue is bool) { | |
| return itemValue.toString() == targetValue.toLowerCase(); | |
| } |
This file contains hidden or 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
| blocTest( | |
| 'returns source items matching a single active boolean condition key', | |
| build: () async { | |
| whenListen( | |
| _filterConditionsBloc, | |
| Stream.value( | |
| ConditionsInitialized( | |
| activeConditions: <String>{ | |
| generateConditionKey('conditional', 'True'), | |
| }, |
This file contains hidden or 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
| if (value is bool) { | |
| availableConditions[property].add('True'); | |
| availableConditions[property].add('False'); | |
| availableConditionKeys.add(generateConditionKey(property, 'True')); | |
| availableConditionKeys.add(generateConditionKey(property, 'False')); | |
| } |
This file contains hidden or 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
| blocTest( | |
| 'filtering one item on a boolean property should still add both items', | |
| build: () async { | |
| whenListen( | |
| _sourceBloc, | |
| Stream.value(MockSourceBlocClassItems([_mockItem1])), | |
| ); | |
| return FilterConditionsBloc<MockSourceBlocClassItems>( | |
| sourceBloc: _sourceBloc, |
This file contains hidden or 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
| blocTest( | |
| 'formats boolean property values for display without repeating', | |
| build: () async { | |
| whenListen( | |
| _sourceBloc, | |
| Stream.value( | |
| MockSourceBlocClassItems([_mockItem1, _mockItem2, _mockItem3])), | |
| ); | |
| return FilterConditionsBloc<MockSourceBlocClassItems>( |
This file contains hidden or 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
| Iterable<I> _searchSource(String searchQuery, Iterable<I> items) { | |
| if (searchQuery.isEmpty) { | |
| return items; | |
| } | |
| // Search queries are stored lowercase, so we want to match | |
| // against a lowercase value as well. | |
| return items.where((item) => _searchProperties.any((property) { | |
| final value = item[property]; | |
| return value is String |
This file contains hidden or 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
| Iterable<I> _filterSource(List<I> items) { | |
| final activeConditions = | |
| (_filterConditionsBloc.state as ConditionsInitialized).activeConditions; | |
| if (activeConditions.isEmpty) { | |
| return items; | |
| } | |
| // If any active condition matches we can immediately return that item. | |
| return items.where((item) => activeConditions.any((conditionKey) { |