Merge pull request 'KAN-8 Add project template context to API and MCP' (#90) from koda/kan-8-add-project-template-to-mcp-api into main
Reviewed-on: OpenSource/KanbanGit#90
This commit was merged in pull request #90.
This commit is contained in:
@@ -3,8 +3,10 @@
|
||||
namespace Tests\Feature\Projects;
|
||||
|
||||
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\Ticket;
|
||||
use App\Models\TicketStatus;
|
||||
use App\Models\User;
|
||||
@@ -31,6 +33,15 @@ class ProjectBoardSettingsControllerTest extends TestCase
|
||||
'position' => 1,
|
||||
]);
|
||||
|
||||
$template = ProjectTemplate::factory()->create([
|
||||
'configuration_snapshot' => app(DuplicateProjectConfiguration::class)->export($project, [
|
||||
DuplicateProjectConfiguration::COPY_BOARD_WORKFLOW,
|
||||
]),
|
||||
'copy_areas' => [DuplicateProjectConfiguration::COPY_BOARD_WORKFLOW],
|
||||
'name' => 'Starter Workflow',
|
||||
]);
|
||||
$project->update(['project_template_id' => $template->id]);
|
||||
|
||||
$this->syncProjectPermissions($project, $user, ['edit']);
|
||||
|
||||
$this->actingAs($user)
|
||||
@@ -41,7 +52,9 @@ class ProjectBoardSettingsControllerTest extends TestCase
|
||||
->where('project.id', $project->id)
|
||||
->where('backlogTicketStatuses.0.name', 'Backlog')
|
||||
->where('boardColumns.0.name', 'Todo')
|
||||
->where('ticketStatuses.0.name', 'Backlog'),
|
||||
->where('ticketStatuses.0.name', 'Backlog')
|
||||
->where('templateState.templateName', 'Starter Workflow')
|
||||
->where('templateState.inheritedAreas.0.value', DuplicateProjectConfiguration::COPY_BOARD_WORKFLOW),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,19 @@
|
||||
namespace Tests\Feature\Projects;
|
||||
|
||||
use App\Actions\ProjectTicketMetadata\InitializeProjectTicketMetadata;
|
||||
use App\Actions\Projects\DuplicateProjectConfiguration;
|
||||
use App\Models\BoardColumn;
|
||||
use App\Models\NotificationAction;
|
||||
use App\Models\Project;
|
||||
use App\Models\ProjectTemplate;
|
||||
use App\Models\RepositoryConnection;
|
||||
use App\Models\Team;
|
||||
use App\Models\Ticket;
|
||||
use App\Models\TicketFieldDefinition;
|
||||
use App\Models\TicketLinkType;
|
||||
use App\Models\TicketPriority;
|
||||
use App\Models\TicketStatus;
|
||||
use App\Models\TicketType;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
@@ -100,12 +108,40 @@ class ProjectControllerTest extends TestCase
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$this->syncGlobalPermissions($user, ['project:create']);
|
||||
$visibleProject = Project::factory()->create([
|
||||
'name' => 'Visible Source',
|
||||
'key' => 'SRC1',
|
||||
]);
|
||||
Project::factory()->create([
|
||||
'name' => 'Hidden Source',
|
||||
'key' => 'SRC2',
|
||||
]);
|
||||
$template = ProjectTemplate::factory()->create([
|
||||
'name' => 'Reusable Setup',
|
||||
'slug' => 'reusable-setup',
|
||||
'source_project_id' => $visibleProject->id,
|
||||
]);
|
||||
ProjectTemplate::factory()->create([
|
||||
'name' => 'Hidden Base',
|
||||
'slug' => 'hidden-base',
|
||||
'project_id' => $visibleProject->id,
|
||||
'source_project_id' => $visibleProject->id,
|
||||
'is_published' => false,
|
||||
]);
|
||||
$this->syncProjectPermissions($visibleProject, $user, ['view']);
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('projects.create'))
|
||||
->get(route('projects.create', ['template' => $template->id]))
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('projects/Create'),
|
||||
->component('projects/Create')
|
||||
->has('copyAreaOptions', count(DuplicateProjectConfiguration::copyableAreas()))
|
||||
->has('sourceProjects', 1)
|
||||
->has('sourceTemplates', 1)
|
||||
->where('sourceProjects.0.id', $visibleProject->id)
|
||||
->where('sourceTemplates.0.id', $template->id)
|
||||
->where('selectedSourceTemplateId', $template->id)
|
||||
->where('copyAreaOptions.0.value', DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -131,6 +167,7 @@ class ProjectControllerTest extends TestCase
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->post(route('projects.store'), [
|
||||
'creation_mode' => 'scratch',
|
||||
'name' => 'Kanban Foundation',
|
||||
'key' => 'core',
|
||||
]);
|
||||
@@ -144,6 +181,18 @@ class ProjectControllerTest extends TestCase
|
||||
'key' => 'CORE',
|
||||
]);
|
||||
|
||||
$project->refresh();
|
||||
|
||||
$this->assertNotNull($project->project_template_id);
|
||||
|
||||
$this->assertDatabaseHas('project_templates', [
|
||||
'id' => $project->project_template_id,
|
||||
'project_id' => $project->id,
|
||||
'source_project_id' => $project->id,
|
||||
'is_published' => false,
|
||||
'slug' => 'core-base-template',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('permission_assignments', [
|
||||
'assignee_id' => $user->id,
|
||||
'assignee_type' => $user->getMorphClass(),
|
||||
@@ -187,6 +236,215 @@ class ProjectControllerTest extends TestCase
|
||||
->assertRedirect(route('projects.create'));
|
||||
}
|
||||
|
||||
public function test_authenticated_users_can_create_projects_from_saved_templates(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$this->syncGlobalPermissions($user, ['project:create']);
|
||||
|
||||
$sourceProject = Project::factory()->create([
|
||||
'key' => 'SRC1',
|
||||
'name' => 'Source Project',
|
||||
'show_author' => false,
|
||||
'show_story_points' => false,
|
||||
]);
|
||||
|
||||
$template = ProjectTemplate::factory()->create([
|
||||
'source_project_id' => $sourceProject->id,
|
||||
'name' => 'Kanban Template',
|
||||
'slug' => 'kanban-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' => 'Bug',
|
||||
'position' => 1,
|
||||
'is_parent' => false,
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->post(route('projects.store'), [
|
||||
'creation_mode' => 'template',
|
||||
'name' => 'Template Based Project',
|
||||
'key' => 'TMP1',
|
||||
'source_template_id' => $template->id,
|
||||
]);
|
||||
|
||||
$project = Project::query()->where('key', 'TMP1')->firstOrFail();
|
||||
|
||||
$response->assertRedirect(route('projects.show', $project));
|
||||
|
||||
$project->refresh();
|
||||
|
||||
$this->assertSame($template->id, $project->project_template_id);
|
||||
$this->assertSame(false, $project->show_author);
|
||||
$this->assertSame(false, $project->show_story_points);
|
||||
$this->assertDatabaseHas('ticket_types', [
|
||||
'project_id' => $project->id,
|
||||
'name' => 'Bug',
|
||||
'position' => 1,
|
||||
'is_parent' => false,
|
||||
]);
|
||||
$this->assertDatabaseMissing('tickets', [
|
||||
'project_id' => $project->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_authenticated_users_can_duplicate_projects_with_selected_settings_only(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$this->syncGlobalPermissions($user, ['project:create']);
|
||||
|
||||
$sourceProject = Project::factory()->create([
|
||||
'key' => 'SRC1',
|
||||
'name' => 'Source Project',
|
||||
'show_author' => false,
|
||||
'show_story_points' => false,
|
||||
]);
|
||||
$this->syncProjectPermissions($sourceProject, $user, ['view']);
|
||||
|
||||
$sourceProject->ticketTypes()->delete();
|
||||
$sourceProject->ticketPriorities()->delete();
|
||||
$sourceProject->ticketStatuses()->delete();
|
||||
$sourceProject->boardColumns()->delete();
|
||||
|
||||
$todoColumn = BoardColumn::factory()->create([
|
||||
'project_id' => $sourceProject->id,
|
||||
'name' => 'Todo',
|
||||
'position' => 1,
|
||||
]);
|
||||
$doingColumn = BoardColumn::factory()->create([
|
||||
'project_id' => $sourceProject->id,
|
||||
'name' => 'Doing',
|
||||
'position' => 2,
|
||||
]);
|
||||
|
||||
$backlogStatus = TicketStatus::factory()->create([
|
||||
'project_id' => $sourceProject->id,
|
||||
'board_column_id' => null,
|
||||
'name' => 'Planned',
|
||||
'position' => 1,
|
||||
]);
|
||||
$todoStatus = TicketStatus::factory()->create([
|
||||
'project_id' => $sourceProject->id,
|
||||
'board_column_id' => $todoColumn->id,
|
||||
'name' => 'Todo',
|
||||
'position' => 1,
|
||||
]);
|
||||
$doingStatus = TicketStatus::factory()->create([
|
||||
'project_id' => $sourceProject->id,
|
||||
'board_column_id' => $doingColumn->id,
|
||||
'name' => 'Doing',
|
||||
'position' => 1,
|
||||
]);
|
||||
$todoStatus->allowedTargetStatuses()->sync([$doingStatus->id]);
|
||||
$backlogStatus->allowedTargetStatuses()->sync([$todoStatus->id]);
|
||||
|
||||
TicketType::factory()->create([
|
||||
'project_id' => $sourceProject->id,
|
||||
'name' => 'Bug',
|
||||
'position' => 1,
|
||||
]);
|
||||
TicketType::factory()->create([
|
||||
'project_id' => $sourceProject->id,
|
||||
'name' => 'Epic',
|
||||
'position' => 2,
|
||||
'is_parent' => true,
|
||||
]);
|
||||
TicketPriority::factory()->create([
|
||||
'project_id' => $sourceProject->id,
|
||||
'name' => 'Urgent',
|
||||
'position' => 1,
|
||||
]);
|
||||
TicketFieldDefinition::factory()->create([
|
||||
'project_id' => $sourceProject->id,
|
||||
'field_type' => 'number',
|
||||
'label' => 'Story estimate',
|
||||
'position' => 1,
|
||||
]);
|
||||
TicketLinkType::factory()->create([
|
||||
'project_id' => $sourceProject->id,
|
||||
'label' => 'Blocks',
|
||||
'counterpart_label' => 'Blocked by',
|
||||
'position' => 1,
|
||||
]);
|
||||
RepositoryConnection::factory()->create([
|
||||
'project_id' => $sourceProject->id,
|
||||
'repository_full_name' => 'OpenSource/source-project',
|
||||
]);
|
||||
NotificationAction::factory()->create([
|
||||
'project_id' => $sourceProject->id,
|
||||
'name' => 'Notify board changes',
|
||||
]);
|
||||
Ticket::factory()->create([
|
||||
'project_id' => $sourceProject->id,
|
||||
'sequence_number' => 42,
|
||||
'title' => 'Existing ticket',
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->post(route('projects.store'), [
|
||||
'name' => 'Duplicated Project',
|
||||
'key' => 'dupe',
|
||||
'creation_mode' => 'duplicate',
|
||||
'source_project_id' => $sourceProject->id,
|
||||
'copy_areas' => [
|
||||
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS,
|
||||
DuplicateProjectConfiguration::COPY_BOARD_WORKFLOW,
|
||||
DuplicateProjectConfiguration::COPY_TICKET_TYPES,
|
||||
DuplicateProjectConfiguration::COPY_TICKET_FIELDS,
|
||||
],
|
||||
]);
|
||||
|
||||
$project = Project::query()->where('key', 'DUPE')->firstOrFail();
|
||||
|
||||
$response->assertRedirect(route('projects.show', $project));
|
||||
|
||||
$this->assertSame('Duplicated Project', $project->name);
|
||||
$this->assertFalse($project->show_author);
|
||||
$this->assertFalse($project->show_story_points);
|
||||
$this->assertSame(0, $project->tickets()->count());
|
||||
|
||||
$this->assertSame(['Todo', 'Doing'], $project->boardColumns()->pluck('name')->all());
|
||||
$this->assertSame(['Planned', 'Todo', 'Doing'], $project->ticketStatuses()->pluck('name')->all());
|
||||
$this->assertSame(['Bug', 'Epic'], $project->ticketTypes()->pluck('name')->all());
|
||||
$this->assertSame(['Story estimate'], $project->ticketFieldDefinitions()->pluck('label')->all());
|
||||
$this->assertSame(['Medium'], $project->ticketPriorities()->pluck('name')->all());
|
||||
$this->assertCount(0, $project->ticketLinkTypes);
|
||||
$this->assertCount(0, $project->repositoryConnections);
|
||||
$this->assertCount(0, $project->notificationActions);
|
||||
|
||||
$duplicatedTodoStatus = $project->ticketStatuses()->where('name', 'Todo')->firstOrFail();
|
||||
$this->assertSame(['Doing'], $duplicatedTodoStatus->allowedTargetStatuses()->pluck('name')->all());
|
||||
}
|
||||
|
||||
public function test_project_duplication_requires_accessible_source_projects(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$this->syncGlobalPermissions($user, ['project:create']);
|
||||
$sourceProject = Project::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->from(route('projects.create'))
|
||||
->post(route('projects.store'), [
|
||||
'name' => 'Denied Duplicate',
|
||||
'key' => 'deny',
|
||||
'creation_mode' => 'duplicate',
|
||||
'source_project_id' => $sourceProject->id,
|
||||
])
|
||||
->assertSessionHasErrors('source_project_id')
|
||||
->assertRedirect(route('projects.create'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure project keys cannot exceed five characters.
|
||||
*/
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace Tests\Feature\Projects;
|
||||
|
||||
use App\Actions\Projects\DuplicateProjectConfiguration;
|
||||
use App\Enums\NotificationChannel;
|
||||
use App\Enums\NotificationEventType;
|
||||
use App\Models\NotificationAction;
|
||||
use App\Models\Project;
|
||||
use App\Models\ProjectTemplate;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
@@ -41,6 +43,15 @@ class ProjectNotificationSettingsControllerTest extends TestCase
|
||||
],
|
||||
]);
|
||||
|
||||
$template = ProjectTemplate::factory()->create([
|
||||
'configuration_snapshot' => app(DuplicateProjectConfiguration::class)->export($project, [
|
||||
DuplicateProjectConfiguration::COPY_NOTIFICATION_ACTIONS,
|
||||
]),
|
||||
'copy_areas' => [DuplicateProjectConfiguration::COPY_NOTIFICATION_ACTIONS],
|
||||
'name' => 'Alert Template',
|
||||
]);
|
||||
$project->update(['project_template_id' => $template->id]);
|
||||
|
||||
$this->syncProjectPermissions($project, $user, ['edit']);
|
||||
|
||||
$this->actingAs($user)
|
||||
@@ -72,6 +83,8 @@ class ProjectNotificationSettingsControllerTest extends TestCase
|
||||
->where('templateVariables.6.value', '$actor_name')
|
||||
->where('templateVariables.7.value', '$assignee_from')
|
||||
->where('templateVariables.8.value', '$assignee_to')
|
||||
->where('templateState.templateName', 'Alert Template')
|
||||
->where('templateState.inheritedAreas.0.value', DuplicateProjectConfiguration::COPY_NOTIFICATION_ACTIONS)
|
||||
->missing('notificationActions.0.delivery_url'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace Tests\Feature\Projects;
|
||||
|
||||
use App\Actions\Git\GitProviderKey;
|
||||
use App\Actions\Projects\DuplicateProjectConfiguration;
|
||||
use App\Models\Project;
|
||||
use App\Models\ProjectTemplate;
|
||||
use App\Models\RepositoryConnection;
|
||||
use App\Models\User;
|
||||
use App\Models\UserGitConnection;
|
||||
@@ -36,6 +38,15 @@ class ProjectRepositorySettingsControllerTest extends TestCase
|
||||
'repository_url' => 'https://git.example.test/core-team/kanbangit',
|
||||
]);
|
||||
|
||||
$template = ProjectTemplate::factory()->create([
|
||||
'configuration_snapshot' => app(DuplicateProjectConfiguration::class)->export($project, [
|
||||
DuplicateProjectConfiguration::COPY_REPOSITORY_CONNECTIONS,
|
||||
]),
|
||||
'copy_areas' => [DuplicateProjectConfiguration::COPY_REPOSITORY_CONNECTIONS],
|
||||
'name' => 'Connected Template',
|
||||
]);
|
||||
$project->update(['project_template_id' => $template->id]);
|
||||
|
||||
$this->syncProjectPermissions($project, $user, ['edit']);
|
||||
|
||||
$this->actingAs($user)
|
||||
@@ -46,7 +57,9 @@ class ProjectRepositorySettingsControllerTest extends TestCase
|
||||
->where('project.id', $project->id)
|
||||
->where('repositoryConnections.0.repository_full_name', 'core-team/kanbangit')
|
||||
->where('repositoryConnections.0.has_personal_access', false)
|
||||
->where('availableRepositorySources', []),
|
||||
->where('availableRepositorySources', [])
|
||||
->where('templateState.templateName', 'Connected Template')
|
||||
->where('templateState.inheritedAreas.0.value', DuplicateProjectConfiguration::COPY_REPOSITORY_CONNECTIONS),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Projects;
|
||||
|
||||
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;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProjectTemplateControllerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_users_with_project_create_permission_can_view_templates_index_and_create_screen(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$project = Project::factory()->create([
|
||||
'name' => 'Core Platform',
|
||||
'key' => 'CORE',
|
||||
]);
|
||||
$template = ProjectTemplate::factory()->create([
|
||||
'name' => 'Foundation Template',
|
||||
'slug' => 'foundation-template',
|
||||
'source_project_id' => $project->id,
|
||||
]);
|
||||
ProjectTemplate::factory()->create([
|
||||
'name' => 'Hidden Base Template',
|
||||
'slug' => 'hidden-base-template',
|
||||
'project_id' => $project->id,
|
||||
'source_project_id' => $project->id,
|
||||
'is_published' => false,
|
||||
]);
|
||||
|
||||
$this->syncGlobalPermissions($user, ['project:create']);
|
||||
$this->syncProjectPermissions($project, $user, ['view']);
|
||||
|
||||
$this->actingAs($user)
|
||||
->get('/project-templates')
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('project-templates/Index')
|
||||
->has('templates', 1)
|
||||
->where('templates.0.id', $template->id)
|
||||
->where('templates.0.slug', 'foundation-template')
|
||||
->where('templates.0.is_published', true));
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('projects.templates.create', $project))
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('project-templates/Create')
|
||||
->where('project.id', $project->id)
|
||||
->has('copyAreaOptions', count(DuplicateProjectConfiguration::copyableAreas())));
|
||||
}
|
||||
|
||||
public function test_users_can_save_and_delete_templates_from_projects(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$project = Project::factory()->create([
|
||||
'name' => 'Source Project',
|
||||
'key' => 'SRC1',
|
||||
'show_author' => false,
|
||||
'show_story_points' => false,
|
||||
]);
|
||||
|
||||
$this->syncGlobalPermissions($user, ['project:create']);
|
||||
$this->syncProjectPermissions($project, $user, ['view']);
|
||||
|
||||
$project->ticketTypes()->delete();
|
||||
$project->ticketStatuses()->delete();
|
||||
$project->boardColumns()->delete();
|
||||
|
||||
$boardColumn = BoardColumn::factory()->create([
|
||||
'project_id' => $project->id,
|
||||
'name' => 'Doing',
|
||||
'position' => 1,
|
||||
]);
|
||||
$ticketStatus = TicketStatus::factory()->create([
|
||||
'project_id' => $project->id,
|
||||
'board_column_id' => $boardColumn->id,
|
||||
'name' => 'Doing',
|
||||
'position' => 1,
|
||||
]);
|
||||
$ticketStatus->allowedTargetStatuses()->sync([$ticketStatus->id]);
|
||||
TicketType::factory()->create([
|
||||
'project_id' => $project->id,
|
||||
'name' => 'Bug',
|
||||
'position' => 1,
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->post(route('projects.templates.store', $project), [
|
||||
'name' => 'Core Reusable',
|
||||
'slug' => 'core-reusable',
|
||||
'copy_areas' => [
|
||||
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS,
|
||||
DuplicateProjectConfiguration::COPY_TICKET_TYPES,
|
||||
],
|
||||
])
|
||||
->assertRedirect('/project-templates');
|
||||
|
||||
$template = ProjectTemplate::query()->where('slug', 'core-reusable')->firstOrFail();
|
||||
|
||||
$this->assertTrue($template->is_published);
|
||||
$this->assertNull($template->project_id);
|
||||
|
||||
$this->assertSame([
|
||||
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS => [
|
||||
'show_author' => false,
|
||||
'show_story_points' => false,
|
||||
],
|
||||
DuplicateProjectConfiguration::COPY_TICKET_TYPES => [
|
||||
[
|
||||
'name' => 'Bug',
|
||||
'position' => 1,
|
||||
'is_parent' => false,
|
||||
],
|
||||
],
|
||||
], $template->configuration_snapshot);
|
||||
|
||||
$this->actingAs($user)
|
||||
->delete(route('project-templates.destroy', $template))
|
||||
->assertRedirect('/project-templates');
|
||||
|
||||
$this->assertDatabaseMissing('project_templates', [
|
||||
'id' => $template->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_hidden_base_templates_cannot_be_deleted_from_the_management_flow(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$project = Project::factory()->create();
|
||||
$template = ProjectTemplate::factory()->create([
|
||||
'project_id' => $project->id,
|
||||
'source_project_id' => $project->id,
|
||||
'is_published' => false,
|
||||
]);
|
||||
|
||||
$this->syncGlobalPermissions($user, ['project:create']);
|
||||
|
||||
$this->actingAs($user)
|
||||
->delete(route('project-templates.destroy', $template))
|
||||
->assertNotFound();
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace Tests\Feature\Projects;
|
||||
|
||||
use App\Actions\ProjectTicketMetadata\InitializeProjectTicketMetadata;
|
||||
use App\Actions\Projects\DuplicateProjectConfiguration;
|
||||
use App\Models\Project;
|
||||
use App\Models\ProjectTemplate;
|
||||
use App\Models\Ticket;
|
||||
use App\Models\TicketFieldDefinition;
|
||||
use App\Models\TicketLinkType;
|
||||
@@ -37,6 +39,24 @@ class ProjectTicketMetadataSettingsControllerTest extends TestCase
|
||||
'position' => 1,
|
||||
]);
|
||||
|
||||
$template = ProjectTemplate::factory()->create([
|
||||
'configuration_snapshot' => app(DuplicateProjectConfiguration::class)->export($project, [
|
||||
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS,
|
||||
DuplicateProjectConfiguration::COPY_TICKET_TYPES,
|
||||
DuplicateProjectConfiguration::COPY_TICKET_LINK_TYPES,
|
||||
]),
|
||||
'copy_areas' => [
|
||||
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS,
|
||||
DuplicateProjectConfiguration::COPY_TICKET_TYPES,
|
||||
DuplicateProjectConfiguration::COPY_TICKET_LINK_TYPES,
|
||||
],
|
||||
'name' => 'Issue Tracker Template',
|
||||
]);
|
||||
$project->update([
|
||||
'project_template_id' => $template->id,
|
||||
'show_story_points' => false,
|
||||
]);
|
||||
|
||||
$this->syncProjectPermissions($project, $user, ['edit']);
|
||||
|
||||
$this->actingAs($user)
|
||||
@@ -45,12 +65,14 @@ class ProjectTicketMetadataSettingsControllerTest extends TestCase
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('projects/settings/Metadata')
|
||||
->where('project.show_author', true)
|
||||
->where('project.show_story_points', true)
|
||||
->where('project.show_story_points', false)
|
||||
->where('ticketTypes.0.name', 'Task')
|
||||
->where('ticketTypes.1.name', 'Release')
|
||||
->where('ticketTypes.1.is_parent', true)
|
||||
->where('ticketTypes.2.name', 'Bug')
|
||||
->where('ticketLinkTypes.0.label', 'Relates to'),
|
||||
->where('ticketLinkTypes.0.label', 'Relates to')
|
||||
->where('templateState.templateName', 'Issue Tracker Template')
|
||||
->where('templateState.overriddenAreas.0.value', DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user