Merge pull request 'koda/kan-10-edit-templates' (#102) from koda/kan-10-edit-templates into epic/kan-3
Reviewed-on: OpenSource/KanbanGit#102
This commit was merged in pull request #102.
This commit is contained in:
@@ -57,6 +57,15 @@ class ProjectTemplateControllerTest extends TestCase
|
||||
->component('project-templates/Create')
|
||||
->where('project.id', $project->id)
|
||||
->has('copyAreaOptions', count(DuplicateProjectConfiguration::copyableAreas())));
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('project-templates.edit', $template))
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('project-templates/Edit')
|
||||
->where('template.id', $template->id)
|
||||
->where('template.slug', 'foundation-template')
|
||||
->has('copyAreaOptions', count(DuplicateProjectConfiguration::copyableAreas())));
|
||||
}
|
||||
|
||||
public function test_users_can_save_and_delete_templates_from_projects(): void
|
||||
@@ -148,5 +157,97 @@ class ProjectTemplateControllerTest extends TestCase
|
||||
$this->actingAs($user)
|
||||
->delete(route('project-templates.destroy', $template))
|
||||
->assertNotFound();
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('project-templates.edit', $template))
|
||||
->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_updating_a_template_requires_warning_acknowledgement_when_projects_are_linked(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$sourceProject = Project::factory()->create();
|
||||
$template = ProjectTemplate::factory()->create([
|
||||
'source_project_id' => $sourceProject->id,
|
||||
]);
|
||||
Project::factory()->create([
|
||||
'project_template_id' => $template->id,
|
||||
]);
|
||||
|
||||
$this->syncGlobalPermissions($user, ['project:create']);
|
||||
|
||||
$this->actingAs($user)
|
||||
->patch(route('project-templates.update', $template), [
|
||||
'name' => 'Updated Template',
|
||||
'copy_areas' => [DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS],
|
||||
])
|
||||
->assertSessionHasErrors('confirm_linked_projects_update');
|
||||
}
|
||||
|
||||
public function test_updating_a_template_refreshes_the_baseline_and_preserves_slug_and_overrides(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$sourceProject = Project::factory()->create([
|
||||
'name' => 'Template Source',
|
||||
'show_author' => false,
|
||||
'show_story_points' => false,
|
||||
]);
|
||||
$template = ProjectTemplate::factory()->create([
|
||||
'name' => 'Platform Template',
|
||||
'slug' => 'platform-template',
|
||||
'copy_areas' => [DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS],
|
||||
'configuration_snapshot' => [
|
||||
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS => [
|
||||
'show_author' => false,
|
||||
'show_story_points' => false,
|
||||
],
|
||||
],
|
||||
'source_project_id' => $sourceProject->id,
|
||||
]);
|
||||
$inheritingProject = Project::factory()->create([
|
||||
'project_template_id' => $template->id,
|
||||
'show_author' => false,
|
||||
'show_story_points' => false,
|
||||
]);
|
||||
$overriddenProject = Project::factory()->create([
|
||||
'project_template_id' => $template->id,
|
||||
'show_author' => true,
|
||||
'show_story_points' => false,
|
||||
]);
|
||||
|
||||
$sourceProject->forceFill([
|
||||
'show_author' => true,
|
||||
'show_story_points' => true,
|
||||
])->save();
|
||||
|
||||
$this->syncGlobalPermissions($user, ['project:create']);
|
||||
|
||||
$this->actingAs($user)
|
||||
->patch(route('project-templates.update', $template), [
|
||||
'name' => 'Platform Template v2',
|
||||
'slug' => 'should-not-change',
|
||||
'copy_areas' => [DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS],
|
||||
'confirm_linked_projects_update' => true,
|
||||
])
|
||||
->assertRedirect('/project-templates');
|
||||
|
||||
$template->refresh();
|
||||
$inheritingProject->refresh();
|
||||
$overriddenProject->refresh();
|
||||
|
||||
$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,
|
||||
],
|
||||
], $template->configuration_snapshot);
|
||||
|
||||
$this->assertTrue($inheritingProject->show_author);
|
||||
$this->assertTrue($inheritingProject->show_story_points);
|
||||
|
||||
$this->assertTrue($overriddenProject->show_author);
|
||||
$this->assertFalse($overriddenProject->show_story_points);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user