From 3c9ae12c62b5109ecbb0c5ea162347b63588d910 Mon Sep 17 00:00:00 2001 From: flap152 Date: Fri, 27 Dec 2024 19:58:41 -0500 Subject: [PATCH] fixes from StyleCI --- src/Concerns/MakesAssertions.php | 6 ++++-- tests/Browser/BrowserTest.php | 8 ++++---- tests/Unit/MakesAssertionsTest.php | 2 +- tests/Unit/WaitsForElementsTest.php | 3 --- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Concerns/MakesAssertions.php b/src/Concerns/MakesAssertions.php index a1bf2f7fc..d1f1263ea 100644 --- a/src/Concerns/MakesAssertions.php +++ b/src/Concerns/MakesAssertions.php @@ -189,6 +189,7 @@ public function assertSeeIn($selector, $text, $ignoreCase = false) // "Did not see expected text [{$text}] within any of the elements [{$selector}]." "Did not see expected text [{$text}] within element [{$fullSelector}]." //hard coded in test ); + return $this; } @@ -208,12 +209,13 @@ public function assertDontSeeIn($selector, $text, $ignoreCase = false) PHPUnit::assertNotEmpty($elements); - foreach ($elements as $element){ + foreach ($elements as $element) { PHPUnit::assertFalse( Str::contains($element->getText(), $text, $ignoreCase), "Saw unexpected text [{$text}] within element [{$fullSelector}]." ); } + return $this; } @@ -231,7 +233,7 @@ public function assertSeeAnythingIn($selector) PHPUnit::assertNotEmpty($elements); - foreach ($elements as $element){ + foreach ($elements as $element) { PHPUnit::assertTrue( $element->getText() !== '', "Saw unexpected text [''] within element [{$fullSelector}]." diff --git a/tests/Browser/BrowserTest.php b/tests/Browser/BrowserTest.php index f9a58e661..22f97dbd6 100644 --- a/tests/Browser/BrowserTest.php +++ b/tests/Browser/BrowserTest.php @@ -24,18 +24,18 @@ public function test_it_handle_wait_for_text_in() ->waitForTextIn('@copy-button', 'Copy', 3); }); } + public function test_it_handles_assert_see_in_with_multiple_selection() { $this->browse(function (Browser $browser) { $browser->visit('/tests/assert-see-in') - ->assertSee( 'Hello World') - ->assertDontSee( 'Gesundheit') + ->assertSee('Hello World') + ->assertDontSee('Gesundheit') ->assertSeeIn('', 'Hello World') ->assertSeeIn('#app > h1', 'Hello World') ->assertSeeIn('#app > div', 'Second') ->assertSeeIn('#app > div:nth-child(3)', 'Third') - ->assertDontSeeIn('#app > div:nth-child(3)', 'Second') - ; + ->assertDontSeeIn('#app > div:nth-child(3)', 'Second'); }); } } diff --git a/tests/Unit/MakesAssertionsTest.php b/tests/Unit/MakesAssertionsTest.php index 47719d01a..9bc66c703 100644 --- a/tests/Unit/MakesAssertionsTest.php +++ b/tests/Unit/MakesAssertionsTest.php @@ -1355,7 +1355,7 @@ public function test_assert_dont_see() // // $resolver = m::mock(stdClass::class); // $resolver->shouldReceive('format')->with('foo')->andReturn('body foo'); -//// $resolver->shouldReceive('findOrFail')->with('foo')->andReturn($element); + //// $resolver->shouldReceive('findOrFail')->with('foo')->andReturn($element); // $resolver->shouldReceive('elements')->with('body foo')->andReturn([$element]); // // $browser = new Browser($driver, $resolver); diff --git a/tests/Unit/WaitsForElementsTest.php b/tests/Unit/WaitsForElementsTest.php index 0ea7c1a88..10b88e914 100644 --- a/tests/Unit/WaitsForElementsTest.php +++ b/tests/Unit/WaitsForElementsTest.php @@ -5,7 +5,6 @@ use Facebook\WebDriver\Exception\TimeOutException; use Facebook\WebDriver\Remote\RemoteWebElement; use Facebook\WebDriver\WebDriver; -use Facebook\WebDriver\WebDriverBy; use Facebook\WebDriver\WebDriverWait; use Laravel\Dusk\Browser; use Laravel\Dusk\ElementResolver; @@ -71,7 +70,6 @@ public function test_when_available_missing() $browser = new Browser($driver, $resolver); - try { $browser->whenAvailable('bar', function ($bar) { // Callback not fired as selector not found @@ -106,7 +104,6 @@ public function test_when_available_present() }); } - public function test_default_wait_time() { Browser::$waitSeconds = 2;