<?php public function test_entangle_works_with_turbo()
{
$this->browse(function ($browser) {
$browser->visit(route('entangle-turbo', [], false))
->assertSeeIn('@page.title', 'Testing Entangle with Turbo')
->click('@turbo.link')
->waitForTextIn('@page.title', 'Showing Livewire&Alpine Component after a Turbo Visit')
<?php File::makeDirectory($this->livewireClassesPath('App'), 0755, true);
$this->browse(function (Browser $browser) {
$browser->visit(route('load-dynamic-component', [], false))
->waitForText('Step 1 Active')
->waitFor('#click_me')
->click('#click_me')
<?php public function test_route_bound_properties_are_synced_with_browser_history()
{
$this->browse(function (Browser $browser) {
$browser->visit(route('sync-history', ['step' => 1], false))
->waitForText('Step 1 Active');
$browser->waitForLivewire()->click('@step-2')
<?php public function test_route_bound_properties_are_synced_with_browser_history_when_no_query_string_is_present()
{
$this->browse(function(Browser $browser) {
$browser->visit(route('sync-history-without-query-string', [ 'step' => 1 ], false))->waitForText('Step 1 Active');
$browser->waitForLivewire()->click('@step-2')->assertRouteIs('sync-history-without-query-string', [ 'step' => 2 ]);
<?php public function test_that_query_bound_properties_are_synced_with_browser_history()
{
$this->browse(function (Browser $browser) {
$browser->visit(route('sync-history', ['step' => 1], false))
->waitForText('Help is currently disabled')
->assertQueryStringHas('showHelp', 'false');
<?php public function test_that_route_and_query_bound_properties_can_both_be_synced_with_browser_history()
{
$this->browse(function (Browser $browser) {
$browser->visit(route('sync-history', ['step' => 1], false))
->waitForText('Step 1 Active')
->waitForText('Help is currently disabled')
->assertQueryStringHas('showHelp', 'false');
<?php public function test_that_query_updates_from_child_components_can_coexist()
{
$this->browse(function (Browser $browser) {
$browser->visit(route('sync-history', ['step' => 1], false))
->waitForText('Step 1 Active')
->waitForText('Dark mode is currently disabled')
->assertQueryStringHas('darkmode', 'false');
<?php public function test_that_if_a_parameter_comes_in_from_the_route_and_doesnt_have_a_matching_property_things_dont_break()
{
$this->browse(function (Browser $browser) {
$browser->visit(route('sync-history-without-mount', ['id' => 1], false))
->assertSeeIn('@output', '1')
->waitForLivewire()->click('@button')
->assertSeeIn('@output', '5');
<?php public function test_that_we_are_not_leaking_old_components_into_history_state_on_refresh()
{
$this->browse(function (Browser $browser) {
$browser->visit(route('sync-history', ['step' => 1], false))
->assertScript('Object.keys(window.history.state.livewire).length', 2)
->refresh()
->assertScript('Object.keys(window.history.state.livewire).length', 2);
<?php public function test_that_livewire_does_not_overwrite_existing_history_state()
{
$this->browse(function (Browser $browser) {
$browser->visit(route('sync-history', ['step' => 1], false))
->script('window.history.pushState({ ...window.history.state, userHistoryState: { foo: "bar" }}, document.title)');
$browser->refresh()
<?php public function test_optional_route_bound_properties_are_synced_with_browser_history()
{
$this->browse(function(Browser $browser) {
$browser->visit(route('sync-history-with-optional-parameter', [], false))
->waitForText('Activate Step 1')
->waitForLivewire()
->click('@step-1')
<?php public function redirectRoute($name, $parameters = [], $absolute = true, $navigate = false)
{
$this->redirect(route($name, $parameters, $absolute), $navigate);
}
public function redirectIntended($default = '/', $navigate = false)
<?php public function assertRedirectToRoute($name, $parameters = [])
{
$uri = route($name, $parameters);
return $this->assertRedirect($uri);
}
<?php $component = Livewire::test(TriggersRedirectStub::class);
session()->put('url.intended', route('foo'));
$component->runAction('triggerRedirectIntended');
<?php $component->runAction('triggerRedirectIntended');
$this->assertEquals(route('foo'), $component->effects['redirect']);
}