feat(editorial): preserve public editions and add QA review workflow
This commit is contained in:
@@ -160,6 +160,82 @@ class OpportunityCanonicalWorkflowTest extends TestCase
|
||||
$this->assertNotNull($response['materiality']);
|
||||
}
|
||||
|
||||
public function test_phase_one_requires_a_new_legal_decision_for_each_content_and_attachment_version(): void
|
||||
{
|
||||
config(['editorial_workflow.enabled' => true]);
|
||||
$this->withoutVite();
|
||||
[$id, $promoter, $validator, $publisher, $payload, $document] = $this->fixture();
|
||||
$this->action($promoter, $id, 'submit');
|
||||
foreach (['property_review', 'registry_urban_review', 'building_compliance_review'] as $gate) {
|
||||
$this->action($validator, $id, 'review_gate', ['gate' => $gate, 'gate_decision' => 'approved', 'evidence_document_ids' => [$document]]);
|
||||
}
|
||||
$this->action($validator, $id, 'approve');
|
||||
$signed = Opportunity::findOrFail($id)->workflow_context['reviews']['registry_urban_review'];
|
||||
$this->action($promoter, $id, 'request_revision');
|
||||
$payload['official_title'] .= ' — edição privada da Fase 1';
|
||||
$this->loginFixture($promoter)->putJson('/minhas-oportunidades/'.$id.'/draft', ['etag' => app(OpportunityManagement::class)->etag(Opportunity::findOrFail($id)), 'canonical' => $payload, 'reason' => self::REASON])->assertOk();
|
||||
$this->action($promoter, $id, 'submit');
|
||||
$context = Opportunity::findOrFail($id)->workflow_context;
|
||||
$this->assertContains('registry_urban_review', $context['materiality']['reopened']);
|
||||
$this->assertArrayNotHasKey('registry_urban_review', $context['reviews']);
|
||||
$this->assertSame($signed['hash'], $context['decision_history'][0]['reviews']['registry_urban_review']['hash']);
|
||||
$this->action($validator, $id, 'approve', [], 422);
|
||||
$this->action($validator, $id, 'review_gate', ['gate' => 'registry_urban_review', 'gate_decision' => 'approved', 'evidence_document_ids' => [$document]]);
|
||||
$this->action($validator, $id, 'approve');
|
||||
$this->action($publisher, $id, 'assign_publication', ['assignee_user_id' => $publisher->id]);
|
||||
$file = DB::table('opportunity_documents')->where('id', $document)->value('document_id');
|
||||
DB::table('documents')->where('id', $file)->increment('version_no');
|
||||
$this->action($publisher, $id, 'publish', [], 409);
|
||||
}
|
||||
|
||||
public function test_phase_one_activation_preserves_an_approved_legacy_submission_without_rewriting_its_hash(): void
|
||||
{
|
||||
config(['editorial_workflow.enabled' => false]);
|
||||
$this->withoutVite();
|
||||
[$id, $promoter, $validator, $publisher, , $document] = $this->fixture();
|
||||
$this->action($promoter, $id, 'submit');
|
||||
foreach (['property_review', 'registry_urban_review', 'building_compliance_review'] as $gate) {
|
||||
$this->action($validator, $id, 'review_gate', ['gate' => $gate, 'gate_decision' => 'approved', 'evidence_document_ids' => [$document]]);
|
||||
}
|
||||
$this->action($validator, $id, 'approve');
|
||||
$approved = Opportunity::findOrFail($id)->workflow_context['approval']['hash'];
|
||||
config(['editorial_workflow.enabled' => true]);
|
||||
$this->action($publisher, $id, 'assign_publication', ['assignee_user_id' => $publisher->id]);
|
||||
$this->action($publisher, $id, 'publish');
|
||||
$record = Opportunity::findOrFail($id);
|
||||
$this->assertSame('published', $record->status);
|
||||
$this->assertSame($approved, $record->workflow_context['approval']['hash']);
|
||||
$this->assertArrayNotHasKey('editorial_version_binding', $record->workflow_context);
|
||||
}
|
||||
|
||||
public function test_phase_one_opportunity_notices_follow_current_access_and_do_not_grant_resource_access(): void
|
||||
{
|
||||
config(['editorial_workflow.enabled' => true]);
|
||||
$this->withoutVite();
|
||||
[$id, $promoter, $validator] = $this->fixture();
|
||||
$this->action($promoter, $id, 'submit');
|
||||
$this->action($validator, $id, 'start_review');
|
||||
$notice = DB::table('portal_editorial_notifications')->where('user_id', $promoter->id)->where('opportunity_id', $id)->first();
|
||||
$this->assertNotNull($notice);
|
||||
$this->assertNotNull($notice->opportunity_version);
|
||||
$data = $this->loginFixture($promoter)->getJson('/management/editorial')->assertOk()->assertJsonPath('resourceAccess', false)->assertJsonPath('items.total', 0)->json();
|
||||
$this->assertNotEmpty($data['notices']);
|
||||
$this->assertSame('/minhas-oportunidades/'.$id, $data['notices'][0]['href']);
|
||||
$this->postJson('/management/editorial/notices/'.$notice->id.'/read')->assertOk();
|
||||
$this->assertNotNull(DB::table('portal_editorial_notifications')->where('id', $notice->id)->value('read_at'));
|
||||
$administrator = User::factory()->create();
|
||||
config(['portal.managers' => [$administrator->email]]);
|
||||
DB::table('portal_editorial_notifications')->insert(['user_id' => $administrator->id, 'edition_id' => null, 'opportunity_id' => $id,
|
||||
'opportunity_version' => $notice->opportunity_version, 'action' => 'start_review', 'created_at' => now()]);
|
||||
$this->loginFixture($administrator)->getJson('/management/editorial')->assertOk()->assertJsonPath('resourceAccess', true)->assertJsonPath('notices', [])->assertJsonPath('opportunityPending', 0);
|
||||
$adminNotice = DB::table('portal_editorial_notifications')->where('user_id', $administrator->id)->value('id');
|
||||
$this->postJson('/management/editorial/notices/'.$adminNotice.'/read')->assertNotFound();
|
||||
$this->loginFixture($promoter);
|
||||
DB::table('portal_role_assignments')->where('user_id', $promoter->id)->update(['revoked_at' => now()]);
|
||||
$this->getJson('/management/editorial')->assertForbidden();
|
||||
$this->postJson('/management/editorial/notices/'.$notice->id.'/read')->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_geometry_order_is_material_and_object_key_order_is_not(): void
|
||||
{
|
||||
$materiality = app(OpportunityReviewMateriality::class);
|
||||
|
||||
Reference in New Issue
Block a user