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.

test(var): fix env variable tests

peaklabs-devdd0bae638d38
diff --git a/tests/Feature/Authorization/EnvironmentVariableValueHidingTest.php b/tests/Feature/Authorization/EnvironmentVariableValueHidingTest.php
index c415ff3242..ec78d0f30d 100644
--- a/tests/Feature/Authorization/EnvironmentVariableValueHidingTest.php
+++ b/tests/Feature/Authorization/EnvironmentVariableValueHidingTest.php
@@ -18,7 +18,7 @@ use Livewire\Livewire;
uses(RefreshDatabase::class);
beforeEach(function () {
- InstanceSettings::updateOrCreate(['id' => 0], ['is_api_enabled' => true]);
+ InstanceSettings::forceCreate(['id' => 0, 'is_api_enabled' => true]);
$this->team = Team::factory()->create();
@@ -103,6 +103,11 @@ test('admin sees unlocked env value in Show component', function () {
'type' => 'application',
]);
+ // Values hydrate lazily; the edit modal triggers loadValues() on open.
+ expect($component->get('value'))->toBeNull();
+
+ $component->call('loadValues');
+
expect($component->get('value'))->toBe('secret-unlocked-value');
});
@@ -246,6 +251,17 @@ test('API hides env values for member even with read:sensitive token', function
'Authorization' => 'Bearer '.$token->plainTextToken,
])->getJson("/api/v1/applications/{$this->application->uuid}/envs");
+ $response->assertForbidden();
+});
+
+test('API hides env values for member with read token', function () {
+ session(['currentTeam' => $this->team]);
+ $token = $this->member->createToken('member-read', ['read']);
+
+ $response = $this->withHeaders([
+ 'Authorization' => 'Bearer '.$token->plainTextToken,
+ ])->getJson("/api/v1/applications/{$this->application->uuid}/envs");
+
$response->assertOk();
$envs = collect($response->json());
diff --git a/tests/Feature/EnvironmentVariableAsyncLoadTest.php b/tests/Feature/EnvironmentVariableAsyncLoadTest.php
index 2cbc5537a1..56abc94f77 100644
--- a/tests/Feature/EnvironmentVariableAsyncLoadTest.php
+++ b/tests/Feature/EnvironmentVariableAsyncLoadTest.php
@@ -71,7 +71,7 @@ it('loads environment variables when loadEnvironmentVariables is called', functi
->assertSee('Loading environment variables...')
->call('loadEnvironmentVariables')
->assertSet('readyToLoad', true)
- ->assertDontSee('Loading environment variables...')
+ ->assertDontSeeText('Loading environment variables...')
->assertSee('API_KEY');
expect($component->instance()->environmentVariables->pluck('key')->all())