diff --git a/docs/10-testing/05-testing-actions.md b/docs/10-testing/05-testing-actions.md index 98a15ae125..c6f5322474 100644 --- a/docs/10-testing/05-testing-actions.md +++ b/docs/10-testing/05-testing-actions.md @@ -42,7 +42,7 @@ it('can send invoices', function () { ->callAction('send', data: [ 'email' => $email = fake()->email(), ]) - ->assertHasNoActionErrors(); + ->assertHasNoFormErrors(); expect($invoice->refresh()) ->isSent()->toBeTrue() @@ -107,9 +107,9 @@ it('confirms the target address before sending', function () { ## Errors -`assertHasNoActionErrors()` is used to assert that no validation errors occurred when submitting the action form. +`assertHasNoFormErrors()` is used to assert that no validation errors occurred when submitting the action form. -To check if a validation error has occurred with the data, use `assertHasActionErrors()`, similar to `assertHasErrors()` in Livewire: +To check if a validation error has occurred with the data, use `assertHasFormErrors()`, similar to `assertHasErrors()` in Livewire: ```php use function Pest\Livewire\livewire; @@ -123,7 +123,7 @@ it('can validate invoice recipient email', function () { ->callAction('send', data: [ 'email' => Str::random(), ]) - ->assertHasActionErrors(['email' => ['email']]); + ->assertHasFormErrors(['email' => ['email']]); }); ``` @@ -144,7 +144,7 @@ it('can send invoices to the primary contact by default', function () { 'email' => $recipientEmail, ]) ->callMountedAction() - ->assertHasNoActionErrors(); + ->assertHasNoFormErrors(); expect($invoice->refresh()) ->isSent()->toBeTrue() diff --git a/packages/actions/.stubs.php b/packages/actions/.stubs.php index b07894620c..4314bb53fb 100644 --- a/packages/actions/.stubs.php +++ b/packages/actions/.stubs.php @@ -63,8 +63,14 @@ namespace Livewire\Features\SupportTesting { public function assertActionHalted(string | TestAction | array $actions = []): static {} + /** + * @deprecated Use `assertHasFormErrors()` instead. + */ public function assertHasActionErrors(array $keys = []): static {} + /** + * @deprecated Use `assertHasNoFormErrors()` instead. + */ public function assertHasNoActionErrors(array $keys = []): static {} public function parseActionName(string | TestAction | array $actions): string {} diff --git a/packages/actions/src/Testing/TestsActions.php b/packages/actions/src/Testing/TestsActions.php index 37cdb5bf21..a3d5d533d0 100644 --- a/packages/actions/src/Testing/TestsActions.php +++ b/packages/actions/src/Testing/TestsActions.php @@ -523,17 +523,7 @@ class TestsActions public function assertHasActionErrors(): Closure { return function (array $keys = []): static { - $this->assertHasErrors( - collect($keys) - ->mapWithKeys(function ($value, $key): array { - if (is_int($key)) { - return [$key => 'mountedActions.' . array_key_last($this->instance()->mountedActions) . '.data.' . $value]; - } - - return ['mountedActions.' . array_key_last($this->instance()->mountedActions) . '.data.' . $key => $value]; - }) - ->all(), - ); + $this->assertHasFormErrors($keys); return $this; }; @@ -542,17 +532,7 @@ class TestsActions public function assertHasNoActionErrors(): Closure { return function (array $keys = []): static { - $this->assertHasNoErrors( - collect($keys) - ->mapWithKeys(function ($value, $key): array { - if (is_int($key)) { - return [$key => 'mountedActions.' . array_key_last($this->instance()->mountedActions) . '.data.' . $value]; - } - - return ['mountedActions.' . array_key_last($this->instance()->mountedActions) . '.data.' . $key => $value]; - }) - ->all(), - ); + $this->assertHasNoFormErrors($keys); return $this; }; diff --git a/packages/forms/.stubs.php b/packages/forms/.stubs.php index 35c94efa93..64b38372d8 100644 --- a/packages/forms/.stubs.php +++ b/packages/forms/.stubs.php @@ -124,12 +124,12 @@ namespace Livewire\Features\SupportTesting { public function assertFormComponentActionHalted(string | array $component, string | array $name, string $formName = 'form'): static {} /** - * @deprecated Use `assertHasActionErrors()` instead. + * @deprecated Use `assertHasFormErrors()` instead. */ public function assertHasFormComponentActionErrors(array $keys = []): static {} /** - * @deprecated Use `assertHasNoActionErrors()` instead. + * @deprecated Use `assertHasNoFormErrors()` instead. */ public function assertHasNoFormComponentActionErrors(array $keys = []): static {} diff --git a/packages/forms/src/Testing/TestsFormComponentActions.php b/packages/forms/src/Testing/TestsFormComponentActions.php index 3f536dafc8..f8b8e59a02 100644 --- a/packages/forms/src/Testing/TestsFormComponentActions.php +++ b/packages/forms/src/Testing/TestsFormComponentActions.php @@ -320,7 +320,7 @@ class TestsFormComponentActions public function assertHasFormComponentActionErrors(): Closure { return function (array $keys = []): static { - $this->assertHasActionErrors($keys); + $this->assertHasFormErrors($keys); return $this; }; @@ -329,7 +329,7 @@ class TestsFormComponentActions public function assertHasNoFormComponentActionErrors(): Closure { return function (array $keys = []): static { - $this->assertHasNoActionErrors($keys); + $this->assertHasNoFormErrors($keys); return $this; }; diff --git a/packages/infolists/.stubs.php b/packages/infolists/.stubs.php index ab6c42cb4b..ab63ebfb6d 100644 --- a/packages/infolists/.stubs.php +++ b/packages/infolists/.stubs.php @@ -81,12 +81,12 @@ namespace Livewire\Features\SupportTesting { public function assertInfolistActionHalted(string $component, string | array $name, string $infolistName = 'infolist'): static {} /** - * @deprecated Use `assertHasActionErrors()` instead. + * @deprecated Use `assertHasFormErrors()` instead. */ public function assertHasInfolistActionErrors(array $keys = []): static {} /** - * @deprecated Use `assertHasNoActionErrors()` instead. + * @deprecated Use `assertHasNoFormErrors()` instead. */ public function assertHasNoInfolistActionErrors(array $keys = []): static {} diff --git a/packages/infolists/src/Testing/TestsInfolistActions.php b/packages/infolists/src/Testing/TestsInfolistActions.php index 78c2bcc7f1..7f2d1e5bec 100644 --- a/packages/infolists/src/Testing/TestsInfolistActions.php +++ b/packages/infolists/src/Testing/TestsInfolistActions.php @@ -319,7 +319,7 @@ class TestsInfolistActions public function assertHasInfolistActionErrors(): Closure { return function (array $keys = []): static { - $this->assertHasActionErrors($keys); + $this->assertHasFormErrors($keys); return $this; }; @@ -328,7 +328,7 @@ class TestsInfolistActions public function assertHasNoInfolistActionErrors(): Closure { return function (array $keys = []): static { - $this->assertHasNoActionErrors($keys); + $this->assertHasNoFormErrors($keys); return $this; }; diff --git a/packages/tables/.stubs.php b/packages/tables/.stubs.php index a41321c448..44d6568d2d 100644 --- a/packages/tables/.stubs.php +++ b/packages/tables/.stubs.php @@ -164,7 +164,7 @@ namespace Livewire\Features\SupportTesting { public function assertHasTableActionErrors(array $keys = []): static {} /** - * @deprecated Use `assertHasNoActionErrors()` instead. + * @deprecated Use `assertHasNoFormErrors()` instead. */ public function assertHasNoTableActionErrors(array $keys = []): static {} @@ -324,12 +324,12 @@ namespace Livewire\Features\SupportTesting { public function assertTableBulkActionHalted(string $name): static {} /** - * @deprecated Use `assertHasActionErrors()` instead. + * @deprecated Use `assertHasFormErrors()` instead. */ public function assertHasTableBulkActionErrors(array $keys = []): static {} /** - * @deprecated Use `assertHasNoActionErrors()` instead. + * @deprecated Use `assertHasNoFormErrors()` instead. */ public function assertHasNoTableBulkActionErrors(array $keys = []): static {} } diff --git a/packages/tables/src/Testing/TestsActions.php b/packages/tables/src/Testing/TestsActions.php index b2b703c6bb..d94c12b8f8 100644 --- a/packages/tables/src/Testing/TestsActions.php +++ b/packages/tables/src/Testing/TestsActions.php @@ -373,7 +373,7 @@ class TestsActions public function assertHasTableActionErrors(): Closure { return function (array $keys = []): static { - $this->assertHasActionErrors($keys); + $this->assertHasFormErrors($keys); return $this; }; @@ -382,7 +382,7 @@ class TestsActions public function assertHasNoTableActionErrors(): Closure { return function (array $keys = []): static { - $this->assertHasNoActionErrors($keys); + $this->assertHasNoFormErrors($keys); return $this; }; diff --git a/packages/tables/src/Testing/TestsBulkActions.php b/packages/tables/src/Testing/TestsBulkActions.php index 6786be6048..2f2a6d729c 100644 --- a/packages/tables/src/Testing/TestsBulkActions.php +++ b/packages/tables/src/Testing/TestsBulkActions.php @@ -307,7 +307,7 @@ class TestsBulkActions public function assertHasTableBulkActionErrors(): Closure { return function (array $keys = []): static { - $this->assertHasActionErrors($keys); + $this->assertHasFormErrors($keys); return $this; }; @@ -316,7 +316,7 @@ class TestsBulkActions public function assertHasNoTableBulkActionErrors(): Closure { return function (array $keys = []): static { - $this->assertHasNoActionErrors($keys); + $this->assertHasNoFormErrors($keys); return $this; }; diff --git a/tests/src/Actions/ActionTest.php b/tests/src/Actions/ActionTest.php index a27de404f9..1238d13d6c 100644 --- a/tests/src/Actions/ActionTest.php +++ b/tests/src/Actions/ActionTest.php @@ -23,7 +23,7 @@ it('can call an action with data', function (): void { ->callAction('data', data: [ 'payload' => $payload = Str::random(), ]) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('data-called', data: [ 'payload' => $payload, ]); @@ -34,7 +34,7 @@ it('can validate an action\'s data', function (): void { ->callAction('data', data: [ 'payload' => null, ]) - ->assertHasActionErrors(['payload' => ['required']]) + ->assertHasFormErrors(['payload' => ['required']]) ->assertNotDispatched('data-called'); }); @@ -43,7 +43,7 @@ it('can access form data in before hook', function (): void { ->callAction('before-hook-data', data: [ 'payload' => $payload = Str::random(), ]) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('before-hook-called', data: [ 'payload' => $payload, ]); @@ -52,7 +52,7 @@ it('can access form data in before hook', function (): void { it('can set default action data when mounted', function (): void { livewire(Actions::class) ->mountAction('data') - ->assertActionDataSet([ + ->assertSchemaSet([ 'foo' => 'bar', ]); }); @@ -65,12 +65,12 @@ it('can call a nested action registered in the modal footer', function (): void ], [ 'bar' => Str::random(), ]) - ->assertHasNoActionErrors() - ->setActionData([ + ->assertHasNoFormErrors() + ->fillForm([ 'foo' => $foo = Str::random(), ]) ->callMountedAction() - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('parent-called', foo: $foo); }); @@ -82,12 +82,12 @@ it('can call a manually modal registered nested action', function (): void { ], [ 'bar' => Str::random(), ]) - ->assertHasNoActionErrors() - ->setActionData([ + ->assertHasNoFormErrors() + ->fillForm([ 'foo' => $foo = Str::random(), ]) ->callMountedAction() - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('parent-called', foo: $foo); }); @@ -99,12 +99,12 @@ it('can call a nested action registered on a schema component', function (): voi ], [ 'bar' => Str::random(), ]) - ->assertHasNoActionErrors() - ->setActionData([ + ->assertHasNoFormErrors() + ->fillForm([ 'foo' => $foo = Str::random(), ]) ->callMountedAction() - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('parent-called', foo: $foo); }); @@ -116,7 +116,7 @@ it('can cancel a parent action when calling a nested action', function (): void ], [ 'bar' => Str::random(), ]) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertActionNotMounted() ->assertNotDispatched('parent-called'); }); @@ -173,11 +173,11 @@ it('can mount a nested action with nested arguments', function (): void { it('can get the raw data from parent actions', function (): void { livewire(Actions::class) ->mountAction('parent') - ->setActionData([ + ->fillForm([ 'foo' => $foo = Str::random(), ]) ->mountAction('manuallyRegisteredModal') - ->setActionData([ + ->fillForm([ 'bar' => $bar = Str::random(), ]) ->callAction('testData', [ diff --git a/tests/src/Forms/ActionTest.php b/tests/src/Forms/ActionTest.php index e86c0c5f27..37b5a9556c 100644 --- a/tests/src/Forms/ActionTest.php +++ b/tests/src/Forms/ActionTest.php @@ -55,7 +55,7 @@ it('can validate an action\'s data', function (): void { ->callAction(TestAction::make('setValue')->schemaComponent('textInput'), data: [ 'value' => null, ]) - ->assertHasActionErrors(['value' => ['required']]) + ->assertHasFormErrors(['value' => ['required']]) ->assertFormSet(['textInput' => null]); livewire(Actions::class) @@ -69,7 +69,7 @@ it('can validate an action\'s data', function (): void { it('can set default action data when mounted', function (): void { livewire(Actions::class) ->mountAction(TestAction::make('setValue')->schemaComponent('textInput')) - ->assertActionDataSet([ + ->assertSchemaSet([ 'value' => 'foo', ]); diff --git a/tests/src/Infolists/ActionTest.php b/tests/src/Infolists/ActionTest.php index e0e747f22b..d9ec1c5d7e 100644 --- a/tests/src/Infolists/ActionTest.php +++ b/tests/src/Infolists/ActionTest.php @@ -30,7 +30,7 @@ it('can validate an action\'s data', function (): void { ->callAction(TestAction::make('setValue')->schemaComponent('textEntry'), data: [ 'value' => null, ]) - ->assertHasActionErrors(['value' => ['required']]) + ->assertHasFormErrors(['value' => ['required']]) ->assertNotDispatched('foo'); livewire(InfolistActions::class) @@ -44,7 +44,7 @@ it('can validate an action\'s data', function (): void { it('can set default action data when mounted', function (): void { livewire(InfolistActions::class) ->mountAction(TestAction::make('setValue')->schemaComponent('textEntry')) - ->assertActionDataSet([ + ->assertSchemaSet([ 'value' => 'foo', ]); diff --git a/tests/src/Panels/Auth/MultiFactor/EmailCode/DisableEmailCodeAuthenticationActionTest.php b/tests/src/Panels/Auth/MultiFactor/EmailCode/DisableEmailCodeAuthenticationActionTest.php index 80560ddbc8..9d8c448cd6 100644 --- a/tests/src/Panels/Auth/MultiFactor/EmailCode/DisableEmailCodeAuthenticationActionTest.php +++ b/tests/src/Panels/Auth/MultiFactor/EmailCode/DisableEmailCodeAuthenticationActionTest.php @@ -44,7 +44,7 @@ it('can disable authentication when valid challenge code is used', function (): ->schemaComponent('email_code', schema: 'content'), ['code' => $emailCodeAuthentication->getCurrentCode($user)], ) - ->assertHasNoActionErrors(); + ->assertHasNoFormErrors(); expect($user->hasEmailCodeAuthentication()) ->toBeFalse(); @@ -120,7 +120,7 @@ it('will not disable authentication when an invalid code is used', function (): ->schemaComponent('email_code', schema: 'content'), ['code' => ($emailCodeAuthentication->getCurrentCode($user) === '000000') ? '111111' : '000000'], ) - ->assertHasActionErrors(); + ->assertHasFormErrors(); expect($user->hasEmailCodeAuthentication()) ->toBeTrue(); @@ -144,7 +144,7 @@ test('codes are required', function (): void { ->schemaComponent('email_code', schema: 'content'), ['code' => ''], ) - ->assertHasActionErrors([ + ->assertHasFormErrors([ 'code' => 'required', ]); @@ -172,7 +172,7 @@ test('codes must be 6 digits', function (): void { ->schemaComponent('email_code', schema: 'content'), ['code' => Str::limit($emailCodeAuthentication->getCurrentCode($user), limit: 5, end: '')], ) - ->assertHasActionErrors([ + ->assertHasFormErrors([ 'code' => 'digits', ]); diff --git a/tests/src/Panels/Auth/MultiFactor/EmailCode/SetUpEmailCodeAuthenticationActionTest.php b/tests/src/Panels/Auth/MultiFactor/EmailCode/SetUpEmailCodeAuthenticationActionTest.php index 1b1ee37bc7..9273374529 100644 --- a/tests/src/Panels/Auth/MultiFactor/EmailCode/SetUpEmailCodeAuthenticationActionTest.php +++ b/tests/src/Panels/Auth/MultiFactor/EmailCode/SetUpEmailCodeAuthenticationActionTest.php @@ -76,9 +76,9 @@ it('can save the secret to the user when the action is submitted', function (): $secret = $encryptedActionArguments['secret']; $livewire - ->setActionData(['code' => $emailCodeAuthentication->getCurrentCode($user, $secret)]) + ->fillForm(['code' => $emailCodeAuthentication->getCurrentCode($user, $secret)]) ->callMountedAction() - ->assertHasNoActionErrors(); + ->assertHasNoFormErrors(); expect($user->hasEmailCodeAuthentication()) ->toBeTrue(); @@ -148,11 +148,11 @@ it('will not set up authentication when an invalid code is used', function (): v $secret = $encryptedActionArguments['secret']; $livewire - ->setActionData([ + ->fillForm([ 'code' => ($emailCodeAuthentication->getCurrentCode($user, $secret) === '000000') ? '111111' : '000000', ]) ->callMountedAction() - ->assertHasActionErrors(); + ->assertHasFormErrors(); expect($user->hasEmailCodeAuthentication()) ->toBeFalse(); @@ -173,9 +173,9 @@ test('codes are required', function (): void { livewire(EditProfile::class) ->mountAction(TestAction::make('setUpEmailCodeAuthentication') ->schemaComponent('email_code', schema: 'content')) - ->setActionData(['code' => '']) + ->fillForm(['code' => '']) ->callMountedAction() - ->assertHasActionErrors([ + ->assertHasFormErrors([ 'code' => 'required', ]); @@ -205,11 +205,11 @@ test('codes must be 6 digits', function (): void { $secret = $encryptedActionArguments['secret']; $livewire - ->setActionData([ + ->fillForm([ 'code' => Str::limit($emailCodeAuthentication->getCurrentCode($user, $secret), limit: 5, end: ''), ]) ->callMountedAction() - ->assertHasActionErrors([ + ->assertHasFormErrors([ 'code' => 'digits', ]); diff --git a/tests/src/Panels/Auth/MultiFactor/GoogleTwoFactor/Actions/DisableGoogleTwoFactorAuthenticationActionTest.php b/tests/src/Panels/Auth/MultiFactor/GoogleTwoFactor/Actions/DisableGoogleTwoFactorAuthenticationActionTest.php index 1075272adc..0d341d83aa 100644 --- a/tests/src/Panels/Auth/MultiFactor/GoogleTwoFactor/Actions/DisableGoogleTwoFactorAuthenticationActionTest.php +++ b/tests/src/Panels/Auth/MultiFactor/GoogleTwoFactor/Actions/DisableGoogleTwoFactorAuthenticationActionTest.php @@ -46,7 +46,7 @@ it('can disable authentication when valid challenge code is used', function (): ->schemaComponent('google_two_factor', schema: 'content'), ['code' => $googleTwoFactorAuthentication->getCurrentCode($user)], ) - ->assertHasNoActionErrors(); + ->assertHasNoFormErrors(); expect($user->hasGoogleTwoFactorAuthentication()) ->toBeFalse(); @@ -76,11 +76,11 @@ it('can disable authentication when a valid recovery code is used', function (): ->schemaComponent('google_two_factor', schema: 'content')) ->callAction(TestAction::make('useRecoveryCode') ->schemaComponent('code')) - ->setActionData([ + ->fillForm([ 'recoveryCode' => Arr::first($this->recoveryCodes), ]) ->callMountedAction() - ->assertHasNoActionErrors(); + ->assertHasNoFormErrors(); expect($user->hasGoogleTwoFactorAuthentication()) ->toBeFalse(); @@ -113,7 +113,7 @@ it('will not disable authentication when an invalid code is used', function (): ->schemaComponent('google_two_factor', schema: 'content'), ['code' => ($googleTwoFactorAuthentication->getCurrentCode($user) === '000000') ? '111111' : '000000'], ) - ->assertHasActionErrors(); + ->assertHasFormErrors(); expect($user->hasGoogleTwoFactorAuthentication()) ->toBeTrue(); @@ -145,7 +145,7 @@ test('codes are required without a recovery code', function (): void { ->schemaComponent('google_two_factor', schema: 'content'), ['code' => ''], ) - ->assertHasActionErrors([ + ->assertHasFormErrors([ 'code' => 'required', ]); @@ -181,7 +181,7 @@ test('codes must be 6 digits', function (): void { ->schemaComponent('google_two_factor', schema: 'content'), ['code' => Str::limit($googleTwoFactorAuthentication->getCurrentCode($user), limit: 5, end: '')], ) - ->assertHasActionErrors([ + ->assertHasFormErrors([ 'code' => 'digits', ]); @@ -214,11 +214,11 @@ it('will not disable authentication when an invalid recovery code is used', func ->schemaComponent('google_two_factor', schema: 'content')) ->callAction(TestAction::make('useRecoveryCode') ->schemaComponent('code')) - ->setActionData([ + ->fillForm([ 'recoveryCode' => 'invalid-recovery-code', ]) ->callMountedAction() - ->assertHasActionErrors(); + ->assertHasFormErrors(); expect($user->hasGoogleTwoFactorAuthentication()) ->toBeTrue(); @@ -253,7 +253,7 @@ it('will not disable authentication with a recovery code if recovery is disabled ->schemaComponent('google_two_factor', schema: 'content'), ['recoveryCode' => Arr::first($this->recoveryCodes)], ) - ->assertHasActionErrors(); + ->assertHasFormErrors(); expect($user->hasGoogleTwoFactorAuthentication()) ->toBeTrue(); diff --git a/tests/src/Panels/Auth/MultiFactor/GoogleTwoFactor/Actions/RegenerateGoogleTwoFactorAuthenticationRecoveryCodesActionTest.php b/tests/src/Panels/Auth/MultiFactor/GoogleTwoFactor/Actions/RegenerateGoogleTwoFactorAuthenticationRecoveryCodesActionTest.php index 9c8045e49e..e078de96ab 100644 --- a/tests/src/Panels/Auth/MultiFactor/GoogleTwoFactor/Actions/RegenerateGoogleTwoFactorAuthenticationRecoveryCodesActionTest.php +++ b/tests/src/Panels/Auth/MultiFactor/GoogleTwoFactor/Actions/RegenerateGoogleTwoFactorAuthenticationRecoveryCodesActionTest.php @@ -34,7 +34,7 @@ it('can generate new recovery codes when valid challenge code is used', function ->schemaComponent('google_two_factor', schema: 'content'), ['code' => $googleTwoFactorAuthentication->getCurrentCode($user)], ) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertActionMounted([ TestAction::make('regenerateGoogleTwoFactorAuthenticationRecoveryCodes') ->schemaComponent('google_two_factor', schema: 'content'), @@ -79,7 +79,7 @@ it('can generate new recovery codes when the current user\'s password is used', ->schemaComponent('google_two_factor', schema: 'content'), ['password' => 'password'], ) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertActionMounted([ TestAction::make('regenerateGoogleTwoFactorAuthenticationRecoveryCodes') ->schemaComponent('google_two_factor', schema: 'content'), @@ -126,7 +126,7 @@ it('will not generate new recovery codes when an invalid code is used', function ->schemaComponent('google_two_factor', schema: 'content'), ['code' => ($googleTwoFactorAuthentication->getCurrentCode($user) === '000000') ? '111111' : '000000'], ) - ->assertHasActionErrors() + ->assertHasFormErrors() ->assertActionNotMounted([ TestAction::make('regenerateGoogleTwoFactorAuthenticationRecoveryCodes') ->schemaComponent('google_two_factor', schema: 'content'), @@ -148,7 +148,7 @@ test('codes are required without the user\'s current password', function (): voi ->schemaComponent('google_two_factor', schema: 'content'), ['code' => ''], ) - ->assertHasActionErrors([ + ->assertHasFormErrors([ 'code' => 'required_without', ]) ->assertActionNotMounted([ @@ -174,7 +174,7 @@ test('codes must be 6 digits', function (): void { ->schemaComponent('google_two_factor', schema: 'content'), ['code' => Str::limit($googleTwoFactorAuthentication->getCurrentCode($user), limit: 5, end: '')], ) - ->assertHasActionErrors([ + ->assertHasFormErrors([ 'code' => 'digits', ]) ->assertActionNotMounted([ @@ -198,7 +198,7 @@ test('the user\'s current password must be valid', function (): void { ->schemaComponent('google_two_factor', schema: 'content'), ['password' => 'incorrect-password'], ) - ->assertHasActionErrors([ + ->assertHasFormErrors([ 'password' => 'current_password', ]) ->assertActionNotMounted([ diff --git a/tests/src/Panels/Auth/MultiFactor/GoogleTwoFactor/Actions/SetUpGoogleTwoFactorAuthenticationActionTest.php b/tests/src/Panels/Auth/MultiFactor/GoogleTwoFactor/Actions/SetUpGoogleTwoFactorAuthenticationActionTest.php index 9bb608161b..0ba6afb593 100644 --- a/tests/src/Panels/Auth/MultiFactor/GoogleTwoFactor/Actions/SetUpGoogleTwoFactorAuthenticationActionTest.php +++ b/tests/src/Panels/Auth/MultiFactor/GoogleTwoFactor/Actions/SetUpGoogleTwoFactorAuthenticationActionTest.php @@ -82,9 +82,9 @@ it('can save the secret and recovery codes to the user when the action is submit $recoveryCodes = $encryptedActionArguments['recoveryCodes']; $livewire - ->setActionData(['code' => $googleTwoFactorAuthentication->getCurrentCode($user, $secret)]) + ->fillForm(['code' => $googleTwoFactorAuthentication->getCurrentCode($user, $secret)]) ->callMountedAction() - ->assertHasNoActionErrors(); + ->assertHasNoFormErrors(); expect($user->hasGoogleTwoFactorAuthentication()) ->toBeTrue(); @@ -124,11 +124,11 @@ it('will not set up authentication when an invalid code is used', function (): v $secret = $encryptedActionArguments['secret']; $livewire - ->setActionData([ + ->fillForm([ 'code' => ($googleTwoFactorAuthentication->getCurrentCode($user, $secret) === '000000') ? '111111' : '000000', ]) ->callMountedAction() - ->assertHasActionErrors(); + ->assertHasFormErrors(); expect($user->hasGoogleTwoFactorAuthentication()) ->toBeFalse(); @@ -155,9 +155,9 @@ test('codes are required', function (): void { livewire(EditProfile::class) ->mountAction(TestAction::make('setUpGoogleTwoFactorAuthentication') ->schemaComponent('google_two_factor', schema: 'content')) - ->setActionData(['code' => '']) + ->fillForm(['code' => '']) ->callMountedAction() - ->assertHasActionErrors([ + ->assertHasFormErrors([ 'code' => 'required', ]); @@ -193,11 +193,11 @@ test('codes must be 6 digits', function (): void { $secret = $encryptedActionArguments['secret']; $livewire - ->setActionData([ + ->fillForm([ 'code' => Str::limit($googleTwoFactorAuthentication->getCurrentCode($user, $secret), limit: 5, end: ''), ]) ->callMountedAction() - ->assertHasActionErrors([ + ->assertHasFormErrors([ 'code' => 'digits', ]); diff --git a/tests/src/Tables/Actions/ActionTest.php b/tests/src/Tables/Actions/ActionTest.php index 809bb05458..2aebfb5751 100644 --- a/tests/src/Tables/Actions/ActionTest.php +++ b/tests/src/Tables/Actions/ActionTest.php @@ -37,7 +37,7 @@ it('can call an action with data', function (): void { ->callAction(TestAction::make('data')->table(), data: [ 'payload' => $payload = Str::random(), ]) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('data-called', data: [ 'payload' => $payload, ]); @@ -73,7 +73,7 @@ it('can validate an action\'s data', function (): void { ->callAction(TestAction::make('data')->table(), data: [ 'payload' => null, ]) - ->assertHasActionErrors(['payload' => ['required']]) + ->assertHasFormErrors(['payload' => ['required']]) ->assertNotDispatched('data-called'); livewire(PostsTable::class) @@ -87,7 +87,7 @@ it('can validate an action\'s data', function (): void { it('can set default action data when mounted', function (): void { livewire(PostsTable::class) ->mountAction(TestAction::make('data')->table()) - ->assertActionDataSet([ + ->assertSchemaSet([ 'foo' => 'bar', ]); @@ -111,13 +111,13 @@ it('can call a nested action registered in the modal footer', function (): void ], [ 'bar' => $bar = Str::random(), ]) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('nested-called', bar: $bar, recordKey: $post->getKey()) - ->setActionData([ + ->fillForm([ 'foo' => $foo = Str::random(), ]) ->callMountedAction() - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('parent-called', foo: $foo, recordKey: $post->getKey()); }); @@ -131,13 +131,13 @@ it('can call a manually modal registered nested action', function (): void { ], [ 'bar' => $bar = Str::random(), ]) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('nested-called', bar: $bar, recordKey: $post->getKey()) - ->setActionData([ + ->fillForm([ 'foo' => $foo = Str::random(), ]) ->callMountedAction() - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('parent-called', foo: $foo, recordKey: $post->getKey()); }); @@ -151,13 +151,13 @@ it('can call a nested action registered on a schema component', function (): voi ], [ 'bar' => $bar = Str::random(), ]) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('nested-called', bar: $bar, recordKey: $post->getKey()) - ->setActionData([ + ->fillForm([ 'foo' => $foo = Str::random(), ]) ->callMountedAction() - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('parent-called', foo: $foo, recordKey: $post->getKey()); }); @@ -171,7 +171,7 @@ it('can cancel a parent action when calling a nested action', function (): void ], [ 'bar' => $bar = Str::random(), ]) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('nested-called', bar: $bar, recordKey: $post->getKey()) ->assertActionNotMounted() ->assertNotDispatched('parent-called'); @@ -187,13 +187,13 @@ it('can call a grouped nested action registered in the modal footer', function ( ], [ 'bar' => $bar = Str::random(), ]) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('nested-called', bar: $bar, recordKey: $post->getKey()) - ->setActionData([ + ->fillForm([ 'foo' => $foo = Str::random(), ]) ->callMountedAction() - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('grouped-parent-called', foo: $foo, recordKey: $post->getKey()); }); @@ -207,13 +207,13 @@ it('can call a grouped manually modal registered nested action', function (): vo ], [ 'bar' => $bar = Str::random(), ]) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('nested-called', bar: $bar, recordKey: $post->getKey()) - ->setActionData([ + ->fillForm([ 'foo' => $foo = Str::random(), ]) ->callMountedAction() - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('grouped-parent-called', foo: $foo, recordKey: $post->getKey()); }); @@ -227,13 +227,13 @@ it('can call a grouped nested action registered on a schema component', function ], [ 'bar' => $bar = Str::random(), ]) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('nested-called', bar: $bar, recordKey: $post->getKey()) - ->setActionData([ + ->fillForm([ 'foo' => $foo = Str::random(), ]) ->callMountedAction() - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('grouped-parent-called', foo: $foo, recordKey: $post->getKey()); }); @@ -247,7 +247,7 @@ it('can cancel a grouped parent action when calling a nested action', function ( ], [ 'bar' => $bar = Str::random(), ]) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('nested-called', bar: $bar, recordKey: $post->getKey()) ->assertActionNotMounted() ->assertNotDispatched('grouped-parent-called'); diff --git a/tests/src/Tables/Actions/BulkActionTest.php b/tests/src/Tables/Actions/BulkActionTest.php index 45e2d835d0..8c0e7a2327 100644 --- a/tests/src/Tables/Actions/BulkActionTest.php +++ b/tests/src/Tables/Actions/BulkActionTest.php @@ -42,7 +42,7 @@ it('can call a bulk action with data', function (): void { ->callAction(TestAction::make('data')->table()->bulk(), data: [ 'payload' => $payload = Str::random(), ]) - ->assertHasNoActionErrors() + ->assertHasNoFormErrors() ->assertDispatched('data-called', data: [ 'payload' => $payload, ]); @@ -65,7 +65,7 @@ it('can validate a bulk action\'s data', function (): void { ->callAction(TestAction::make('data')->table()->bulk(), data: [ 'payload' => null, ]) - ->assertHasActionErrors(['payload' => ['required']]) + ->assertHasFormErrors(['payload' => ['required']]) ->assertNotDispatched('data-called'); livewire(PostsTable::class) @@ -82,7 +82,7 @@ it('can set default bulk action data when mounted', function (): void { livewire(PostsTable::class) ->selectTableRecords($posts) ->mountAction(TestAction::make('data')->table()->bulk()) - ->assertActionDataSet([ + ->assertSchemaSet([ 'foo' => 'bar', ]);