Files
keystone/tests/Feature/SourceProviderControllerTest.php

44 lines
1.5 KiB
PHP

<?php
use App\Enums\SourceProviderType;
use App\Models\Organisation;
use App\Models\User;
use Inertia\Testing\AssertableInertia;
it('shows the create source provider page', function () {
$user = User::factory()->create();
$organisation = Organisation::factory()->create(['owner_id' => $user->id]);
$response = $this->actingAs($user)->get(route('source-providers.create', [
'organisation' => $organisation->id,
]));
$response->assertOk();
$response->assertInertia(fn (AssertableInertia $page) => $page
->component('source-providers/Create', false)
->where('sourceProviderTypes.0', SourceProviderType::GITEA->value));
});
it('stores a source provider for repository onboarding', function () {
$user = User::factory()->create();
$organisation = Organisation::factory()->create(['owner_id' => $user->id]);
$response = $this->actingAs($user)->post(route('source-providers.store', [
'organisation' => $organisation->id,
]), [
'name' => 'Gitea',
'type' => SourceProviderType::GITEA->value,
'url' => 'https://gitea.example.com/',
]);
$response->assertRedirect(route('organisations.show', [
'organisation' => $organisation->id,
]));
$sourceProvider = $organisation->sourceProviders()->firstOrFail();
expect($sourceProvider->name)->toBe('Gitea')
->and($sourceProvider->type)->toBe(SourceProviderType::GITEA)
->and($sourceProvider->url)->toBe('https://gitea.example.com');
});