diff --git a/app/Setting/SettingServiceProvider.php b/app/Setting/SettingServiceProvider.php index cec22ee5..fc071b4d 100644 --- a/app/Setting/SettingServiceProvider.php +++ b/app/Setting/SettingServiceProvider.php @@ -2,8 +2,6 @@ namespace App\Setting; -use App\Fileshare\FileshareSettings; -use App\Form\FormSettings; use Modules\Module\ModuleSettings; use App\Prevention\PreventionSettings; use App\Setting\Data\SettingSynthesizer; @@ -35,7 +33,6 @@ class SettingServiceProvider extends ServiceProvider app(SettingFactory::class)->register(ModuleSettings::class); app(SettingFactory::class)->register(InvoiceSettings::class); app(SettingFactory::class)->register(NamiSettings::class); - app(SettingFactory::class)->register(FileshareSettings::class); app(SettingFactory::class)->register(PreventionSettings::class); Livewire::propertySynthesizer(SettingSynthesizer::class); diff --git a/config/app.php b/config/app.php index 12fa5c15..0fb18e81 100644 --- a/config/app.php +++ b/config/app.php @@ -185,6 +185,7 @@ return [ Modules\Nami\NamiServiceProvider::class, Modules\Auth\AuthServiceProvider::class, Modules\Form\FormServiceProvider::class, + Modules\Fileshare\FileshareServiceProvider::class, ], /* diff --git a/modules/Fileshare/Components/SettingView.php b/modules/Fileshare/Components/SettingView.php new file mode 100644 index 00000000..2f6fb9bb --- /dev/null +++ b/modules/Fileshare/Components/SettingView.php @@ -0,0 +1,20 @@ + Fileshare::get(), + ]); + } +} diff --git a/modules/Fileshare/Components/SettingViewTest.php b/modules/Fileshare/Components/SettingViewTest.php new file mode 100644 index 00000000..ec671215 --- /dev/null +++ b/modules/Fileshare/Components/SettingViewTest.php @@ -0,0 +1,63 @@ +withoutExceptionHandling()->login()->loginNami(); + + test()->get('/setting/fileshare')->assertSeeLivewire(SettingView::class); +}); + +it('displays overview', function () { + $this->withoutExceptionHandling()->login()->loginNami()->withUser('badenpowell', 'secret'); + Fileshare::factory() + ->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')])) + ->name('lokaler Server') + ->create(); + + Livewire::test(SettingView::class) + ->assertSee('lokaler Server') + ->assertSee('Verbindung erfolgreich') + ->assertSee('Owncloud'); + // ->assertJsonPath('data.0.name', 'lokaler Server') + // ->assertJsonPath('data.0.type', OwncloudConnection::class) + // ->assertJsonPath('data.0.config.user', 'badenpowell') + // ->assertJsonPath('data.0.config.password', 'secret') + // ->assertJsonPath('data.0.config.base_url', env('TEST_OWNCLOUD_DOMAIN')) + // ->assertJsonPath('data.0.id', $connection->id) + // ->assertJsonPath('data.0.is_active', true) + // ->assertJsonPath('data.0.type_human', 'Owncloud') + // ->assertJsonPath('data.0.links.update', route('fileshare.update', ['fileshare' => $connection])) + // ->assertJsonPath('meta.default.name', '') + // ->assertJsonPath('meta.links.store', route('fileshare.store')) + // ->assertJsonPath('meta.types.0.id', NextcloudConnection::class) + // ->assertJsonPath('meta.types.0.name', 'Nextcloud') + // ->assertJsonPath('meta.types.0.defaults.base_url', '') + // ->assertJsonPath('meta.types.1.id', OwncloudConnection::class) + // ->assertJsonPath('meta.types.1.name', 'Owncloud') + // ->assertJsonPath('meta.types.1.defaults.base_url', '') + // ->assertJsonPath('meta.types.0.fields.1', ['label' => 'Benutzer', 'key' => 'user', 'type' => 'text']); +}); + +it('displays wrong connection', function () { + $this->withoutExceptionHandling()->login()->loginNami()->withUser('badenpowell', 'secret'); + Fileshare::factory() + ->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'wrong', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')])) + ->name('lokaler Server') + ->create(); + + Livewire::test(SettingView::class) + ->assertSee('lokaler Server') + ->assertSee('Verbindung fehlgeschlagen'); +}); diff --git a/modules/Fileshare/Components/setting-view.blade.php b/modules/Fileshare/Components/setting-view.blade.php new file mode 100644 index 00000000..2591f60a --- /dev/null +++ b/modules/Fileshare/Components/setting-view.blade.php @@ -0,0 +1,36 @@ + + + Neue Verbindung + +
+ + + Bezeichnung + Typ + Prüfung + Aktion + + + @foreach ($data as $index => $share) + + {{ $share->name }} + {{ $share->type::title() }} + + + + + Bearbeiten + + + @endforeach + +
+
diff --git a/modules/Fileshare/FileshareServiceProvider.php b/modules/Fileshare/FileshareServiceProvider.php new file mode 100644 index 00000000..ff23dc00 --- /dev/null +++ b/modules/Fileshare/FileshareServiceProvider.php @@ -0,0 +1,38 @@ +register(FileshareSettings::class); + + app(Router::class)->middleware(['web', 'auth:web'])->group(function ($router) { + $router->get('/setting/fileshare', SettingView::class)->name('setting.fileshare'); + }); + + View::addNamespace('fileshare', __DIR__ . '/Components'); + } +} diff --git a/tests/Fileshare/FileshareIndexActionTest.php b/tests/Fileshare/FileshareIndexActionTest.php deleted file mode 100644 index a398d74a..00000000 --- a/tests/Fileshare/FileshareIndexActionTest.php +++ /dev/null @@ -1,47 +0,0 @@ -withoutExceptionHandling()->login()->loginNami()->withUser('badenpowell', 'secret'); - $connection = Fileshare::factory() - ->type(OwncloudConnection::from(['user' => 'badenpowell', 'password' => 'secret', 'base_url' => env('TEST_OWNCLOUD_DOMAIN')])) - ->name('lokaler Server') - ->create(); - - $this->get('/api/fileshare') - ->assertJsonPath('data.0.name', 'lokaler Server') - ->assertJsonPath('data.0.type', OwncloudConnection::class) - ->assertJsonPath('data.0.config.user', 'badenpowell') - ->assertJsonPath('data.0.config.password', 'secret') - ->assertJsonPath('data.0.config.base_url', env('TEST_OWNCLOUD_DOMAIN')) - ->assertJsonPath('data.0.id', $connection->id) - ->assertJsonPath('data.0.is_active', true) - ->assertJsonPath('data.0.type_human', 'Owncloud') - ->assertJsonPath('data.0.links.update', route('fileshare.update', ['fileshare' => $connection])) - ->assertJsonPath('meta.default.name', '') - ->assertJsonPath('meta.links.store', route('fileshare.store')) - ->assertJsonPath('meta.types.0.id', NextcloudConnection::class) - ->assertJsonPath('meta.types.0.name', 'Nextcloud') - ->assertJsonPath('meta.types.0.defaults.base_url', '') - ->assertJsonPath('meta.types.1.id', OwncloudConnection::class) - ->assertJsonPath('meta.types.1.name', 'Owncloud') - ->assertJsonPath('meta.types.1.defaults.base_url', '') - ->assertJsonPath('meta.types.0.fields.1', ['label' => 'Benutzer', 'key' => 'user', 'type' => 'text']); - } - - public function testItRendersComponent(): void - { - $this->withoutExceptionHandling()->login()->loginNami(); - - $this->get('/setting/fileshare')->assertComponent('setting/Fileshare'); - } -} diff --git a/tests/FileshareTestCase.php b/tests/FileshareTestCase.php index aaeac0a8..2984e294 100644 --- a/tests/FileshareTestCase.php +++ b/tests/FileshareTestCase.php @@ -25,7 +25,7 @@ abstract class FileshareTestCase extends TestCase */ protected array $passwords = []; - public function setUp(): void + protected function setUp(): void { parent::setUp();