Fix false child acceptance criteria sync
This commit is contained in:
@@ -708,7 +708,7 @@ class ProjectTicketControllerTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_ticket_update_syncs_child_acceptance_criteria_when_parent_is_toggled(): void
|
||||
public function test_ticket_update_persists_explicit_child_acceptance_criteria_toggle_states(): void
|
||||
{
|
||||
$editor = User::factory()->create();
|
||||
$project = Project::factory()->create([
|
||||
@@ -769,13 +769,13 @@ class ProjectTicketControllerTest extends TestCase
|
||||
[
|
||||
'id' => $childCriterion->id,
|
||||
'text' => 'Child item',
|
||||
'checked' => false,
|
||||
'checked' => true,
|
||||
'indent' => 1,
|
||||
],
|
||||
[
|
||||
'id' => $grandchildCriterion->id,
|
||||
'text' => 'Grandchild item',
|
||||
'checked' => false,
|
||||
'checked' => true,
|
||||
'indent' => 2,
|
||||
],
|
||||
],
|
||||
@@ -812,13 +812,13 @@ class ProjectTicketControllerTest extends TestCase
|
||||
[
|
||||
'id' => $childCriterion->id,
|
||||
'text' => 'Child item',
|
||||
'checked' => true,
|
||||
'checked' => false,
|
||||
'indent' => 1,
|
||||
],
|
||||
[
|
||||
'id' => $grandchildCriterion->id,
|
||||
'text' => 'Grandchild item',
|
||||
'checked' => true,
|
||||
'checked' => false,
|
||||
'indent' => 2,
|
||||
],
|
||||
],
|
||||
@@ -843,6 +843,130 @@ class ProjectTicketControllerTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_ticket_update_does_not_sync_later_indented_items_outside_the_toggled_subtree(): 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 false child test',
|
||||
]);
|
||||
$loginCriterion = AcceptanceCriterion::query()->create([
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_acceptance_criterion_id' => null,
|
||||
'position' => 0,
|
||||
'text' => 'Login',
|
||||
'is_checked' => false,
|
||||
]);
|
||||
$stayLoggedInCriterion = AcceptanceCriterion::query()->create([
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_acceptance_criterion_id' => $loginCriterion->id,
|
||||
'position' => 0,
|
||||
'text' => 'stay logged in button',
|
||||
'is_checked' => false,
|
||||
]);
|
||||
$registerCriterion = AcceptanceCriterion::query()->create([
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_acceptance_criterion_id' => null,
|
||||
'position' => 1,
|
||||
'text' => 'Register',
|
||||
'is_checked' => true,
|
||||
]);
|
||||
$passwordResetCriterion = AcceptanceCriterion::query()->create([
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_acceptance_criterion_id' => null,
|
||||
'position' => 2,
|
||||
'text' => 'Password reset',
|
||||
'is_checked' => true,
|
||||
]);
|
||||
$rateLimitCriterion = AcceptanceCriterion::query()->create([
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_acceptance_criterion_id' => $passwordResetCriterion->id,
|
||||
'position' => 0,
|
||||
'text' => 'max 1x pro 10 min',
|
||||
'is_checked' => false,
|
||||
]);
|
||||
|
||||
$this->syncProjectPermissions($project, $editor, ['write', 'view']);
|
||||
|
||||
$this->actingAs($editor)
|
||||
->withHeaders([
|
||||
'Accept' => 'application/json',
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])
|
||||
->patch(route('projects.tickets.update', [$project, $ticket]), $this->updatePayload($ticket, [
|
||||
'acceptance_criteria' => [
|
||||
[
|
||||
'id' => $loginCriterion->id,
|
||||
'text' => 'Login',
|
||||
'checked' => true,
|
||||
'indent' => 0,
|
||||
],
|
||||
[
|
||||
'id' => $stayLoggedInCriterion->id,
|
||||
'text' => 'stay logged in button',
|
||||
'checked' => true,
|
||||
'indent' => 1,
|
||||
],
|
||||
[
|
||||
'id' => $registerCriterion->id,
|
||||
'text' => 'Register',
|
||||
'checked' => true,
|
||||
'indent' => 0,
|
||||
],
|
||||
[
|
||||
'id' => $passwordResetCriterion->id,
|
||||
'text' => 'Password reset',
|
||||
'checked' => true,
|
||||
'indent' => 0,
|
||||
],
|
||||
[
|
||||
'id' => $rateLimitCriterion->id,
|
||||
'text' => 'max 1x pro 10 min',
|
||||
'checked' => false,
|
||||
'indent' => 1,
|
||||
],
|
||||
],
|
||||
]))
|
||||
->assertOk()
|
||||
->assertJson([
|
||||
'message' => 'CORE-1 was updated.',
|
||||
'updated' => true,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('acceptance_criteria', [
|
||||
'id' => $loginCriterion->id,
|
||||
'is_checked' => true,
|
||||
]);
|
||||
$this->assertDatabaseHas('acceptance_criteria', [
|
||||
'id' => $stayLoggedInCriterion->id,
|
||||
'is_checked' => true,
|
||||
]);
|
||||
$this->assertDatabaseHas('acceptance_criteria', [
|
||||
'id' => $registerCriterion->id,
|
||||
'is_checked' => true,
|
||||
]);
|
||||
$this->assertDatabaseHas('acceptance_criteria', [
|
||||
'id' => $passwordResetCriterion->id,
|
||||
'is_checked' => true,
|
||||
]);
|
||||
$this->assertDatabaseHas('acceptance_criteria', [
|
||||
'id' => $rateLimitCriterion->id,
|
||||
'is_checked' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure non-parent tickets cannot be assigned as a parent target.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user