whereKey(0)->exists()) { $settings = new InstanceSettings; $settings->id = 0; $settings->save(); } Once::flush(); $this->team = Team::factory()->create(); $this->user = User::factory()->create(); $this->team->members()->attach($this->user->id, ['role' => 'owner']); session(['currentTeam' => $this->team]); $this->actingAs($this->user); Log::spy(); }); test('adding a digitalocean token from a modal closes the modal and refreshes digitalocean token selectors', function () { Http::fake([ 'https://api.digitalocean.com/v2/account' => Http::response([], 200), ]); $component = Livewire::test(CloudProviderTokenForm::class, [ 'modal_mode' => true, 'provider' => 'digitalocean', ]) ->set('name', 'Production DigitalOcean') ->set('token', 'digitalocean-token') ->call('addToken') ->assertDispatched('close-modal'); $dispatches = collect(data_get($component->effects, 'dispatches', [])); expect($dispatches->contains(fn (array $dispatch) => $dispatch['name'] === 'tokenAdded.digitalocean' && data_get($dispatch, 'to') === 'server.new.by-digital-ocean'))->toBeTrue() ->and($dispatches->contains(fn (array $dispatch) => $dispatch['name'] === 'tokenAdded' && data_get($dispatch, 'to') === 'security.cloud-provider-tokens'))->toBeTrue(); }); test('security cloud token form lets users choose every supported provider', function () { Livewire::test(CloudProviderTokenForm::class) ->assertSee('Provider') ->assertSee('Hetzner') ->assertSee('DigitalOcean') ->assertSee('Vultr'); }); test('cloud provider help link reacts to provider selection without a live request', function () { $view = file_get_contents(resource_path('views/livewire/security/cloud-provider-token-form.blade.php')); expect($view) ->toContain("selectedProvider: \$wire.entangle('provider')") ->toContain(':wire="false"') ->toContain('x-model="selectedProvider"') ->toContain(':href="providerConsoleUrl"') ->toContain('x-text="providerName + \' console\'"') ->not->toContain('wire:model.live="provider"'); expect(strpos($view, ':href="providerConsoleUrl"')) ->toBeLessThan(strpos($view, '