migrating tests (Metrics, NotificationChannels, PHP, Profile and Projects)

This commit is contained in:
Saeed Vaziry
2024-10-10 23:24:07 +02:00
parent 93cee92568
commit 7086e84c3c
16 changed files with 292 additions and 212 deletions

View File

@ -4,7 +4,9 @@
use App\Enums\ServiceStatus;
use App\Models\Service;
use App\Web\Pages\Servers\Metrics\Index;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
use Tests\TestCase;
class MetricsTest extends TestCase
@ -23,7 +25,7 @@ public function test_visit_metrics(): void
'status' => ServiceStatus::READY,
]);
$this->get(route('servers.metrics', ['server' => $this->server]))
$this->get(Index::getUrl(['server' => $this->server]))
->assertSuccessful()
->assertSee('CPU Load')
->assertSee('Memory Usage')
@ -34,8 +36,8 @@ public function test_cannot_visit_metrics(): void
{
$this->actingAs($this->user);
$this->get(route('servers.metrics', ['server' => $this->server]))
->assertNotFound();
$this->get(Index::getUrl(['server' => $this->server]))
->assertForbidden();
}
public function test_update_data_retention(): void
@ -50,14 +52,18 @@ public function test_update_data_retention(): void
'status' => ServiceStatus::READY,
]);
$this->post(route('servers.metrics.settings', ['server' => $this->server]), [
'data_retention' => 30,
])->assertSessionHas('toast.type', 'success');
Livewire::test(Index::class, [
'server' => $this->server,
])
->callAction('data-retention', [
'data_retention' => 365,
])
->assertSuccessful();
$this->assertDatabaseHas('services', [
'server_id' => $this->server->id,
'type' => 'monitoring',
'type_data->data_retention' => 30,
'type_data->data_retention' => 365,
]);
}
}