Created
January 3, 2024 17:29
-
-
Save ziadoz/ecda21aa8478cbe51197a444aa3ccf6b to your computer and use it in GitHub Desktop.
Laravel Dusk - Disable Bootstrap 4 CSS Transitions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Tests\Browser; | |
use Tests\DuskTestCase; | |
class ModalTest extends DuskTestCase | |
{ | |
public function test_modal(): void | |
{ | |
$this->browse(function (Browser $browser) { | |
$browser->visit('/modal'); | |
// Disable modal CSS transitions because they interfere with clicking the close button. | |
$browser->script(<<<SCRIPT | |
document.head.insertAdjacentHTML('beforeend', '<style>* { transition: none !important; transform: none; }<style>'); | |
SCRIPT); | |
// Open the modal. | |
$browser->click('a.open-modal'); | |
// Perform some assertions. | |
$browser->whenAvailable('div.modal-dialog', function (Browser $browser) use ($position) { | |
// Do stuff... | |
}); | |
// Close the modal. | |
// Without disabling the transitions, this would fail because things occur so quickly. | |
$browser->click('div.modal-dialog button.close'); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment