Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing test for array update hooks $value #8235

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/Mechanisms/HandleComponents/BrowserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,45 @@ public function render()
->assertSeeIn('@selected', 'D')
;
}

/** @test */
public function it_does_not_show_rm_removal_value_in_update_hooks()
{
Livewire::visit(new class extends Component {
public $updates = [];

public array $items = ['one', 'two', 'three', 'four'];

public function updatedItems($value, $key)
{
$this->updates[] = [
'key' => $key,
'value' => $value,
];
}

public function render()
{
return <<<'HTML'
<div>
<div>Items: <span dusk="items">{{ json_encode($items) }}</span></div>
<div>Updates: <span dusk="updates">{{ json_encode($updates) }}</span></div>

<div x-data="{ values: [] }" x-modelable="values" wire:model.live="items">
<button x-on:click="values = ['two', 'three']" dusk="changeArray">Change array</button>
</div>
</div>
HTML;
}
})
->assertSeeIn('@items', '["one","two","three","four"]')
->assertSeeIn('@updates', '[]')

->waitForLivewire()->click('@changeArray')
->assertSeeIn('@items', '["two","three"]')
->assertSeeIn('@updates', '[{"key":null,"value":["two","three"]}]')
;
}
}

enum Suit: string
Expand Down