Skip to content

Commit

Permalink
fix: test scroll issue in settings_page_test
Browse files Browse the repository at this point in the history
  • Loading branch information
murtazahussain108 committed Jan 22, 2024
1 parent efb24af commit 7716aa2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
24 changes: 12 additions & 12 deletions lib/src/view/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,6 @@ class _SettingsPageState extends State<SettingsPage> {
),
_heading(Localization.strings['apiListingScreen']!),
const SizedBox(height: 16),
_settingRow(
title: Localization.strings['showRequestStats']!,
description: Localization.strings['showRequestStatsDesc']!,
child: Switch.adaptive(
activeColor: primaryColor,
value: _settings.showRequestsStats,
onChanged: (value) {
_saveSettings(showRequestsStats: value);
},
),
),
const SizedBox(height: 16),
_settingRow(
title: Localization.strings['selectedMethod']!,
description: Localization.strings['selectedMethodDesc']!,
Expand All @@ -111,6 +99,18 @@ class _SettingsPageState extends State<SettingsPage> {
),
padding: 16,
),
const SizedBox(height: 16),
_settingRow(
title: Localization.strings['showRequestStats']!,
description: Localization.strings['showRequestStatsDesc']!,
child: Switch.adaptive(
activeColor: primaryColor,
value: _settings.showRequestsStats,
onChanged: (value) {
_saveSettings(showRequestsStats: value);
},
),
),
const Padding(
padding: EdgeInsets.symmetric(vertical: 16),
child: Divider(),
Expand Down
10 changes: 9 additions & 1 deletion test/src/view/settings_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ void main() {
await tester.pumpWidget(const MaterialApp(home: SettingsPage()));

final switches = find.byType(Switch).evaluate();
final finderShowRequestSwitch =
find.byWidget(switches.elementAt(1).widget);

await tester.dragUntilVisible(
finderShowRequestSwitch,
find.byType(ListView),
const Offset(0, 500),
);

await tester.tap(find.byWidget(switches.elementAt(1).widget));
await tester.pumpAndSettle();
Expand All @@ -60,7 +68,7 @@ void main() {
);

testWidgets(
'Delete confir dialog on/off settings should be saved in shared preferences',
'Delete confirmation dialog on/off settings should be saved in shared preferences',
(WidgetTester tester) async {
SharedPreferences.setMockInitialValues({});

Expand Down

0 comments on commit 7716aa2

Please sign in to comment.