fixed missing features
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Feature\Projects;
|
||||
|
||||
use App\Actions\ProjectTicketMetadata\InitializeProjectTicketMetadata;
|
||||
use App\Models\BoardColumn;
|
||||
use App\Models\Project;
|
||||
use App\Models\RepositoryConnection;
|
||||
use App\Models\Ticket;
|
||||
@@ -11,6 +12,7 @@ use App\Models\TicketFieldValue;
|
||||
use App\Models\TicketLink;
|
||||
use App\Models\TicketLinkType;
|
||||
use App\Models\TicketPriority;
|
||||
use App\Models\TicketStatus;
|
||||
use App\Models\TicketType;
|
||||
use App\Models\TicketWorklogEntry;
|
||||
use App\Models\User;
|
||||
@@ -274,6 +276,97 @@ class ProjectTicketControllerTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the create page defaults to a board status when opened from the board.
|
||||
*/
|
||||
public function test_users_with_write_permission_can_view_the_ticket_create_page(): void
|
||||
{
|
||||
$editor = User::factory()->create();
|
||||
$project = Project::factory()->create([
|
||||
'key' => 'CORE',
|
||||
]);
|
||||
|
||||
app(InitializeProjectTicketMetadata::class)->handle($project);
|
||||
|
||||
$boardColumn = BoardColumn::factory()->for($project)->create([
|
||||
'name' => 'Todo',
|
||||
'position' => 1,
|
||||
]);
|
||||
$boardStatus = TicketStatus::factory()
|
||||
->for($project)
|
||||
->for($boardColumn)
|
||||
->create([
|
||||
'name' => 'Todo',
|
||||
'position' => 1,
|
||||
]);
|
||||
|
||||
$this->syncProjectPermissions($project, $editor, ['write', 'view']);
|
||||
|
||||
$this->actingAs($editor)
|
||||
->get(route('projects.tickets.create', [
|
||||
'project' => $project,
|
||||
'source' => 'board',
|
||||
]))
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('projects/TicketCreate')
|
||||
->where('defaultTicketStatusId', $boardStatus->id)
|
||||
->where('project.id', $project->id)
|
||||
->where('source', 'board')
|
||||
->where('ticketStatusOptions.1.id', $boardStatus->id),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure creating tickets from the dedicated endpoint redirects to the ticket detail page.
|
||||
*/
|
||||
public function test_users_with_write_permission_can_create_tickets(): void
|
||||
{
|
||||
$editor = User::factory()->create();
|
||||
$assignee = 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();
|
||||
|
||||
$this->syncProjectPermissions($project, $editor, ['write', 'view']);
|
||||
|
||||
$this->actingAs($editor)
|
||||
->post(route('projects.tickets.store', $project), [
|
||||
'acceptance_criteria' => 'The ticket exists.',
|
||||
'assignee_user_id' => $assignee->id,
|
||||
'description' => 'Created from the dedicated page.',
|
||||
'story_points' => 5,
|
||||
'ticket_priority_id' => $priority->id,
|
||||
'ticket_status_id' => $backlogStatus->id,
|
||||
'ticket_type_id' => $this->nonParentType($project)->id,
|
||||
'title' => 'Dedicated create page',
|
||||
])
|
||||
->assertRedirect(route('projects.tickets.show', [$project, 1]))
|
||||
->assertSessionHas('status', 'CORE-1 was created.');
|
||||
|
||||
$this->assertDatabaseHas('tickets', [
|
||||
'assignee_user_id' => $assignee->id,
|
||||
'author_user_id' => $editor->id,
|
||||
'project_id' => $project->id,
|
||||
'story_points' => 5,
|
||||
'ticket_key' => 'CORE-1',
|
||||
'ticket_status_id' => $backlogStatus->id,
|
||||
'title' => 'Dedicated create page',
|
||||
]);
|
||||
$this->assertDatabaseHas('ticket_worklog_entries', [
|
||||
'actor_id' => $editor->id,
|
||||
'entry_type' => 'created',
|
||||
'summary' => 'Ticket was created in Backlog.',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure updating ticket details requires the project edit permission.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user