Update checklist sync without hard resets
This commit is contained in:
@@ -579,6 +579,88 @@ class ProjectTicketControllerTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_ticket_update_reuses_acceptance_criteria_ids_when_provided(): void
|
||||
{
|
||||
$editor = User::factory()->create();
|
||||
$project = Project::factory()->create([
|
||||
'key' => 'CORE',
|
||||
]);
|
||||
|
||||
app(InitializeProjectTicketMetadata::class)->handle($project);
|
||||
|
||||
$priority = $project->ticketPriorities()->firstOrFail();
|
||||
$ticketType = $this->nonParentType($project);
|
||||
$ticket = Ticket::factory()->create([
|
||||
'project_id' => $project->id,
|
||||
'sequence_number' => 1,
|
||||
'ticket_key' => 'CORE-1',
|
||||
'ticket_priority_id' => $priority->id,
|
||||
'ticket_type_id' => $ticketType->id,
|
||||
'title' => 'Acceptance criteria update test',
|
||||
]);
|
||||
$rootCriterion = AcceptanceCriterion::query()->create([
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_acceptance_criterion_id' => null,
|
||||
'position' => 0,
|
||||
'text' => 'Original root item',
|
||||
'is_checked' => false,
|
||||
]);
|
||||
$childCriterion = AcceptanceCriterion::query()->create([
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_acceptance_criterion_id' => $rootCriterion->id,
|
||||
'position' => 0,
|
||||
'text' => 'Original child item',
|
||||
'is_checked' => false,
|
||||
]);
|
||||
|
||||
$this->syncProjectPermissions($project, $editor, ['write', 'view']);
|
||||
|
||||
$this->actingAs($editor)
|
||||
->patch(route('projects.tickets.update', [$project, $ticket]), [
|
||||
'acceptance_criteria' => [
|
||||
[
|
||||
'id' => $rootCriterion->id,
|
||||
'text' => 'Updated root item',
|
||||
'checked' => true,
|
||||
'indent' => 0,
|
||||
],
|
||||
[
|
||||
'id' => $childCriterion->id,
|
||||
'text' => 'Updated child item',
|
||||
'checked' => false,
|
||||
'indent' => 1,
|
||||
],
|
||||
],
|
||||
'blocked_comment' => $ticket->blocked_comment,
|
||||
'description' => $ticket->description,
|
||||
'field_values' => [],
|
||||
'is_blocked' => $ticket->is_blocked,
|
||||
'parent_ticket_id' => $ticket->parent_ticket_id,
|
||||
'story_points' => $ticket->story_points,
|
||||
'ticket_priority_id' => $priority->id,
|
||||
'ticket_type_id' => $ticketType->id,
|
||||
'title' => $ticket->title,
|
||||
])
|
||||
->assertRedirect(route('projects.tickets.show', [$project, $ticket]));
|
||||
|
||||
$this->assertDatabaseHas('acceptance_criteria', [
|
||||
'id' => $rootCriterion->id,
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_acceptance_criterion_id' => null,
|
||||
'position' => 0,
|
||||
'text' => 'Updated root item',
|
||||
'is_checked' => true,
|
||||
]);
|
||||
$this->assertDatabaseHas('acceptance_criteria', [
|
||||
'id' => $childCriterion->id,
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_acceptance_criterion_id' => $rootCriterion->id,
|
||||
'position' => 0,
|
||||
'text' => 'Updated child item',
|
||||
'is_checked' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure non-parent tickets cannot be assigned as a parent target.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user