fix(KAN-14): preserve template inheritance and project data
CI/CD / preconditions (pull_request) Successful in 4s
CI/CD / test_and_check_app (pull_request) Failing after 2m14s
CI/CD / Publish immutable image (pull_request) Skipped

This commit is contained in:
2026-10-15 11:38:17 +02:00
parent 5769d84526
commit 1291a0fcad
61 changed files with 2696 additions and 335 deletions
@@ -38,7 +38,7 @@ class ProjectTemplateControllerTest extends TestCase
]);
$this->syncGlobalPermissions($user, ['project:create']);
$this->syncProjectPermissions($project, $user, ['view']);
$this->syncProjectPermissions($project, $user, ['admin']);
$this->actingAs($user)
->get('/project-templates')
@@ -79,7 +79,7 @@ class ProjectTemplateControllerTest extends TestCase
]);
$this->syncGlobalPermissions($user, ['project:create']);
$this->syncProjectPermissions($project, $user, ['view']);
$this->syncProjectPermissions($project, $user, ['admin']);
$project->ticketTypes()->delete();
$project->ticketStatuses()->delete();
@@ -119,19 +119,8 @@ class ProjectTemplateControllerTest extends TestCase
$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->assertSame(app(DuplicateProjectConfiguration::class)->export($project, $template->copy_areas), $template->configuration_snapshot);
$this->assertSame($template->id, $project->fresh()->project_template_id);
$this->actingAs($user)
->delete(route('project-templates.destroy', $template))
@@ -271,6 +260,11 @@ class ProjectTemplateControllerTest extends TestCase
],
])->saveQuietly();
app(DuplicateProjectConfiguration::class)->apply($inheritingProject, $template->configuration_snapshot, adoptExisting: true);
$nextConfiguration = app(DuplicateProjectConfiguration::class)->normalizeConfiguration($template->configuration_snapshot);
$nextConfiguration['project_settings'] = ['show_author' => true, 'show_story_points' => true];
$nextConfiguration['ticket_types'][0]['name'] = 'Feature';
$sourceProject->forceFill([
'show_author' => true,
'show_story_points' => true,
@@ -281,6 +275,7 @@ class ProjectTemplateControllerTest extends TestCase
$this->actingAs($user)
->patch(route('project-templates.update', $template), [
'name' => 'Platform Template v2',
'configuration_snapshot' => $nextConfiguration,
'slug' => 'should-not-change',
'copy_areas' => [
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS,
@@ -296,19 +291,7 @@ class ProjectTemplateControllerTest extends TestCase
$this->assertSame('Platform Template v2', $template->name);
$this->assertSame('platform-template', $template->slug);
$this->assertSame([
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS => [
'show_author' => true,
'show_story_points' => true,
],
DuplicateProjectConfiguration::COPY_TICKET_TYPES => [
[
'name' => 'Feature',
'position' => 1,
'is_parent' => false,
],
],
], $template->configuration_snapshot);
$this->assertSame($nextConfiguration, $template->configuration_snapshot);
$this->assertTrue($inheritingProject->show_author);
$this->assertTrue($inheritingProject->show_story_points);