Add ticket pull request visibility

This commit is contained in:
2026-03-26 09:19:56 +01:00
parent 0b95477f4e
commit 789675f83f
11 changed files with 495 additions and 3 deletions
+44
View File
@@ -4,6 +4,7 @@ namespace Tests\Feature\Git;
use App\Actions\Git\Data\GitAuthenticatedUser;
use App\Actions\Git\Data\GitBranch;
use App\Actions\Git\Data\GitPullRequest;
use App\Actions\Git\Data\GitRepository;
use App\Actions\Git\Gitea\GiteaProviderClient;
use Illuminate\Foundation\Testing\RefreshDatabase;
@@ -117,4 +118,47 @@ class GiteaProviderTest extends TestCase
) && $request->hasHeader('Authorization', 'token branch-token');
});
}
/**
* Ensure the provider lists pull requests for a specific repository.
*/
public function test_provider_can_list_repository_pull_requests(): void
{
Http::preventStrayRequests();
Http::fake([
'https://git.example.test/api/v1/repos/core-team/kanbangit/pulls*' => Http::response([
[
'number' => 42,
'title' => 'Add login form',
'state' => 'open',
'merged' => false,
'html_url' => 'https://git.example.test/core-team/kanbangit/pulls/42',
'head' => [
'ref' => 'CORE-1-login-form',
],
],
]),
]);
$pullRequests = app(GiteaProviderClient::class)->listPullRequests(
'https://git.example.test',
'pull-token',
'core-team',
'kanbangit',
);
$this->assertCount(1, $pullRequests);
$this->assertContainsOnlyInstancesOf(GitPullRequest::class, $pullRequests);
$this->assertSame('42', $pullRequests[0]->number);
$this->assertSame('Add login form', $pullRequests[0]->title);
$this->assertSame('open', $pullRequests[0]->status);
$this->assertSame('CORE-1-login-form', $pullRequests[0]->sourceBranch);
Http::assertSent(function ($request): bool {
return str_starts_with(
$request->url(),
'https://git.example.test/api/v1/repos/core-team/kanbangit/pulls',
) && $request->hasHeader('Authorization', 'token pull-token');
});
}
}