55 lines
2.0 KiB
PHP
55 lines
2.0 KiB
PHP
<?php
|
|
|
|
use App\Enums\EnvironmentVariableSource;
|
|
use App\Models\Application;
|
|
use App\Models\Environment;
|
|
use App\Models\Organisation;
|
|
use App\Models\User;
|
|
use Inertia\Testing\AssertableInertia;
|
|
|
|
it('shows the user environment variable create page', function () {
|
|
$user = User::factory()->create();
|
|
$organisation = Organisation::factory()->create(['owner_id' => $user->id]);
|
|
$application = Application::factory()->for($organisation)->create();
|
|
$environment = Environment::factory()->for($application)->create();
|
|
|
|
$response = $this->actingAs($user)->get(route('environment-variables.create', [
|
|
'organisation' => $organisation->id,
|
|
'application' => $application->id,
|
|
'environment' => $environment->id,
|
|
]));
|
|
|
|
$response->assertOk();
|
|
$response->assertInertia(fn (AssertableInertia $page) => $page
|
|
->component('environment-variables/Create', false));
|
|
});
|
|
|
|
it('stores editable user-defined environment variables', function () {
|
|
$user = User::factory()->create();
|
|
$organisation = Organisation::factory()->create(['owner_id' => $user->id]);
|
|
$application = Application::factory()->for($organisation)->create();
|
|
$environment = Environment::factory()->for($application)->create();
|
|
|
|
$response = $this->actingAs($user)->post(route('environment-variables.store', [
|
|
'organisation' => $organisation->id,
|
|
'application' => $application->id,
|
|
'environment' => $environment->id,
|
|
]), [
|
|
'key' => 'APP_DEBUG',
|
|
'value' => 'false',
|
|
]);
|
|
|
|
$response->assertRedirect(route('applications.show', [
|
|
'organisation' => $organisation->id,
|
|
'application' => $application->id,
|
|
]));
|
|
|
|
$variable = $environment->variables()->firstOrFail();
|
|
|
|
expect($variable->key)->toBe('APP_DEBUG')
|
|
->and($variable->value)->toBe('false')
|
|
->and($variable->source)->toBe(EnvironmentVariableSource::USER)
|
|
->and($variable->overridable)->toBeTrue()
|
|
->and($variable->service_slice_id)->toBeNull();
|
|
});
|