actingAs(User::factory()->create(['must_change_password' => false])); } public function test_reports_update_available_from_the_remote_tag_api(): void { config()->set('clusev.version', '0.9.4'); Http::fake([self::TAGS_URL => Http::response([ ['name' => 'v0.9.6'], ['name' => 'v0.9.5'], ['name' => 'v0.9.4'], ])]); Livewire::test(Index::class) ->call('checkUpdates') ->assertSet('updateState', 'update') ->assertSee('0.9.6'); } public function test_reports_current_when_installed_is_at_or_above_the_latest_tag(): void { config()->set('clusev.version', '0.9.9'); Http::fake([self::TAGS_URL => Http::response([['name' => 'v0.9.6']])]); Livewire::test(Index::class) ->call('checkUpdates') ->assertSet('updateState', 'current'); } public function test_stable_channel_ignores_prereleases_but_beta_sees_them(): void { config()->set('clusev.version', '0.9.6'); Http::fake([self::TAGS_URL => Http::response([ ['name' => 'v1.0.0-beta1'], ['name' => 'v0.9.6'], ])]); // stable: 1.0.0-beta1 is not offered, 0.9.6 == installed → current Setting::put('release_channel', 'stable'); Livewire::test(Index::class)->call('checkUpdates')->assertSet('updateState', 'current'); // beta: the prerelease is newer → update available Cache::flush(); Setting::put('release_channel', 'beta'); Livewire::test(Index::class) ->call('checkUpdates') ->assertSet('updateState', 'update') ->assertSee('1.0.0-beta1'); } public function test_degrades_gracefully_when_the_remote_api_is_unreachable(): void { // Installed version above any real local .git tag, so the local fallback can't claim an // update — this asserts a failed remote lookup never crashes the action. config()->set('clusev.version', '99.0.0'); Http::fake([self::TAGS_URL => Http::response('upstream down', 500)]); Livewire::test(Index::class) ->call('checkUpdates') ->assertSet('updateState', 'current') ->assertSet('lastChecked', now()->format('H:i')); } }