Skip to content

Commit

Permalink
fix: Goldens update darkmode status (#3016)
Browse files Browse the repository at this point in the history
* fix: Goldens update darkmode status

* Update user_preferences_page_test.dart

* fix

* Update user_preferences_page_test.dart
  • Loading branch information
M123-dev authored Sep 15, 2022
1 parent 6a11349 commit 1d5abac
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
10 changes: 5 additions & 5 deletions packages/smooth_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ packages:
name: build
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
version: "2.3.1"
built_collection:
dependency: transitive
description:
Expand Down Expand Up @@ -209,7 +209,7 @@ packages:
name: code_builder
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.0"
version: "4.3.0"
collection:
dependency: "direct main"
description:
Expand All @@ -223,7 +223,7 @@ packages:
name: connectivity_plus
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.6+1"
version: "2.3.7"
connectivity_plus_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -272,7 +272,7 @@ packages:
name: cross_file
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.3+1"
version: "0.3.3+2"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -1231,7 +1231,7 @@ packages:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.2"
version: "1.2.3"
source_span:
dependency: transitive
description:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 19 additions & 13 deletions packages/smooth_app/test/pages/user_preferences_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import '../tests_utils/mocks.dart';
void main() {
group('UserPreferencesPage looks as expected', () {
for (final bool themeDark in <bool>[true, false]) {
final String theme = themeDark ? 'dark' : 'light';
final String theme = themeDark ? 'Dark' : 'Light';

testWidgets(theme, (WidgetTester tester) async {
// Override & mock out HTTP Requests
Expand All @@ -28,12 +28,12 @@ void main() {
late ThemeProvider themeProvider;

SharedPreferences.setMockInitialValues(
mockSharedPreferences(
themeDark: themeDark,
),
mockSharedPreferences(),
);

userPreferences = await UserPreferences.getUserPreferences();
userPreferences.setTheme(theme);

productPreferences = ProductPreferences(ProductPreferencesSelection(
setImportance: userPreferences.setImportance,
getImportance: userPreferences.getImportance,
Expand All @@ -43,17 +43,23 @@ void main() {
await userPreferences.init(productPreferences);
themeProvider = ThemeProvider(userPreferences);

await tester.pumpWidget(MockSmoothApp(
userPreferences,
UserManagementProvider(),
productPreferences,
themeProvider,
const UserPreferencesPage(),
));
await tester.pumpWidget(
MockSmoothApp(
userPreferences,
UserManagementProvider(),
productPreferences,
themeProvider,
const UserPreferencesPage(),
),
);
await tester.pump();

await expectGoldenMatches(find.byType(UserPreferencesPage),
'user_preferences_page-$theme.png');
// We need to lowercase the theme, as on some platforms
// the name is always lowercase
await expectGoldenMatches(
find.byType(UserPreferencesPage),
'user_preferences_page-${theme.toLowerCase()}.png',
);
expect(tester, meetsGuideline(textContrastGuideline));
expect(tester, meetsGuideline(labeledTapTargetGuideline));
expect(tester, meetsGuideline(iOSTapTargetGuideline));
Expand Down
1 change: 0 additions & 1 deletion packages/smooth_app/test/tests_utils/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class MockSmoothApp extends StatelessWidget {
}

Map<String, Object> mockSharedPreferences({
Color color = Colors.lightBlue,
bool init = true,
bool themeDark = false,
}) =>
Expand Down

0 comments on commit 1d5abac

Please sign in to comment.