feat: support both ticket link directions (KAN-12)
This commit is contained in:
@@ -293,6 +293,49 @@ class TicketApiTest extends TestCase
|
||||
$this->assertDatabaseCount('ticket_worklog_entries', 0);
|
||||
}
|
||||
|
||||
public function test_counterpart_link_direction_is_reflected_on_both_tickets_in_the_api(): void
|
||||
{
|
||||
[$user, $project] = $this->projectContext();
|
||||
$status = $project->ticketStatuses()->firstOrFail();
|
||||
$blockingTicket = $this->ticket($project, $status);
|
||||
$blockedTicket = $this->ticket($project, $status, 2);
|
||||
$linkType = TicketLinkType::factory()->for($project)->create([
|
||||
'label' => 'Blocks',
|
||||
'counterpart_label' => 'Blocked by',
|
||||
]);
|
||||
|
||||
$this->withApplicationKey($user)
|
||||
->postJson(route('api.projects.tickets.links.store', [$project, $blockedTicket]), [
|
||||
'linked_ticket_id' => $blockingTicket->id,
|
||||
'ticket_link_type_id' => $linkType->id,
|
||||
'link_direction' => 'counterpart',
|
||||
])
|
||||
->assertCreated()
|
||||
->assertJsonPath('data.source_ticket_id', $blockingTicket->id)
|
||||
->assertJsonPath('data.target_ticket_id', $blockedTicket->id)
|
||||
->assertJsonPath('data.ticket_link_type.label', 'Blocked by')
|
||||
->assertJsonPath('meta.message', 'Blocked by link was saved.');
|
||||
|
||||
$this->withApplicationKey($user)
|
||||
->getJson(route('api.projects.tickets.show', [$project, $blockingTicket]))
|
||||
->assertOk()
|
||||
->assertJsonPath('data.linkedTickets.0.ticket_link_type.label', 'Blocks');
|
||||
|
||||
$this->withApplicationKey($user)
|
||||
->getJson(route('api.projects.tickets.show', [$project, $blockedTicket]))
|
||||
->assertOk()
|
||||
->assertJsonPath('data.linkedTickets.0.ticket_link_type.label', 'Blocked by');
|
||||
|
||||
$this->withApplicationKey($user)
|
||||
->postJson(route('api.projects.tickets.links.store', [$project, $blockedTicket]), [
|
||||
'linked_ticket_id' => $blockingTicket->id,
|
||||
'ticket_link_type_id' => $linkType->id,
|
||||
'link_direction' => 'invalid',
|
||||
])
|
||||
->assertUnprocessable()
|
||||
->assertJsonValidationErrors('link_direction');
|
||||
}
|
||||
|
||||
public function test_ticket_links_and_branch_endpoints_are_available(): void
|
||||
{
|
||||
Http::preventStrayRequests();
|
||||
|
||||
Reference in New Issue
Block a user