Skip to content

Commit

Permalink
Merge pull request #2434 from leancodepl/fix/disable-printing-logs-in…
Browse files Browse the repository at this point in the history
…-some-nested-calls

Disable printing logs in nested `waitUntilVisible` and `waitUntilExits` calls
  • Loading branch information
pdenert authored Nov 27, 2024
2 parents bdf05ae + 1d1e59b commit 3ce9af8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
4 changes: 4 additions & 0 deletions packages/patrol_finders/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.5.1

- Disable printing logs in nested `waitUntilVisible` and `waitUntilExists` calls.

## 2.5.0

- Update `patrol_log`.
Expand Down
18 changes: 15 additions & 3 deletions packages/patrol_finders/lib/src/custom_finders/patrol_finder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,11 @@ class PatrolFinder implements MatchFinder {
wrapWithPatrolLog(
action: 'waitUntilExists',
color: AnsiCodes.cyan,
function: () => tester.waitUntilExists(this, timeout: timeout),
function: () => tester.waitUntilExists(
this,
timeout: timeout,
enablePatrolLog: false,
),
);

/// Waits until this finder finds at least one visible widget.
Expand All @@ -400,11 +404,19 @@ class PatrolFinder implements MatchFinder {
///
/// Timeout is globally set by [PatrolTester.config.visibleTimeout]. If you
/// want to override this global setting, set [timeout].
Future<PatrolFinder> waitUntilVisible({Duration? timeout}) =>
Future<PatrolFinder> waitUntilVisible({
Duration? timeout,
bool enablePatrolLog = true,
}) =>
wrapWithPatrolLog(
action: 'waitUntilVisible',
color: AnsiCodes.cyan,
function: () => tester.waitUntilVisible(this, timeout: timeout),
function: () => tester.waitUntilVisible(
this,
timeout: timeout,
enablePatrolLog: false,
),
enablePatrolLog: enablePatrolLog,
);

/// Returns a finder matching widget of type [T] which also fulfills
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ class PatrolTester {
enablePatrolLog: enablePatrolLog,
function: () async {
var viewPatrolFinder = PatrolFinder(finder: view, tester: this);
await viewPatrolFinder.waitUntilVisible();
await viewPatrolFinder.waitUntilVisible(enablePatrolLog: false);
viewPatrolFinder = viewPatrolFinder.hitTestable().first;
dragDuration ??= config.dragDuration;
settleBetweenScrollsTimeout ??= config.settleBetweenScrollsTimeout;
Expand Down Expand Up @@ -655,7 +655,7 @@ class PatrolTester {
enablePatrolLog: enablePatrolLog,
function: () async {
var viewPatrolFinder = PatrolFinder(finder: view, tester: this);
await viewPatrolFinder.waitUntilVisible();
await viewPatrolFinder.waitUntilVisible(enablePatrolLog: false);
viewPatrolFinder = viewPatrolFinder.hitTestable().first;
dragDuration ??= config.dragDuration;
settleBetweenScrollsTimeout ??= config.settleBetweenScrollsTimeout;
Expand Down Expand Up @@ -719,7 +719,7 @@ class PatrolTester {
final scrollablePatrolFinder = await PatrolFinder(
finder: finderView,
tester: this,
).waitUntilVisible();
).waitUntilVisible(enablePatrolLog: false);

AxisDirection direction;
if (scrollDirection == null) {
Expand Down Expand Up @@ -790,7 +790,7 @@ class PatrolTester {
final scrollablePatrolFinder = await PatrolFinder(
finder: finderView,
tester: this,
).waitUntilVisible();
).waitUntilVisible(enablePatrolLog: false);
AxisDirection direction;
if (scrollDirection == null) {
if (finderView.evaluate().first.widget is Scrollable) {
Expand Down
4 changes: 2 additions & 2 deletions packages/patrol_finders/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: patrol_finders
description: Streamlined, high-level API on top of flutter_test.
version: 2.5.0
version: 2.5.1
homepage: https://patrol.leancode.co
repository: https://github.com/leancodepl/patrol/tree/master/packages/patrol_finders
issue_tracker: https://github.com/leancodepl/patrol/issues?q=is%3Aopen+is%3Aissue+label%3Apackage%3Apatrol_finders
Expand All @@ -20,7 +20,7 @@ dependencies:
flutter_test:
sdk: flutter
meta: ^1.10.0
patrol_log: ^0.2.0
patrol_log: ^0.2.1

dev_dependencies:
leancode_lint: ^14.2.0

0 comments on commit 3ce9af8

Please sign in to comment.