Fix parent ticket assignment and display
This commit is contained in:
@@ -368,6 +368,16 @@ class ProjectTicketControllerTest extends TestCase
|
||||
|
||||
app(InitializeProjectTicketMetadata::class)->handle($project);
|
||||
|
||||
$priority = $project->ticketPriorities()->firstOrFail();
|
||||
$parentTicket = Ticket::factory()->create([
|
||||
'project_id' => $project->id,
|
||||
'sequence_number' => 1,
|
||||
'ticket_key' => 'CORE-1',
|
||||
'ticket_priority_id' => $priority->id,
|
||||
'ticket_type_id' => $this->parentType($project)->id,
|
||||
'title' => 'Parent ticket',
|
||||
]);
|
||||
|
||||
$boardColumn = BoardColumn::factory()->for($project)->create([
|
||||
'name' => 'Todo',
|
||||
'position' => 1,
|
||||
@@ -391,6 +401,7 @@ class ProjectTicketControllerTest extends TestCase
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('projects/TicketCreate')
|
||||
->where('defaultTicketStatusId', $boardStatus->id)
|
||||
->where('parentTicketOptions.0.ticket_key', $parentTicket->ticket_key)
|
||||
->where('project.id', $project->id)
|
||||
->where('source', 'board')
|
||||
->where('ticketStatusOptions.1.id', $boardStatus->id),
|
||||
@@ -451,6 +462,98 @@ class ProjectTicketControllerTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure tickets can be created with a parent ticket assignment.
|
||||
*/
|
||||
public function test_users_with_write_permission_can_create_tickets_with_a_parent_ticket(): void
|
||||
{
|
||||
$editor = User::factory()->create();
|
||||
$project = Project::factory()->create([
|
||||
'key' => 'CORE',
|
||||
]);
|
||||
|
||||
app(InitializeProjectTicketMetadata::class)->handle($project);
|
||||
|
||||
$priority = $project->ticketPriorities()->firstOrFail();
|
||||
$backlogStatus = $project->ticketStatuses()
|
||||
->whereNull('board_column_id')
|
||||
->firstOrFail();
|
||||
$parentTicket = Ticket::factory()->create([
|
||||
'project_id' => $project->id,
|
||||
'sequence_number' => 1,
|
||||
'ticket_key' => 'CORE-1',
|
||||
'ticket_priority_id' => $priority->id,
|
||||
'ticket_type_id' => $this->parentType($project)->id,
|
||||
'title' => 'Parent ticket',
|
||||
]);
|
||||
|
||||
$this->syncProjectPermissions($project, $editor, ['write', 'view']);
|
||||
|
||||
$this->actingAs($editor)
|
||||
->post(route('projects.tickets.store', $project), [
|
||||
'assignee_user_id' => null,
|
||||
'description' => 'Created with parent.',
|
||||
'parent_ticket_id' => $parentTicket->id,
|
||||
'ticket_priority_id' => $priority->id,
|
||||
'ticket_status_id' => $backlogStatus->id,
|
||||
'ticket_type_id' => $this->nonParentType($project)->id,
|
||||
'title' => 'Child ticket',
|
||||
])
|
||||
->assertRedirect(route('projects.tickets.show', [$project, 2]))
|
||||
->assertSessionHas('status', 'CORE-2 was created.');
|
||||
|
||||
$this->assertDatabaseHas('tickets', [
|
||||
'project_id' => $project->id,
|
||||
'ticket_key' => 'CORE-2',
|
||||
'parent_ticket_id' => $parentTicket->id,
|
||||
'title' => 'Child ticket',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure ticket detail payloads expose the linked parent ticket when assigned.
|
||||
*/
|
||||
public function test_ticket_detail_pages_include_the_linked_parent_ticket(): void
|
||||
{
|
||||
$viewer = User::factory()->create();
|
||||
$project = Project::factory()->create([
|
||||
'key' => 'CORE',
|
||||
]);
|
||||
|
||||
app(InitializeProjectTicketMetadata::class)->handle($project);
|
||||
|
||||
$priority = $project->ticketPriorities()->firstOrFail();
|
||||
$parentTicket = Ticket::factory()->create([
|
||||
'project_id' => $project->id,
|
||||
'sequence_number' => 1,
|
||||
'ticket_key' => 'CORE-1',
|
||||
'ticket_priority_id' => $priority->id,
|
||||
'ticket_type_id' => $this->parentType($project)->id,
|
||||
'title' => 'Parent ticket',
|
||||
]);
|
||||
$childTicket = Ticket::factory()->create([
|
||||
'parent_ticket_id' => $parentTicket->id,
|
||||
'project_id' => $project->id,
|
||||
'sequence_number' => 2,
|
||||
'ticket_key' => 'CORE-2',
|
||||
'ticket_priority_id' => $priority->id,
|
||||
'ticket_type_id' => $this->nonParentType($project)->id,
|
||||
'title' => 'Child ticket',
|
||||
]);
|
||||
|
||||
$this->syncProjectPermissions($project, $viewer, ['view']);
|
||||
|
||||
$this->actingAs($viewer)
|
||||
->get(route('projects.tickets.show', [$project, $childTicket]))
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('projects/Ticket')
|
||||
->where('ticket.parent_ticket.ticket_key', $parentTicket->ticket_key)
|
||||
->where('ticket.parent_ticket.title', $parentTicket->title)
|
||||
->where('childTicketTree', []),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure updating ticket details requires the project edit permission.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user