Add template context to API and MCP project payloads
This commit is contained in:
@@ -108,6 +108,76 @@ class ProjectApiTest extends TestCase
|
||||
$this->assertSame(['Spike'], $project->ticketTypes()->pluck('name')->all());
|
||||
}
|
||||
|
||||
public function test_project_api_exposes_template_context_and_overrides(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$project = Project::factory()->create([
|
||||
'key' => 'TMP1',
|
||||
'name' => 'Template Driven Project',
|
||||
'show_author' => false,
|
||||
'show_story_points' => false,
|
||||
]);
|
||||
$template = ProjectTemplate::factory()->create([
|
||||
'name' => 'Workflow Template',
|
||||
'slug' => 'workflow-template',
|
||||
'copy_areas' => [
|
||||
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS,
|
||||
DuplicateProjectConfiguration::COPY_TICKET_TYPES,
|
||||
],
|
||||
'configuration_snapshot' => [
|
||||
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS => [
|
||||
'show_author' => true,
|
||||
'show_story_points' => true,
|
||||
],
|
||||
DuplicateProjectConfiguration::COPY_TICKET_TYPES => [
|
||||
[
|
||||
'name' => 'Bug',
|
||||
'position' => 1,
|
||||
'is_parent' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'Feature',
|
||||
'position' => 2,
|
||||
'is_parent' => false,
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$project->update([
|
||||
'project_template_id' => $template->id,
|
||||
]);
|
||||
$project->ticketTypes()->delete();
|
||||
TicketType::factory()->create([
|
||||
'project_id' => $project->id,
|
||||
'name' => 'Bug',
|
||||
'position' => 1,
|
||||
'is_parent' => false,
|
||||
]);
|
||||
TicketType::factory()->create([
|
||||
'project_id' => $project->id,
|
||||
'name' => 'Feature',
|
||||
'position' => 2,
|
||||
'is_parent' => false,
|
||||
]);
|
||||
|
||||
$this->syncProjectPermissions($project, $user, ['view']);
|
||||
|
||||
$this->withApplicationKey($user)
|
||||
->getJson(route('api.projects.show', $project))
|
||||
->assertOk()
|
||||
->assertJsonPath('data.project_template.id', $template->id)
|
||||
->assertJsonPath('data.project_template.slug', 'workflow-template')
|
||||
->assertJsonPath('data.project_template.configuration_snapshot.project_settings.show_author', true)
|
||||
->assertJsonPath('data.template_state.inherits_from_template', true)
|
||||
->assertJsonPath('data.template_state.template_id', $template->id)
|
||||
->assertJsonPath('data.template_state.template_configuration.project_settings.show_author', true)
|
||||
->assertJsonPath('data.template_state.effective_configuration.ticket_types.0.name', 'Bug')
|
||||
->assertJsonPath('data.template_state.inherited_configuration.ticket_types.1.name', 'Feature')
|
||||
->assertJsonPath('data.template_state.overridden_configuration.project_settings.show_author', false)
|
||||
->assertJsonPath('data.template_state.overridden_areas.0.value', DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS);
|
||||
}
|
||||
|
||||
public function test_users_can_duplicate_projects_via_api(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
Reference in New Issue
Block a user