Aceita fila administrativa de associacoes com checkpoint local
This commit is contained in:
@@ -25,6 +25,13 @@ final class ModuleNavigationTest extends TestCase
|
||||
{
|
||||
return $this->postJson('/api/context',['tenant_id'=>$this->f['tenant'],'company_id'=>$company??$this->f['company'],'unit_id'=>$this->f['unit'],'module_id'=>$module]);
|
||||
}
|
||||
private function decide(array $input)
|
||||
{
|
||||
$input['operation'] ??= 'associate';
|
||||
$preview = $this->postJson('/api/module-records/preview', $input);
|
||||
if ($preview->status() !== 200) return $preview;
|
||||
return $this->postJson('/api/module-records', ['review_token' => $preview->json('review_token')]);
|
||||
}
|
||||
public function test_explicit_selection_direct_access_and_old_generation(): void
|
||||
{
|
||||
$this->select(null)->assertOk();
|
||||
@@ -95,15 +102,15 @@ final class ModuleNavigationTest extends TestCase
|
||||
$this->withHeader('X-SGF-Context',$token)->getJson('/api/a/clients')->assertOk()->assertJsonPath('records',[]);
|
||||
$this->getJson('/api/a/clients/'.$id)->assertForbidden();
|
||||
$this->getJson('/api/module-records')->assertOk()->assertJsonPath('records.clients.0.id',$id);
|
||||
$this->postJson('/api/module-records',['area'=>'clients','id'=>$id,'version'=>1,'module_id'=>'workshop','reason'=>'Explicit synthetic association'])->assertOk();
|
||||
$this->decide(['area'=>'clients','id'=>$id,'version'=>1,'module_id'=>'workshop','reason'=>'Explicit synthetic association'])->assertOk();
|
||||
$this->getJson('/api/a/clients/'.$id)->assertOk()->assertJsonPath('name','Module proof client');
|
||||
$this->assertSame(1,DB::table('a_clients')->where('id',$id)->value('version'));
|
||||
$this->assertSame(2,DB::table('identity_audit')->where('action','module.record.associated')->where('company_id',$this->f['company'])->count());
|
||||
$this->postJson('/api/module-records',['area'=>'clients','id'=>$id,'version'=>1,'module_id'=>'workshop','reason'=>'Correct association without rewriting original','operation'=>'remove'])->assertOk();
|
||||
$this->decide(['area'=>'clients','id'=>$id,'version'=>1,'module_id'=>'workshop','reason'=>'Correct association without rewriting original','operation'=>'remove'])->assertOk();
|
||||
$this->getJson('/api/a/clients/'.$id)->assertForbidden();
|
||||
$this->getJson('/api/module-records')->assertOk()->assertJsonPath('records.clients.0.modules',['commercial']);
|
||||
$this->assertSame(1,DB::table('a_clients')->where('id',$id)->value('version'));
|
||||
$this->postJson('/api/module-records',['area'=>'clients','id'=>$id,'version'=>1,'module_id'=>'workshop','reason'=>'Re-association explicitly reviewed'])->assertOk();
|
||||
$this->decide(['area'=>'clients','id'=>$id,'version'=>1,'module_id'=>'workshop','reason'=>'Re-association explicitly reviewed'])->assertOk();
|
||||
$this->getJson('/api/a/clients/'.$id)->assertOk();
|
||||
IdentityFixture::grant($actor->id,$this->f['tenant'],$this->f['sibling'],'clients.view');
|
||||
$token=$this->postJson('/api/context',['tenant_id'=>$this->f['tenant'],'company_id'=>$this->f['sibling'],'unit_id'=>$this->f['siblingUnit'],'module_id'=>'commercial'])->assertOk()->json('context.token');
|
||||
@@ -120,7 +127,7 @@ final class ModuleNavigationTest extends TestCase
|
||||
$this->getJson('/api/module-records')->assertForbidden();
|
||||
IdentityFixture::grant($this->f['reader']->id,$this->f['tenant'],$this->f['company'],'access.manage');
|
||||
$this->getJson('/api/module-records')->assertOk()->assertJsonPath('records.clients.0.id',$id)->assertJsonPath('records.clients.0.modules',[]);
|
||||
$this->postJson('/api/module-records',['area'=>'clients','id'=>$id,'version'=>1,'module_id'=>'commercial','reason'=>'Cannot assign without edit permission'])->assertForbidden();
|
||||
$this->decide(['area'=>'clients','id'=>$id,'version'=>1,'module_id'=>'commercial','reason'=>'Cannot assign without edit permission'])->assertForbidden();
|
||||
$this->assertSame('Existing unassociated record',DB::table('a_clients')->where('id',$id)->value('name'));
|
||||
}
|
||||
|
||||
@@ -141,8 +148,8 @@ final class ModuleNavigationTest extends TestCase
|
||||
$original=$this->getJson('/api/a/billing_drafts/'.$bill)->assertOk()->json();
|
||||
$this->assertSame($draft,$original['source_id']);
|
||||
$token=$this->select('workshop')->assertOk()->json('context.token');
|
||||
$this->withHeader('X-SGF-Context',$token)->postJson('/api/module-records',['area'=>'billing_drafts','id'=>$bill,'version'=>99,'module_id'=>'workshop','reason'=>'Reject stale review'])->assertStatus(409);
|
||||
$this->postJson('/api/module-records',['area'=>'billing_drafts','id'=>$bill,'version'=>1,'module_id'=>'workshop','reason'=>'Explicitly share this preserved draft'])->assertOk();
|
||||
$this->withHeader('X-SGF-Context',$token)->decide(['area'=>'billing_drafts','id'=>$bill,'version'=>99,'module_id'=>'workshop','reason'=>'Reject stale review'])->assertStatus(409);
|
||||
$this->decide(['area'=>'billing_drafts','id'=>$bill,'version'=>1,'module_id'=>'workshop','reason'=>'Explicitly share this preserved draft'])->assertOk();
|
||||
$record=$this->getJson('/api/a/billing_drafts/'.$bill)->assertOk()->json();
|
||||
$this->assertSame($original['data'],$record['data']);
|
||||
$this->assertSame($original['history'],$record['history']);
|
||||
|
||||
Reference in New Issue
Block a user