From b23304ba46cb20b97a13cff654e935ed139ef969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Viguier?= Date: Wed, 10 Apr 2024 00:13:50 +0200 Subject: [PATCH] Avoid crashing when livewire flag is set in tests (#2364) --- tests/Feature/IndexTest.php | 16 +++++++++++++--- tests/Feature/InstallTest.php | 14 ++++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/tests/Feature/IndexTest.php b/tests/Feature/IndexTest.php index bb743b98e4d..7452f5c0bb8 100644 --- a/tests/Feature/IndexTest.php +++ b/tests/Feature/IndexTest.php @@ -30,7 +30,12 @@ public function testHome(): void * check if we can actually get a nice answer. */ $response = $this->get('/'); - $this->assertOk($response); + if (config('app.livewire') === true) { + $this->assertRedirect($response); + $response->assertRedirect(route('livewire-gallery')); + } else { + $this->assertOk($response); + } $response = $this->postJson('/api/Albums::get'); $this->assertOk($response); @@ -56,8 +61,13 @@ public function testLandingPage(): void Configs::set('landing_page_enable', 1); $response = $this->get('/'); - $this->assertOk($response); - $response->assertViewIs('landing'); + if (config('app.livewire') === true) { + $this->assertRedirect($response); + $response->assertRedirect(route('landing')); + } else { + $this->assertOk($response); + $response->assertViewIs('landing'); + } $response = $this->get('/gallery'); $this->assertOk($response); diff --git a/tests/Feature/InstallTest.php b/tests/Feature/InstallTest.php index cd0cc800982..5258aefd5ea 100644 --- a/tests/Feature/InstallTest.php +++ b/tests/Feature/InstallTest.php @@ -41,7 +41,12 @@ public function testInstall(): void config(['app.key' => $prevAppKey]); $response = $this->get('/'); - $this->assertOk($response); + if (config('app.livewire') === true) { + $this->assertRedirect($response); + $response->assertRedirect(route('livewire-gallery')); + } else { + $this->assertOk($response); + } /* * Clearing things up. We could do an Artisan migrate:reset but this is more efficient. @@ -133,7 +138,12 @@ public function testInstall(): void */ Configs::invalidateCache(); $response = $this->get('/'); - $this->assertOk($response); + if (config('app.livewire') === true) { + $this->assertRedirect($response); + $response->assertRedirect(route('livewire-gallery')); + } else { + $this->assertOk($response); + } /* * make sure there's still an admin user with ID 1