Add ticket pull request visibility
This commit is contained in:
@@ -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');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,14 +101,15 @@ class ProjectTicketControllerTest extends TestCase
|
||||
->where('linkedTickets.0.linked_ticket.ticket_key', 'CORE-2')
|
||||
->where('linkedTickets.0.ticket_link_type.label', 'Relates to')
|
||||
->where('repositoryBranches', [])
|
||||
->where('repositoryPullRequests', [])
|
||||
->where('canEditTicket', false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure ticket details expose matching branches and inaccessible repository links.
|
||||
* Ensure ticket details expose matching branches, pull requests, and inaccessible repository links.
|
||||
*/
|
||||
public function test_ticket_details_include_matching_branches_and_inaccessible_repository_links(): void
|
||||
public function test_ticket_details_include_matching_branches_pull_requests_and_inaccessible_repository_links(): void
|
||||
{
|
||||
Http::preventStrayRequests();
|
||||
Http::fake([
|
||||
@@ -118,6 +119,38 @@ class ProjectTicketControllerTest extends TestCase
|
||||
['name' => 'CORE-10-should-not-match'],
|
||||
['name' => 'main'],
|
||||
]),
|
||||
'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',
|
||||
],
|
||||
],
|
||||
[
|
||||
'number' => 43,
|
||||
'title' => 'Close auth gap',
|
||||
'state' => 'closed',
|
||||
'merged' => true,
|
||||
'html_url' => 'https://git.example.test/core-team/kanbangit/pulls/43',
|
||||
'head' => [
|
||||
'ref' => 'CORE-1/fix-oauth',
|
||||
],
|
||||
],
|
||||
[
|
||||
'number' => 99,
|
||||
'title' => 'Other ticket change',
|
||||
'state' => 'open',
|
||||
'merged' => false,
|
||||
'html_url' => 'https://git.example.test/core-team/kanbangit/pulls/99',
|
||||
'head' => [
|
||||
'ref' => 'CORE-10-should-not-match',
|
||||
],
|
||||
],
|
||||
]),
|
||||
]);
|
||||
|
||||
$viewer = User::factory()->create();
|
||||
@@ -175,7 +208,16 @@ class ProjectTicketControllerTest extends TestCase
|
||||
->where('repositoryBranches.0.branches.1.name', 'CORE-1/fix-oauth')
|
||||
->where('repositoryBranches.1.repository_connection.repository_full_name', 'other-team/mobile')
|
||||
->where('repositoryBranches.1.repository_connection.has_personal_access', false)
|
||||
->where('repositoryBranches.1.branches', []),
|
||||
->where('repositoryBranches.1.branches', [])
|
||||
->has('repositoryPullRequests.0.pull_requests', 2)
|
||||
->where('repositoryPullRequests.0.pull_requests.0.number', '42')
|
||||
->where('repositoryPullRequests.0.pull_requests.0.title', 'Add login form')
|
||||
->where('repositoryPullRequests.0.pull_requests.0.status', 'open')
|
||||
->where('repositoryPullRequests.0.pull_requests.1.number', '43')
|
||||
->where('repositoryPullRequests.0.pull_requests.1.status', 'merged')
|
||||
->where('repositoryPullRequests.1.repository_connection.repository_full_name', 'other-team/mobile')
|
||||
->where('repositoryPullRequests.1.repository_connection.has_personal_access', false)
|
||||
->where('repositoryPullRequests.1.pull_requests', []),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user