Skip to content

Commit

Permalink
setup goldens_test and init guest page golden
Browse files Browse the repository at this point in the history
  • Loading branch information
tbm98 committed Oct 21, 2021
1 parent c2971e5 commit 619fc0f
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ app.*.map.json
android/app/google-services.json
ios/Runner/GoogleService-Info.plist
ios/build

# don't check in golden failure output
**/failures/*.png
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ My notes, todo list, and memories.
| ----------- | ----------- | ----------- | ----------- |
| x | x | | |

Guest
![](./test/goldens_test/guest/goldens/guest_page.png)

Guest | Login | Memories
Login | Memories | empty
:-------------------------:|:-------------------------:|:-------------------------:
![](./screenshots/guest.png) | ![](./screenshots/login.png) | ![](./screenshots/memories.png)
| ![](./screenshots/login.png) | ![](./screenshots/memories.png)
Share memory | info | Confirm empty trash
![](./screenshots/share_memory.png) | ![](./screenshots/info.png) | ![](./screenshots/confirm_empty_trash.png)

Expand Down
2 changes: 2 additions & 0 deletions dart_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tags:
golden:
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
golden_toolkit:
dependency: "direct dev"
description:
name: golden_toolkit
url: "https://pub.dartlang.org"
source: hosted
version: "0.11.0"
google_sign_in:
dependency: "direct main"
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ dev_dependencies:
json_serializable: ^5.0.2
freezed: ^0.15.0+1
mockito: ^5.0.16
golden_toolkit: ^0.11.0

# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
Expand Down
Binary file removed screenshots/guest.png
Binary file not shown.
3 changes: 2 additions & 1 deletion scripts/commit_preparing.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
flutter format .
flutter format .
flutter test
1 change: 1 addition & 0 deletions scripts/update_goldens.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flutter test --update-goldens --tags=golden
8 changes: 8 additions & 0 deletions test/flutter_test_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'dart:async';

import 'package:golden_toolkit/golden_toolkit.dart';

Future<void> testExecutable(FutureOr<void> Function() testMain) async {
await loadAppFonts();
return testMain();
}
Binary file added test/goldens_test/guest/goldens/guest_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions test/goldens_test/guest/guest_page_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:notes/src/ui/screens/guest/guest_page.dart';

void main() {
testGoldens('GuestPage',
(tester) async {
final builder = DeviceBuilder()
..overrideDevicesForAllScenarios(devices: [
Device.phone,
Device.iphone11,
Device.tabletPortrait,
Device.tabletLandscape,
])
..addScenario(
widget: const GuestPage(),
name: 'Guest page',
);

await tester.pumpDeviceBuilder(builder);

await screenMatchesGolden(tester, 'guest_page');
});
}

0 comments on commit 619fc0f

Please sign in to comment.