Implement ticket links and blocker state

This commit is contained in:
2026-03-25 09:12:17 +01:00
parent 3b31e6bb7d
commit 70b90f32d4
34 changed files with 1722 additions and 10 deletions
+70
View File
@@ -7,6 +7,8 @@ use App\Models\Project;
use App\Models\Ticket;
use App\Models\TicketFieldDefinition;
use App\Models\TicketFieldValue;
use App\Models\TicketLink;
use App\Models\TicketLinkType;
use App\Models\TicketPriority;
use App\Models\TicketWorklogEntry;
use Database\Seeders\BoardColumnSeeder;
@@ -165,4 +167,72 @@ class TicketTest extends TestCase
$this->assertSame($parentTicket->id, $childTicket->fresh()->parentTicket?->id);
$this->assertSame([$childTicket->id], $parentTicket->fresh()->childTickets->modelKeys());
}
/**
* Ensure the blocked flag is cast to a boolean for board and detail rendering.
*/
public function test_ticket_blocked_state_is_cast_to_boolean(): void
{
$ticket = Ticket::factory()->create([
'blocked_comment' => 'Waiting for environment access.',
'is_blocked' => 1,
]);
$freshTicket = $ticket->fresh();
$this->assertTrue($freshTicket->is_blocked);
$this->assertSame('Waiting for environment access.', $freshTicket->blocked_comment);
}
/**
* Ensure tickets expose incoming and outgoing link relations.
*/
public function test_ticket_link_relations_are_available(): void
{
$project = Project::factory()->create([
'key' => 'CORE',
]);
app(InitializeProjectTicketMetadata::class)->handle($project);
$priority = TicketPriority::factory()->for($project)->create([
'name' => 'Medium',
'position' => 1,
]);
$taskType = $project->ticketTypes()->where('system_key', 'task')->firstOrFail();
$sourceTicket = Ticket::factory()->create([
'project_id' => $project->id,
'sequence_number' => 1,
'ticket_key' => 'CORE-1',
'ticket_priority_id' => $priority->id,
'ticket_type_id' => $taskType->id,
]);
$targetTicket = Ticket::factory()->create([
'project_id' => $project->id,
'sequence_number' => 2,
'ticket_key' => 'CORE-2',
'ticket_priority_id' => $priority->id,
'ticket_type_id' => $taskType->id,
]);
$ticketLinkType = TicketLinkType::factory()->for($project)->create([
'label' => 'Relates to',
'position' => 1,
]);
$ticketLink = TicketLink::factory()->create([
'source_ticket_id' => $sourceTicket->id,
'target_ticket_id' => $targetTicket->id,
'ticket_link_type_id' => $ticketLinkType->id,
]);
$this->assertSame(
[$ticketLink->id],
$sourceTicket->fresh()->ticketLinksAsSource->modelKeys(),
);
$this->assertSame(
[$ticketLink->id],
$targetTicket->fresh()->ticketLinksAsTarget->modelKeys(),
);
}
}