mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 06:56:15 +00:00
#591 - server-providers
This commit is contained in:
@ -3,11 +3,10 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Enums\ServerProvider;
|
||||
use App\Web\Pages\Settings\ServerProviders\Index;
|
||||
use App\Web\Pages\Settings\ServerProviders\Widgets\ServerProvidersList;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Livewire\Livewire;
|
||||
use Inertia\Testing\AssertableInertia;
|
||||
use JsonException;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ServerProvidersTest extends TestCase
|
||||
@ -15,7 +14,11 @@ class ServerProvidersTest extends TestCase
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @dataProvider data
|
||||
*
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_connect_provider(string $provider, array $input): void
|
||||
{
|
||||
@ -30,10 +33,8 @@ public function test_connect_provider(string $provider, array $input): void
|
||||
],
|
||||
$input
|
||||
);
|
||||
Livewire::test(Index::class)
|
||||
->callAction('create', $data)
|
||||
->assertHasNoActionErrors()
|
||||
->assertSuccessful();
|
||||
$this->post(route('server-providers.store'), $data)
|
||||
->assertSessionHasNoErrors();
|
||||
|
||||
$this->assertDatabaseHas('server_providers', [
|
||||
'provider' => $provider,
|
||||
@ -43,6 +44,8 @@ public function test_connect_provider(string $provider, array $input): void
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @dataProvider data
|
||||
*/
|
||||
public function test_cannot_connect_to_provider(string $provider, array $input): void
|
||||
@ -60,10 +63,8 @@ public function test_cannot_connect_to_provider(string $provider, array $input):
|
||||
],
|
||||
$input
|
||||
);
|
||||
Livewire::test(Index::class)
|
||||
->callAction('create', $data)
|
||||
->assertActionHalted('create')
|
||||
->assertNotified();
|
||||
$this->post(route('server-providers.store'), $data)
|
||||
->assertSessionHasErrors('provider');
|
||||
|
||||
$this->assertDatabaseMissing('server_providers', [
|
||||
'provider' => $provider,
|
||||
@ -75,17 +76,19 @@ public function test_see_providers_list(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$provider = \App\Models\ServerProvider::factory()->create([
|
||||
\App\Models\ServerProvider::factory()->create([
|
||||
'user_id' => $this->user->id,
|
||||
]);
|
||||
|
||||
$this->get(Index::getUrl())
|
||||
$this->get(route('server-providers'))
|
||||
->assertSuccessful()
|
||||
->assertSee($provider->profile);
|
||||
->assertInertia(fn (AssertableInertia $page) => $page->component('server-providers/index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data
|
||||
*
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function test_delete_provider(string $provider): void
|
||||
{
|
||||
@ -96,9 +99,9 @@ public function test_delete_provider(string $provider): void
|
||||
'provider' => $provider,
|
||||
]);
|
||||
|
||||
Livewire::test(ServerProvidersList::class)
|
||||
->callTableAction('delete', $provider->id)
|
||||
->assertSuccessful();
|
||||
$this->delete(route('server-providers.destroy', $provider))
|
||||
->assertSessionHasNoErrors()
|
||||
->assertRedirect(route('server-providers'));
|
||||
|
||||
$this->assertDatabaseMissing('server_providers', [
|
||||
'id' => $provider->id,
|
||||
@ -121,15 +124,19 @@ public function test_cannot_delete_provider(string $provider): void
|
||||
'provider_id' => $provider->id,
|
||||
]);
|
||||
|
||||
Livewire::test(ServerProvidersList::class)
|
||||
->callTableAction('delete', $provider->id)
|
||||
->assertNotified('This server provider is being used by a server.');
|
||||
$this->delete(route('server-providers.destroy', $provider))
|
||||
->assertSessionHasErrors([
|
||||
'provider' => 'This server provider is being used by a server.',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('server_providers', [
|
||||
'id' => $provider->id,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<int, array<string, mixed>>>
|
||||
*/
|
||||
public static function data(): array
|
||||
{
|
||||
return [
|
||||
|
@ -6,7 +6,7 @@
|
||||
use App\Models\Project;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Inertia\Testing\AssertableInertia;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UserTest extends TestCase
|
||||
@ -41,7 +41,7 @@ public function test_see_users_list(): void
|
||||
|
||||
$this->get(route('users'))
|
||||
->assertSuccessful()
|
||||
->assertInertia(fn (Assert $page) => $page->component('users/index'));
|
||||
->assertInertia(fn (AssertableInertia $page) => $page->component('users/index'));
|
||||
}
|
||||
|
||||
public function test_must_be_admin_to_see_users_list(): void
|
||||
|
Reference in New Issue
Block a user