diff --git a/src/Stubs/Resource/Page/Create/Form/Fields/Disabled.php b/src/Stubs/Resource/Page/Create/Form/Fields/Disabled.php index 597791a6..9d04c7f7 100644 --- a/src/Stubs/Resource/Page/Create/Form/Fields/Disabled.php +++ b/src/Stubs/Resource/Page/Create/Form/Fields/Disabled.php @@ -11,7 +11,7 @@ class Disabled extends Base public function getDescription(): string { - return 'has a disabled X field on create form'; + return 'has a disabled field on create form'; } public function getShouldGenerate(): bool @@ -19,4 +19,11 @@ public function getShouldGenerate(): bool return collect($this->getResourceCreateFields($this->resource)) ->filter(fn ($field) => $field->isDisabled())->count(); } + + public function getVariables(): array + { + return [ + 'CREATE_PAGE_DISABLED_FIELDS' => $this->convertDoubleQuotedArrayString(collect($this->getResourceCreateFields($this->resource))->filter(fn ($field) => $field->isDisabled())->keys()), + ]; + } } diff --git a/src/Stubs/Resource/Page/Edit/Form/Fields/Disabled.php b/src/Stubs/Resource/Page/Edit/Form/Fields/Disabled.php index 0c41bb84..7ac4d643 100644 --- a/src/Stubs/Resource/Page/Edit/Form/Fields/Disabled.php +++ b/src/Stubs/Resource/Page/Edit/Form/Fields/Disabled.php @@ -11,7 +11,7 @@ class Disabled extends Base public function getDescription(): string { - return 'has a disabled X field on edit form'; + return 'has a disabled field on edit form'; } public function getShouldGenerate(): bool @@ -19,4 +19,11 @@ public function getShouldGenerate(): bool return collect($this->getResourceEditFields($this->resource)) ->filter(fn ($field) => $field->isDisabled())->count(); } + + public function getVariables(): array + { + return [ + 'EDIT_PAGE_DISABLED_FIELDS' => $this->convertDoubleQuotedArrayString(collect($this->getResourceEditFields($this->resource))->filter(fn ($field) => $field->isDisabled())->keys()), + ]; + } } diff --git a/stubs/Resource/Page/Create/Form/Fields/Disabled.stub b/stubs/Resource/Page/Create/Form/Fields/Disabled.stub index 34783ed8..2be4b4b3 100644 --- a/stubs/Resource/Page/Create/Form/Fields/Disabled.stub +++ b/stubs/Resource/Page/Create/Form/Fields/Disabled.stub @@ -1,3 +1,4 @@ -it({{ DESCRIPTION }}, function () { - // -}){{ RESOLVED_GROUP_METHOD }}->todo(); +it({{ DESCRIPTION }}, function (string $field) { + livewire({{ RESOURCE_CREATE_CLASS}}) + ->assertFormFieldIsDisabled($field); +})->with({{ CREATE_PAGE_DISABLED_FIELDS }}){{ RESOLVED_GROUP_METHOD }}; diff --git a/stubs/Resource/Page/Edit/Form/Fields/Disabled.stub b/stubs/Resource/Page/Edit/Form/Fields/Disabled.stub index 34783ed8..f4e1bd07 100644 --- a/stubs/Resource/Page/Edit/Form/Fields/Disabled.stub +++ b/stubs/Resource/Page/Edit/Form/Fields/Disabled.stub @@ -1,3 +1,6 @@ -it({{ DESCRIPTION }}, function () { - // -}){{ RESOLVED_GROUP_METHOD }}->todo(); +it({{ DESCRIPTION }}, function (string $field) { + $record = {{ MODEL_SINGULAR_NAME }}::factory()->create(); + + livewire({{ RESOURCE_EDIT_CLASS}}, ['record' => $record->getRouteKey()]) + ->assertFormFieldIsDisabled($field); +})->with({{ EDIT_PAGE_DISABLED_FIELDS }}){{ RESOLVED_GROUP_METHOD }};