Skip to content

Commit

Permalink
Avoid crashing when livewire flag is set in tests (#2364)
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria authored Apr 9, 2024
1 parent 31a394b commit b23304b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
16 changes: 13 additions & 3 deletions tests/Feature/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
14 changes: 12 additions & 2 deletions tests/Feature/InstallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b23304b

Please sign in to comment.