Add reusable project templates
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Actions\ProjectTicketMetadata\InitializeProjectTicketMetadata;
|
||||
use App\Actions\Projects\DuplicateProjectConfiguration;
|
||||
use App\Models\BoardColumn;
|
||||
use App\Models\Project;
|
||||
use App\Models\ProjectTemplate;
|
||||
use App\Models\TicketStatus;
|
||||
use App\Models\TicketType;
|
||||
use App\Models\User;
|
||||
@@ -55,6 +56,51 @@ class ProjectApiTest extends TestCase
|
||||
$this->assertSame(1, $project->ticketStatuses()->count());
|
||||
}
|
||||
|
||||
public function test_users_can_create_projects_from_templates_via_api(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$this->syncGlobalPermissions($user, ['create']);
|
||||
|
||||
$template = ProjectTemplate::factory()->create([
|
||||
'name' => 'API Template',
|
||||
'slug' => 'api-template',
|
||||
'copy_areas' => [
|
||||
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS,
|
||||
DuplicateProjectConfiguration::COPY_TICKET_TYPES,
|
||||
],
|
||||
'configuration_snapshot' => [
|
||||
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS => [
|
||||
'show_author' => false,
|
||||
'show_story_points' => false,
|
||||
],
|
||||
DuplicateProjectConfiguration::COPY_TICKET_TYPES => [
|
||||
[
|
||||
'name' => 'Spike',
|
||||
'position' => 1,
|
||||
'is_parent' => false,
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->withApplicationKey($user)
|
||||
->postJson(route('api.projects.store'), [
|
||||
'key' => 'tpl1',
|
||||
'name' => 'Template API Project',
|
||||
'creation_mode' => 'template',
|
||||
'source_template_id' => $template->id,
|
||||
])
|
||||
->assertCreated()
|
||||
->assertJsonPath('data.key', 'TPL1')
|
||||
->assertJsonPath('data.name', 'Template API Project');
|
||||
|
||||
$project = Project::query()->where('key', 'TPL1')->firstOrFail();
|
||||
|
||||
$this->assertFalse($project->show_author);
|
||||
$this->assertFalse($project->show_story_points);
|
||||
$this->assertSame(['Spike'], $project->ticketTypes()->pluck('name')->all());
|
||||
}
|
||||
|
||||
public function test_users_can_duplicate_projects_via_api(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
Reference in New Issue
Block a user