-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MBL-14971][Parent] Manage remote config flags (#1128)
* [MBL-14971][Parent] Added the Remote config screen refs: MBL-14971 affects: Parent release note: Added the Remote config params screen to modify remote configs. test plan: In debug mode, under settings a new menu is available 'Remote Config Params'. In the new screen you can update the local remote config values.
- Loading branch information
1 parent
1566a76
commit 25a6034
Showing
11 changed files
with
255 additions
and
7 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
apps/flutter_parent/lib/screens/remote_config/remote_config_interactor.dart
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,26 @@ | ||
// Copyright (C) 2020 - present Instructure, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, version 3 of the License. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import 'package:flutter_parent/utils/remote_config_utils.dart'; | ||
|
||
class RemoteConfigInteractor { | ||
|
||
Map<RemoteConfigParams, String> getRemoteConfigParams() { | ||
return Map.fromIterable(RemoteConfigParams.values, key: (rc) => rc, value: (rc) => RemoteConfigUtils.getStringValue(rc)); | ||
} | ||
|
||
void updateRemoteConfig(RemoteConfigParams rcKey, String value) { | ||
RemoteConfigUtils.updateRemoteConfig(rcKey, value); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
apps/flutter_parent/lib/screens/remote_config/remote_config_screen.dart
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,72 @@ | ||
// Copyright (C) 2020 - present Instructure, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, version 3 of the License. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_parent/screens/remote_config/remote_config_interactor.dart'; | ||
import 'package:flutter_parent/utils/remote_config_utils.dart'; | ||
import 'package:flutter_parent/utils/service_locator.dart'; | ||
|
||
class RemoteConfigScreen extends StatefulWidget { | ||
@override | ||
_RemoteConfigScreenState createState() => _RemoteConfigScreenState(); | ||
} | ||
|
||
class _RemoteConfigScreenState extends State<RemoteConfigScreen> { | ||
RemoteConfigInteractor _interactor = locator<RemoteConfigInteractor>(); | ||
|
||
Map<RemoteConfigParams, String> _remoteConfig; | ||
|
||
@override | ||
void initState() { | ||
_remoteConfig = _interactor.getRemoteConfigParams(); | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar(title: Text('Remote Config Params')), | ||
body: Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: ListView( | ||
key: Key('remote_config_params_list'), | ||
children: _createListItems(_remoteConfig), | ||
), | ||
), | ||
); | ||
} | ||
|
||
List<Widget> _createListItems(Map<RemoteConfigParams, String> remoteConfigParams) { | ||
return remoteConfigParams.entries.map((e) => _createListItem(e)).toList(); | ||
} | ||
|
||
Widget _createListItem(MapEntry<RemoteConfigParams, String> entry) { | ||
return Row(children: [ | ||
Align( | ||
child: Text(RemoteConfigUtils.getRemoteConfigName(entry.key)), | ||
alignment: Alignment.centerLeft, | ||
), | ||
Flexible( | ||
child: Padding( | ||
padding: EdgeInsets.only(left: 8.0), | ||
child: TextField( | ||
controller: TextEditingController()..text = entry.value, | ||
onChanged: (value) => { | ||
_interactor.updateRemoteConfig(entry.key, value) | ||
}, | ||
), | ||
)) | ||
]); | ||
} | ||
} |
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
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
31 changes: 31 additions & 0 deletions
31
apps/flutter_parent/test/screens/remote_config_params/remote_config_interactor_test.dart
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,31 @@ | ||
// Copyright (C) 2020 - present Instructure, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, version 3 of the License. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_parent/screens/remote_config/remote_config_interactor.dart'; | ||
import 'package:flutter_parent/utils/remote_config_utils.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mockito/mockito.dart'; | ||
|
||
import '../../utils/platform_config.dart'; | ||
import '../../utils/test_app.dart'; | ||
import '../../utils/test_helpers/mock_helpers.dart'; | ||
|
||
void main() { | ||
test('getRemoteConfigParams returns correct map', () async { | ||
final mockRemoteConfig = setupMockRemoteConfig(valueSettings: {'test_string': 'fetched value', 'mobile_verify_beta_enabled' : 'false'}); | ||
await setupPlatformChannels( | ||
config: PlatformConfig(initRemoteConfig: mockRemoteConfig)); | ||
expect(RemoteConfigInteractor().getRemoteConfigParams(), equals({RemoteConfigParams.TEST_STRING: 'fetched value', RemoteConfigParams.MOBILE_VERIFY_BETA_ENABLED: 'false'})); | ||
}); | ||
} |
50 changes: 50 additions & 0 deletions
50
apps/flutter_parent/test/screens/remote_config_params/remote_config_screen_test.dart
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,50 @@ | ||
// Copyright (C) 2020 - present Instructure, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, version 3 of the License. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_parent/screens/remote_config/remote_config_interactor.dart'; | ||
import 'package:flutter_parent/screens/remote_config/remote_config_screen.dart'; | ||
import 'package:flutter_parent/utils/remote_config_utils.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mockito/mockito.dart'; | ||
|
||
import '../../utils/accessibility_utils.dart'; | ||
import '../../utils/platform_config.dart'; | ||
import '../../utils/test_app.dart'; | ||
import '../../utils/test_helpers/mock_helpers.dart'; | ||
|
||
void main() { | ||
|
||
testWidgetsWithAccessibilityChecks('Shows the correct list', (tester) async { | ||
var interactor = _MockInteractor(); | ||
setupTestLocator((locator) => locator.registerFactory<RemoteConfigInteractor>(() => interactor)); | ||
|
||
Map<RemoteConfigParams, String> remoteConfigs = { | ||
RemoteConfigParams.MOBILE_VERIFY_BETA_ENABLED: 'false', | ||
RemoteConfigParams.TEST_STRING: 'fetched value' | ||
}; | ||
|
||
when(interactor.getRemoteConfigParams()).thenReturn(remoteConfigs); | ||
|
||
await tester.pumpWidget(TestApp(RemoteConfigScreen())); | ||
await tester.pumpAndSettle(); | ||
|
||
expect(find.text(RemoteConfigUtils.getRemoteConfigName(RemoteConfigParams.MOBILE_VERIFY_BETA_ENABLED)), findsOneWidget); | ||
expect(find.text('false'), findsOneWidget); | ||
expect(find.text(RemoteConfigUtils.getRemoteConfigName(RemoteConfigParams.TEST_STRING)), findsOneWidget); | ||
expect(find.text('fetched value'), findsOneWidget); | ||
}); | ||
} | ||
|
||
class _MockInteractor extends Mock implements RemoteConfigInteractor {} |
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