feat(api): sincronizar tipo de elemento y activo/inactivo en la app móvil
- bundle: mapFeature incluye feature_type_id e is_active; nuevo array feature_types (catálogo) para que el móvil resuelva nombres/colores. - /sync feature.update acepta is_active y feature_type_id (last-write-wins). - openapi.yaml: bundle documenta feature_types. Tests: MobileApiTest cubre feature.update con los nuevos campos + bundle. Suite 88 passing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -356,6 +356,30 @@ class MobileApiTest extends TestCase
|
||||
$this->assertEquals(100, $phase->fresh()->progress_percent);
|
||||
}
|
||||
|
||||
public function test_feature_update_sets_active_and_type_and_bundle_exposes_them(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$user->givePermissionTo('update progress');
|
||||
$project = $this->makeProject($user);
|
||||
$feature = $this->makeFeature($this->makeLayer($this->makePhase($project)));
|
||||
$type = \App\Models\FeatureType::create(['name' => 'Pilar', 'color' => '#ffffff']);
|
||||
|
||||
Sanctum::actingAs($user, ['mobile-sync']);
|
||||
$this->postJson('/api/v1/sync', ['operations' => [[
|
||||
'entity' => 'feature', 'op' => 'update', 'uuid' => (string) Str::uuid(),
|
||||
'data' => ['id' => $feature->id, 'is_active' => false, 'feature_type_id' => $type->id],
|
||||
]]])->assertOk()->assertJsonPath('results.0.status', 'applied');
|
||||
|
||||
$feature->refresh();
|
||||
$this->assertFalse($feature->is_active);
|
||||
$this->assertEquals($type->id, $feature->feature_type_id);
|
||||
|
||||
$res = $this->getJson("/api/v1/projects/{$project->id}/bundle")->assertOk();
|
||||
$this->assertEquals($type->id, $res->json('features.0.feature_type_id'));
|
||||
$this->assertFalse($res->json('features.0.is_active'));
|
||||
$this->assertTrue(collect($res->json('feature_types'))->pluck('id')->contains($type->id));
|
||||
}
|
||||
|
||||
public function test_sync_returns_conflict_when_server_is_newer(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
Reference in New Issue
Block a user