Merge origin/main into koda/recreate-68-assignee-changed-notification
This commit is contained in:
@@ -44,18 +44,15 @@ class TicketApiTest extends TestCase
|
||||
$createResponse = $this->withApplicationKey($user)
|
||||
->postJson(route('api.projects.tickets.store', $project), [
|
||||
'acceptance_criteria' => [
|
||||
'summary' => 'Can sign in',
|
||||
'items' => [
|
||||
[
|
||||
'checked' => false,
|
||||
'indent' => 0,
|
||||
'text' => 'Credentials are validated',
|
||||
],
|
||||
[
|
||||
'checked' => true,
|
||||
'indent' => 1,
|
||||
'text' => 'Nested validation is supported',
|
||||
],
|
||||
[
|
||||
'checked' => false,
|
||||
'indent' => 0,
|
||||
'text' => 'Credentials are validated',
|
||||
],
|
||||
[
|
||||
'checked' => true,
|
||||
'indent' => 1,
|
||||
'text' => 'Nested validation is supported',
|
||||
],
|
||||
],
|
||||
'description' => 'Build the API-created ticket',
|
||||
@@ -67,8 +64,7 @@ class TicketApiTest extends TestCase
|
||||
])
|
||||
->assertCreated()
|
||||
->assertJsonPath('data.ticket_key', 'CORE-1')
|
||||
->assertJsonPath('data.acceptance_criteria.summary', 'Can sign in')
|
||||
->assertJsonPath('data.acceptance_criteria.items.1.indent', 1)
|
||||
->assertJsonPath('data.acceptance_criteria.1.indent', 1)
|
||||
->assertJsonPath('meta.message', 'CORE-1 was created.');
|
||||
|
||||
$ticket = Ticket::query()->findOrFail($createResponse->json('data.id'));
|
||||
@@ -81,13 +77,10 @@ class TicketApiTest extends TestCase
|
||||
$this->withApplicationKey($user)
|
||||
->patchJson(route('api.projects.tickets.update', [$project, $ticket]), [
|
||||
'acceptance_criteria' => [
|
||||
'summary' => 'Can sign in from the API',
|
||||
'items' => [
|
||||
[
|
||||
'checked' => true,
|
||||
'indent' => 0,
|
||||
'text' => 'API update preserves checked state',
|
||||
],
|
||||
[
|
||||
'checked' => true,
|
||||
'indent' => 0,
|
||||
'text' => 'API update preserves checked state',
|
||||
],
|
||||
],
|
||||
'blocked_comment' => null,
|
||||
@@ -101,7 +94,7 @@ class TicketApiTest extends TestCase
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('data.title', 'Updated API ticket')
|
||||
->assertJsonPath('data.acceptance_criteria.items.0.checked', true)
|
||||
->assertJsonPath('data.acceptance_criteria.0.checked', true)
|
||||
->assertJsonPath('meta.message', 'CORE-1 was updated.');
|
||||
|
||||
$this->withApplicationKey($user)
|
||||
@@ -143,7 +136,7 @@ class TicketApiTest extends TestCase
|
||||
|
||||
$this->withApplicationKey($writer)
|
||||
->patchJson(route('api.projects.tickets.update', [$project, $ticket]), [
|
||||
'acceptance_criteria' => $ticket->acceptance_criteria,
|
||||
'acceptance_criteria' => [],
|
||||
'blocked_comment' => $ticket->blocked_comment,
|
||||
'description' => $ticket->description,
|
||||
'is_blocked' => $ticket->is_blocked,
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Tests\Feature\Notifications;
|
||||
|
||||
use App\Actions\Notifications\DeliverNotificationAction;
|
||||
use App\Actions\ProjectTicketMetadata\InitializeProjectTicketMetadata;
|
||||
use App\Actions\Tickets\Support\TicketAcceptanceCriteriaData;
|
||||
use App\Actions\Tickets\Support\AcceptanceCriteriaChecklistMapper;
|
||||
use App\Enums\NotificationDeliveryStatus;
|
||||
use App\Enums\NotificationEventType;
|
||||
use App\Models\NotificationAction;
|
||||
@@ -321,9 +321,8 @@ class TicketAssigneeChangedNotificationDispatchTest extends TestCase
|
||||
private function updatePayload(Ticket $ticket, array $overrides = []): array
|
||||
{
|
||||
return [
|
||||
'acceptance_criteria' => TicketAcceptanceCriteriaData::fromStored(
|
||||
$ticket->acceptance_criteria_data,
|
||||
$ticket->acceptance_criteria,
|
||||
'acceptance_criteria' => AcceptanceCriteriaChecklistMapper::fromModels(
|
||||
$ticket->acceptanceCriteria()->get(),
|
||||
),
|
||||
'assignee_user_id' => $ticket->assignee_user_id,
|
||||
'author_user_id' => $ticket->author_user_id,
|
||||
|
||||
@@ -110,7 +110,11 @@ class TicketCreatedNotificationDispatchTest extends TestCase
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->post(route('projects.tickets.store', $project), [
|
||||
'acceptance_criteria' => 'Ship it.',
|
||||
'acceptance_criteria' => [[
|
||||
'checked' => false,
|
||||
'indent' => 0,
|
||||
'text' => 'Ship it.',
|
||||
]],
|
||||
'assignee_user_id' => null,
|
||||
'description' => 'Created from notification dispatch test.',
|
||||
'story_points' => 3,
|
||||
|
||||
@@ -84,7 +84,11 @@ class ProjectBacklogTest extends TestCase
|
||||
->post(route('projects.tickets.store', $project), [
|
||||
'title' => 'New ticket',
|
||||
'description' => 'Description',
|
||||
'acceptance_criteria' => 'Criteria',
|
||||
'acceptance_criteria' => [[
|
||||
'checked' => false,
|
||||
'indent' => 0,
|
||||
'text' => 'Criteria',
|
||||
]],
|
||||
'ticket_type_id' => $project->ticketTypes()->firstOrFail()->id,
|
||||
'ticket_priority_id' => $priority->id,
|
||||
'ticket_status_id' => $backlogStatus->id,
|
||||
@@ -118,7 +122,11 @@ class ProjectBacklogTest extends TestCase
|
||||
$payload = [
|
||||
'title' => 'Same title',
|
||||
'description' => 'Description',
|
||||
'acceptance_criteria' => 'Criteria',
|
||||
'acceptance_criteria' => [[
|
||||
'checked' => false,
|
||||
'indent' => 0,
|
||||
'text' => 'Criteria',
|
||||
]],
|
||||
'assignee_user_id' => $assignee->id,
|
||||
'story_points' => 3,
|
||||
'ticket_type_id' => $project->ticketTypes()->firstOrFail()->id,
|
||||
@@ -192,7 +200,11 @@ class ProjectBacklogTest extends TestCase
|
||||
->post(route('projects.tickets.store', $project), [
|
||||
'title' => 'New ticket',
|
||||
'description' => 'Description',
|
||||
'acceptance_criteria' => 'Criteria',
|
||||
'acceptance_criteria' => [[
|
||||
'checked' => false,
|
||||
'indent' => 0,
|
||||
'text' => 'Criteria',
|
||||
]],
|
||||
'ticket_type_id' => $project->ticketTypes()->firstOrFail()->id,
|
||||
'ticket_priority_id' => $project->ticketPriorities()->firstOrFail()->id,
|
||||
'ticket_status_id' => $boardStatus->id,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Feature\Projects;
|
||||
|
||||
use App\Actions\ProjectTicketMetadata\InitializeProjectTicketMetadata;
|
||||
use App\Models\AcceptanceCriterion;
|
||||
use App\Models\BoardColumn;
|
||||
use App\Models\Project;
|
||||
use App\Models\RepositoryConnection;
|
||||
@@ -56,10 +57,7 @@ class ProjectTicketControllerTest extends TestCase
|
||||
'position' => 1,
|
||||
]);
|
||||
|
||||
$legacyAcceptanceCriteria = "Review checklist\n- [ ] User can sign in\n - [x] Nested verification";
|
||||
|
||||
$ticket = Ticket::factory()->create([
|
||||
'acceptance_criteria' => $legacyAcceptanceCriteria,
|
||||
'assignee_user_id' => $assignee->id,
|
||||
'author_user_id' => $author->id,
|
||||
'project_id' => $project->id,
|
||||
@@ -70,6 +68,20 @@ class ProjectTicketControllerTest extends TestCase
|
||||
'ticket_type_id' => $this->nonParentType($project)->id,
|
||||
'title' => 'Ticket detail test',
|
||||
]);
|
||||
$rootCriterion = AcceptanceCriterion::query()->create([
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_acceptance_criterion_id' => null,
|
||||
'position' => 0,
|
||||
'text' => 'User can sign in',
|
||||
'is_checked' => false,
|
||||
]);
|
||||
AcceptanceCriterion::query()->create([
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_acceptance_criterion_id' => $rootCriterion->id,
|
||||
'position' => 0,
|
||||
'text' => 'Nested verification',
|
||||
'is_checked' => true,
|
||||
]);
|
||||
$linkedTicket = Ticket::factory()->create([
|
||||
'author_user_id' => $author->id,
|
||||
'project_id' => $project->id,
|
||||
@@ -110,14 +122,12 @@ class ProjectTicketControllerTest extends TestCase
|
||||
->where('project.show_author', false)
|
||||
->where('ticket.ticket_key', 'CORE-1')
|
||||
->where('ticket.story_points', 5)
|
||||
->where('ticket.acceptance_criteria.summary', 'Review checklist')
|
||||
->where('ticket.acceptance_criteria.items.0.text', 'User can sign in')
|
||||
->where('ticket.acceptance_criteria.items.0.checked', false)
|
||||
->where('ticket.acceptance_criteria.items.0.indent', 0)
|
||||
->where('ticket.acceptance_criteria.items.1.text', 'Nested verification')
|
||||
->where('ticket.acceptance_criteria.items.1.checked', true)
|
||||
->where('ticket.acceptance_criteria.items.1.indent', 1)
|
||||
->where('ticket.acceptance_criteria_text', $legacyAcceptanceCriteria)
|
||||
->where('ticket.acceptance_criteria.0.text', 'User can sign in')
|
||||
->where('ticket.acceptance_criteria.0.checked', false)
|
||||
->where('ticket.acceptance_criteria.0.indent', 0)
|
||||
->where('ticket.acceptance_criteria.1.text', 'Nested verification')
|
||||
->where('ticket.acceptance_criteria.1.checked', true)
|
||||
->where('ticket.acceptance_criteria.1.indent', 1)
|
||||
->where('ticket.assignee.name', 'Assigned User')
|
||||
->where('ticket.author', null)
|
||||
->where('ticket.author_user_id', null)
|
||||
@@ -350,7 +360,11 @@ class ProjectTicketControllerTest extends TestCase
|
||||
|
||||
$this->actingAs($editor)
|
||||
->post(route('projects.tickets.store', $project), [
|
||||
'acceptance_criteria' => 'The ticket exists.',
|
||||
'acceptance_criteria' => [[
|
||||
'checked' => false,
|
||||
'indent' => 0,
|
||||
'text' => 'The ticket exists.',
|
||||
]],
|
||||
'assignee_user_id' => $assignee->id,
|
||||
'description' => 'Created from the dedicated page.',
|
||||
'story_points' => 5,
|
||||
@@ -448,7 +462,6 @@ class ProjectTicketControllerTest extends TestCase
|
||||
]);
|
||||
|
||||
$ticket = Ticket::factory()->create([
|
||||
'acceptance_criteria' => 'Old acceptance criteria',
|
||||
'author_user_id' => $author->id,
|
||||
'description' => 'Old description',
|
||||
'project_id' => $project->id,
|
||||
@@ -475,18 +488,15 @@ class ProjectTicketControllerTest extends TestCase
|
||||
$this->syncProjectPermissions($project, $editor, ['write', 'view']);
|
||||
|
||||
$updatedAcceptanceCriteria = [
|
||||
'summary' => 'Updated acceptance criteria',
|
||||
'items' => [
|
||||
[
|
||||
'text' => 'Shows success banner',
|
||||
'checked' => false,
|
||||
'indent' => 0,
|
||||
],
|
||||
[
|
||||
'text' => 'Includes nested confirmations',
|
||||
'checked' => true,
|
||||
'indent' => 1,
|
||||
],
|
||||
[
|
||||
'text' => 'Shows success banner',
|
||||
'checked' => false,
|
||||
'indent' => 0,
|
||||
],
|
||||
[
|
||||
'text' => 'Includes nested confirmations',
|
||||
'checked' => true,
|
||||
'indent' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
@@ -520,16 +530,37 @@ class ProjectTicketControllerTest extends TestCase
|
||||
'id' => $ticket->id,
|
||||
'title' => 'Updated title',
|
||||
'description' => 'Updated description',
|
||||
'acceptance_criteria' => "Updated acceptance criteria\n\n- [ ] Shows success banner\n - [x] Includes nested confirmations",
|
||||
'assignee_user_id' => $assignee->id,
|
||||
'story_points' => 8,
|
||||
'ticket_type_id' => $this->parentType($project)->id,
|
||||
'ticket_priority_id' => $highPriority->id,
|
||||
]);
|
||||
|
||||
$ticket->refresh();
|
||||
$ticket->refresh()->load('acceptanceCriteria');
|
||||
|
||||
$this->assertEquals($updatedAcceptanceCriteria, $ticket->acceptance_criteria_data);
|
||||
$this->assertEquals(
|
||||
$updatedAcceptanceCriteria,
|
||||
\App\Actions\Tickets\Support\AcceptanceCriteriaChecklistMapper::fromModels($ticket->acceptanceCriteria),
|
||||
);
|
||||
$this->assertDatabaseHas('acceptance_criteria', [
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_acceptance_criterion_id' => null,
|
||||
'position' => 0,
|
||||
'text' => 'Shows success banner',
|
||||
'is_checked' => false,
|
||||
]);
|
||||
$rootCriterionId = \App\Models\AcceptanceCriterion::query()
|
||||
->where('ticket_id', $ticket->id)
|
||||
->where('text', 'Shows success banner')
|
||||
->value('id');
|
||||
$this->assertNotNull($rootCriterionId);
|
||||
$this->assertDatabaseHas('acceptance_criteria', [
|
||||
'ticket_id' => $ticket->id,
|
||||
'parent_acceptance_criterion_id' => $rootCriterionId,
|
||||
'position' => 0,
|
||||
'text' => 'Includes nested confirmations',
|
||||
'is_checked' => true,
|
||||
]);
|
||||
$this->assertDatabaseHas('ticket_field_values', [
|
||||
'ticket_id' => $ticket->id,
|
||||
'ticket_field_definition_id' => $reviewerField->id,
|
||||
@@ -548,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.
|
||||
*/
|
||||
@@ -948,7 +1061,9 @@ class ProjectTicketControllerTest extends TestCase
|
||||
private function updatePayload(Ticket $ticket, array $overrides = []): array
|
||||
{
|
||||
return array_merge([
|
||||
'acceptance_criteria' => $ticket->acceptance_criteria,
|
||||
'acceptance_criteria' => \App\Actions\Tickets\Support\AcceptanceCriteriaChecklistMapper::fromModels(
|
||||
$ticket->acceptanceCriteria()->get(),
|
||||
),
|
||||
'assignee_user_id' => $ticket->assignee_user_id,
|
||||
'author_user_id' => $ticket->author_user_id,
|
||||
'blocked_comment' => $ticket->blocked_comment,
|
||||
|
||||
Reference in New Issue
Block a user