mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
replace old methods
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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 {}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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', [
|
||||
|
||||
@@ -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',
|
||||
]);
|
||||
|
||||
|
||||
@@ -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',
|
||||
]);
|
||||
|
||||
|
||||
+4
-4
@@ -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',
|
||||
]);
|
||||
|
||||
|
||||
+8
-8
@@ -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',
|
||||
]);
|
||||
|
||||
|
||||
+9
-9
@@ -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();
|
||||
|
||||
+6
-6
@@ -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([
|
||||
|
||||
+8
-8
@@ -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',
|
||||
]);
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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',
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user