From aa48915b05c4502e77d746081927f07198aa56fc Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Mon, 29 Apr 2024 20:06:33 +0300 Subject: [PATCH] Update DockerTest.php --- web/tests/Unit/DockerTest.php | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/web/tests/Unit/DockerTest.php b/web/tests/Unit/DockerTest.php index 71d40b6..2c95207 100644 --- a/web/tests/Unit/DockerTest.php +++ b/web/tests/Unit/DockerTest.php @@ -2,13 +2,42 @@ namespace tests\Unit; -use Tests\Feature\Api\ActionTestCase; +use App\Models\User; +use Livewire\Livewire; +use Modules\Docker\Filament\Clusters\Docker\Pages\DockerCatalog; +use Modules\Docker\PostInstall; +use Tests\TestCase; -class DockerTest extends ActionTestCase +class DockerTest extends TestCase { public function testDocker() { + $docker = new PostInstall(); + $docker->setLogFile('/tmp/phyrepanel-docker-install.log'); + $docker->run(); + $dockerIsInstalled = false; + for ($i = 0; $i < 50; $i++) { + $logFile = file_get_contents('/tmp/phyrepanel-docker-install.log'); + if (strpos($logFile, 'Done!') !== false) { + $dockerIsInstalled = true; + break; + } + sleep(1); + } + $this->assertTrue($dockerIsInstalled); + + $this->actingAs(User::factory()->create()); + + $livewireCatalogIndex = Livewire::test(DockerCatalog::class) + ->set('keyword', 'nginx') + ->assertSee('nginx'); + + $viewData = $livewireCatalogIndex->viewData('dockerImages'); + $this->assertNotEmpty($viewData); + + $livewireCatalogIndex->set('keyword', 'non-existing-image') + ->assertDontSee('non-existing-image'); }