This commit is contained in:
Saeed Vaziry
2025-06-01 12:02:25 +02:00
parent 84476db764
commit efacadba10
12 changed files with 252 additions and 235 deletions

View File

@ -6,64 +6,13 @@
use App\Enums\ServiceStatus;
use App\Facades\SSH;
use App\Models\Service;
use App\Web\Pages\Servers\NodeJS\Index;
use App\Web\Pages\Servers\NodeJS\Widgets\NodeJSList;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
use Tests\TestCase;
class NodeJSTest extends TestCase
{
use RefreshDatabase;
public function test_install_new_nodejs(): void
{
SSH::fake();
$this->actingAs($this->user);
Livewire::test(Index::class, ['server' => $this->server])
->callAction('install', [
'version' => NodeJS::V16,
])
->assertSuccessful();
$this->assertDatabaseHas('services', [
'server_id' => $this->server->id,
'type' => 'nodejs',
'version' => NodeJS::V16,
'status' => ServiceStatus::READY,
]);
}
public function test_uninstall_nodejs(): void
{
SSH::fake();
$this->actingAs($this->user);
$php = new Service([
'server_id' => $this->server->id,
'type' => 'nodejs',
'type_data' => [],
'name' => 'nodejs',
'version' => NodeJS::V16,
'status' => ServiceStatus::READY,
'is_default' => true,
]);
$php->save();
Livewire::test(NodeJSList::class, [
'server' => $this->server,
])
->callTableAction('uninstall', $php->id)
->assertSuccessful();
$this->assertDatabaseMissing('services', [
'id' => $php->id,
]);
}
public function test_change_default_nodejs_cli(): void
{
SSH::fake();
@ -81,11 +30,13 @@ public function test_change_default_nodejs_cli(): void
'is_default' => false,
]);
Livewire::test(NodeJSList::class, [
'server' => $this->server,
$this->post(route('node.default-cli', [
'server' => $this->server->id,
'service' => $service->id,
]), [
'version' => NodeJS::V16,
])
->callTableAction('default-nodejs-cli', $service->id)
->assertSuccessful();
->assertSessionDoesntHaveErrors();
$service->refresh();