Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix(new-resource): render the resource search binding only on the type step

Andras Bacsaie1637cbe0257
diff --git a/resources/views/livewire/project/new/select.blade.php b/resources/views/livewire/project/new/select.blade.php
index c1b255f72a..5288bf6eaf 100644
--- a/resources/views/livewire/project/new/select.blade.php
+++ b/resources/views/livewire/project/new/select.blade.php
@@ -1,6 +1,6 @@
<div class="application-settings-form" x-data x-init="$wire.loadServers">
- <div x-data="searchResources()">
- @if ($current_step === 'type')
+ @if ($current_step === 'type')
+ <div x-data="searchResources()">
<x-application.settings-section title="Choose a resource" flush>
<x-slot:actions>
<button type="button" class="button" :disabled="loading" @click="loadResources">
@@ -634,8 +634,8 @@
}
}
</script>
- @endif
- </div>
+ </div>
+ @endif
@if ($current_step === 'servers')
<x-application.settings-section title="Select a server"
description="Choose the machine that will host this resource." flush>
diff --git a/tests/Feature/NewResourceSelectServerScopeTest.php b/tests/Feature/NewResourceSelectServerScopeTest.php
index c534877e28..a55321e0de 100644
--- a/tests/Feature/NewResourceSelectServerScopeTest.php
+++ b/tests/Feature/NewResourceSelectServerScopeTest.php
@@ -131,3 +131,20 @@ test('the postgresql shortcut ignores a server that is not in the server list',
->assertSet('server', null)
->assertSet('current_step', 'type');
});
+
+test('the postgresql image step does not reference the resource search script it does not render', function () {
+ Livewire::withQueryParams([
+ 'type' => 'postgresql',
+ 'server_id' => $this->server->id,
+ 'destination' => $this->defaultDestination->uuid,
+ ])->test(Select::class)
+ ->assertSet('current_step', 'select-postgresql-type')
+ ->assertDontSeeHtml('searchResources');
+});
+
+test('the resource type step renders the resource search script with its binding', function () {
+ Livewire::test(Select::class)
+ ->assertSet('current_step', 'type')
+ ->assertSeeHtml('x-data="searchResources()"')
+ ->assertSeeHtml('function searchResources()');
+});