actingAs($this->user); $this->get( Index::getUrl([ 'server' => $this->server, ]) ) ->assertSuccessful() ->assertSee('.cache') ->assertSee('.config'); } public function test_upload_file(): void { SSH::fake(); $this->actingAs($this->user); Livewire::test(FilesList::class, [ 'server' => $this->server, ]) ->callTableAction('upload', null, [ 'file' => UploadedFile::fake()->create('test.txt'), ]) ->assertSuccessful(); } public function test_create_file(): void { SSH::fake(<<<'EOF' total 3 drwxr-xr-x 7 vito vito 4096 Feb 2 19:42 . drwxr-xr-x 3 root root 4096 Feb 1 18:44 .. -rw-rw-r-- 1 vito vito 82 Feb 2 14:13 test.txt EOF ); $this->actingAs($this->user); Livewire::test(FilesList::class, [ 'server' => $this->server, ]) ->callTableAction('new-file', null, [ 'name' => 'test.txt', 'content' => 'Hello, world!', ]) ->assertSuccessful(); $this->assertDatabaseHas('files', [ 'name' => 'test.txt', ]); } public function test_create_directory(): void { SSH::fake(<<<'EOF' total 3 drwxr-xr-x 7 vito vito 4096 Feb 2 19:42 . drwxr-xr-x 3 root root 4096 Feb 1 18:44 .. drwxr-xr-x 2 vito vito 4096 Feb 2 14:13 test EOF ); $this->actingAs($this->user); Livewire::test(FilesList::class, [ 'server' => $this->server, ]) ->callTableAction('new-directory', null, [ 'name' => 'test', ]) ->assertSuccessful(); $this->assertDatabaseHas('files', [ 'name' => 'test', ]); } public function test_download_file(): void { SSH::fake(<<<'EOF' total 3 drwxr-xr-x 7 vito vito 4096 Feb 2 19:42 . drwxr-xr-x 3 root root 4096 Feb 1 18:44 .. -rw-rw-r-- 1 vito vito 82 Feb 2 14:13 test.txt EOF ); $this->actingAs($this->user); $this->get( Index::getUrl([ 'server' => $this->server, ]) )->assertSuccessful(); $file = File::query()->where('name', 'test.txt')->firstOrFail(); Livewire::test(FilesList::class, [ 'server' => $this->server, ]) ->assertTableActionVisible('download', $file) ->callTableAction('download', $file) ->assertSuccessful(); } }