Skip to content

Commit

Permalink
Add integration test and widget test flow to playground example
Browse files Browse the repository at this point in the history
  • Loading branch information
AcarFurkan committed Feb 9, 2024
1 parent 1e78e80 commit bfe5f4c
Show file tree
Hide file tree
Showing 11 changed files with 787 additions and 6 deletions.
143 changes: 143 additions & 0 deletions playground/integration_test/playground_flow_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import 'package:demo_ui_components/demo_ui_components.dart';
import 'package:flutter/material.dart';
import 'package:patrol/patrol.dart';
import 'package:playground/main.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
patrolTest(
'Page with forced max height and background color flow',
($) async {
await $.pumpWidgetAndSettle(
const MaterialApp(
home: DemoApp(
androidSdkVersion: 30,
),
),
);
//Page with forced max height and background color flow
expect($('Wolt Modal Sheet Playground'), findsOneWidget);
await $('Show Modal Sheet').tap();
expect($('Choose a use case'), findsOneWidget);
await $('Page with forced max height').tap();
await $('Let\'s start!').tap();
expect($('Page with forced max height and background color'),
findsAtLeast(1));
await $('Close').tap();
expect(
$('Page with forced max height and background color'), findsNothing);

// Page with a hero image flow
await $('Show Modal Sheet').tap();
expect($('Choose a use case'), findsOneWidget);
await $('Page with hero image').tap();
await $('Let\'s start!').tap();
expect($(Image), findsOneWidget);
await $('Close').tap();

// Page with lazy loading list flow
await $('Show Modal Sheet').tap();
expect($('Choose a use case'), findsOneWidget);
await $('Page with lazy loading list').tap();
await $('Let\'s start!').tap();
expect($(SliverList), findsAtLeast(1));
await $(WoltCircularElevatedButton).tap();

//Page with auto-focus text field
//TODO: Ask to manager Shouldn't textformfiel appear on the screen when the page is opened? If so, fix the bug first
await $('Page with auto-focus text field').scrollTo().tap();
await $('Let\'s start!').tap();
expect(
FocusScope.of($.tester.element($(TextFormField))).hasFocus, isTrue);
// await $('Fill the text field to enable').tap();
await $(TextFormField).scrollTo().enterText('Hello');
await $('Submit').tap();
expect($('Page with text field'), findsNothing);

//Page with custom top bar
expect($('Wolt Modal Sheet Playground'), findsOneWidget);
await $('Show Modal Sheet').tap();
await $('Page with custom top bar').scrollTo().tap();
await $('Let\'s start!').tap();
//?: I couldn't find how to test custom top bar. I couldn't take opacity value of Flow.
await $.scrollUntilExists(finder: $(Placeholder));
expect(
find.byWidgetPredicate((widget) =>
widget.runtimeType.toString() == 'TopBarAnimatedBuilder'),
findsOneWidget);
await $('Close').tap();

//Page with no title and no top bar
await $('Show Modal Sheet').tap();
await $('Page with no title and no top bar').scrollTo().tap();
await $('Let\'s start!').tap();
expect(
find.byWidgetPredicate((widget) =>
widget.runtimeType.toString() == 'TopBarAnimatedBuilder'),
findsNothing);
await $('Close').tap();

//Page with dynamic properties
await $('Show Modal Sheet').tap();
await $('Page with dynamic properties').scrollTo().tap();
await $('Let\'s start!').tap();
expect($('Dynamic page properties'), findsOneWidget);
await $(Switch).tap(); // disable Drag for WoLt Modal Sheet
await $.tester.drag($('Dynamic page properties'),
Offset(0, $.tester.view.physicalSize.height / 2));
await $.tester.pumpAndSettle();
expect($('Dynamic page properties'), findsOneWidget);

await $(Switch).tap(); // enable Drag for Wolt Modal Sheet
await $.tester.drag($('Dynamic page properties'),
Offset(0, $.tester.view.physicalSize.height / 2));
await $.tester.pumpAndSettle();
expect($('Dynamic page properties'), findsNothing);
//NonScrollingWoltModalSheetPage example
await $('Show Modal Sheet').tap();
await $('NonScrollingWoltModalSheetPage example').scrollTo().tap();
await $('Let\'s start!').tap();

expect($(SliverList), findsNothing);
await $(WoltCircularElevatedButton).tap();

// All the pages in one flow
await $('All the pages in one flow').scrollTo().tap();
await $('Let\'s start!').tap();
// hero
expect($(Image), findsOneWidget);
await $('Next').tap();
// lazy list
expect($(SliverList), findsAtLeast(1));
await $('Next').tap();
// text field
expect($(TextFormField), findsOneWidget);
await $(TextFormField).scrollTo().enterText('Hello');
await $('Submit').tap();
// noTitleNoTopBar
expect(
find.byWidgetPredicate((widget) =>
widget.runtimeType.toString() == 'TopBarAnimatedBuilder'),
findsNothing);
await $('Next').tap();
// custom top bar
expect(
find.byWidgetPredicate((widget) =>
widget.runtimeType.toString() == 'TopBarAnimatedBuilder'),
findsOneWidget);
await $('Next').tap();
// dynamic page properties
expect($('Dynamic page properties'), findsOneWidget);
await $('Next').tap();
// NonScrollingWoltModalSheetPage example
expect($(SliverList), findsNothing);
await $('Flex: 1\n Tap here to go to the next page').tap();
// forcedMaxHeight
expect($('Page with forced max height and background color'),
findsAtLeast(1));
await $('Close').tap();
expect(
$('Page with forced max height and background color'), findsNothing);
},
);
}
83 changes: 83 additions & 0 deletions playground/integration_test/test_bundle.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion playground/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down Expand Up @@ -32,6 +32,10 @@ target 'Runner' do
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

target 'RunnerUITests' do
inherit! :complete
end
end

post_install do |installer|
Expand Down
42 changes: 42 additions & 0 deletions playground/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
PODS:
- CocoaAsyncSocket (7.6.5)
- device_info_plus (0.0.1):
- Flutter
- Flutter (1.0.0)
- flutter_keyboard_visibility (0.0.1):
- Flutter
- patrol (0.0.1):
- CocoaAsyncSocket (~> 7.6)
- Flutter
- FlutterMacOS

DEPENDENCIES:
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- Flutter (from `Flutter`)
- flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`)
- patrol (from `.symlinks/plugins/patrol/darwin`)

SPEC REPOS:
trunk:
- CocoaAsyncSocket

EXTERNAL SOURCES:
device_info_plus:
:path: ".symlinks/plugins/device_info_plus/ios"
Flutter:
:path: Flutter
flutter_keyboard_visibility:
:path: ".symlinks/plugins/flutter_keyboard_visibility/ios"
patrol:
:path: ".symlinks/plugins/patrol/darwin"

SPEC CHECKSUMS:
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069
patrol: 3e21d514020dbee24b3e3383caac9e8e051292ac

PODFILE CHECKSUM: c06bbe494565b5f0cfb799af75dc36785e60532a

COCOAPODS: 1.14.3
Loading

0 comments on commit bfe5f4c

Please sign in to comment.