mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Update StateTest.php
This commit is contained in:
@@ -486,7 +486,7 @@ test('hidden components are excluded from state dehydration except if they are m
|
||||
->fill();
|
||||
|
||||
expect($container)
|
||||
->dehydrateState()->not()->toBe([]);
|
||||
->dehydrateState()->data->not()->toBe([]);
|
||||
|
||||
$container = ComponentContainer::make(Livewire::make())
|
||||
->statePath('data')
|
||||
@@ -505,7 +505,7 @@ test('hidden components are excluded from state dehydration except if they are m
|
||||
->fill();
|
||||
|
||||
expect($container)
|
||||
->dehydrateState()->not()->toBe([]);
|
||||
->dehydrateState()->data->not()->toBe([]);
|
||||
});
|
||||
|
||||
test('hidden components are excluded from state dehydration even if their parent component has a state path', function () {
|
||||
@@ -531,6 +531,74 @@ test('hidden components are excluded from state dehydration even if their parent
|
||||
]);
|
||||
});
|
||||
|
||||
test('components are not excluded from state dehydration if there is another dehydrated field with the same name', function () {
|
||||
$container = ComponentContainer::make(Livewire::make())
|
||||
->statePath('data')
|
||||
->components([
|
||||
(new Component)
|
||||
->statePath($statePath = Str::random())
|
||||
->default(Str::random())
|
||||
->dehydrated(false),
|
||||
(new Component)
|
||||
->statePath($statePath)
|
||||
->default(Str::random()),
|
||||
])
|
||||
->fill();
|
||||
|
||||
expect($container)
|
||||
->dehydrateState()->data->not()->toBe([]);
|
||||
|
||||
$container = ComponentContainer::make(Livewire::make())
|
||||
->statePath('data')
|
||||
->components([
|
||||
(new Component)
|
||||
->statePath($statePath = Str::random())
|
||||
->default(Str::random()),
|
||||
(new Component)
|
||||
->statePath($statePath)
|
||||
->default(Str::random())
|
||||
->dehydrated(false),
|
||||
])
|
||||
->fill();
|
||||
|
||||
expect($container)
|
||||
->dehydrateState()->data->not()->toBe([]);
|
||||
});
|
||||
|
||||
test('hidden components are not excluded from state dehydration if there is another visible field with the same name', function () {
|
||||
$container = ComponentContainer::make(Livewire::make())
|
||||
->statePath('data')
|
||||
->components([
|
||||
(new Component)
|
||||
->statePath($statePath = Str::random())
|
||||
->default(Str::random())
|
||||
->hidden(),
|
||||
(new Component)
|
||||
->statePath($statePath)
|
||||
->default(Str::random()),
|
||||
])
|
||||
->fill();
|
||||
|
||||
expect($container)
|
||||
->dehydrateState()->data->not()->toBe([]);
|
||||
|
||||
$container = ComponentContainer::make(Livewire::make())
|
||||
->statePath('data')
|
||||
->components([
|
||||
(new Component)
|
||||
->statePath($statePath = Str::random())
|
||||
->default(Str::random()),
|
||||
(new Component)
|
||||
->statePath($statePath)
|
||||
->default(Str::random())
|
||||
->hidden(),
|
||||
])
|
||||
->fill();
|
||||
|
||||
expect($container)
|
||||
->dehydrateState()->data->not()->toBe([]);
|
||||
});
|
||||
|
||||
test('disabled components are excluded from state dehydration', function () {
|
||||
$container = ComponentContainer::make(Livewire::make())
|
||||
->statePath('data')
|
||||
@@ -577,7 +645,7 @@ test('disabled components are excluded from state dehydration except if they are
|
||||
->fill();
|
||||
|
||||
expect($container)
|
||||
->dehydrateState()->not()->toBe([]);
|
||||
->dehydrateState()->data->not()->toBe([]);
|
||||
});
|
||||
|
||||
test('disabled components are excluded from state dehydration if their parent component is disabled and not marked as dehydrated', function () {
|
||||
|
||||
Reference in New Issue
Block a user