mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 06:56:15 +00:00
#591 - node
This commit is contained in:
@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user