Feature/permission users phases btn#409
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
resources/js/Pages/ProjectDetails/Partials/Tabs/OpeningTab.vue (1)
60-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
computed()forstageto match sibling tabs.
stageis declared as a plainconst(line 62), whileLegalAnalysisTab,FormalizationTab, andBudgetTaball usecomputed(() => ...)for the same pattern. This inconsistency could cause stale data ifprops.project.stageschanges without a full component remount.♻️ Proposed fix
-const stage = props.project.stages?.find((s) => s.slug === STAGE_SLUG); +const stage = computed(() => props.project.stages?.find((s) => s.slug === STAGE_SLUG));🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@resources/js/Pages/ProjectDetails/Partials/Tabs/OpeningTab.vue` around lines 60 - 64, Update the stage lookup in OpeningTab around STAGE_SLUG and stage to use computed(), matching the reactive pattern in the sibling tabs, while preserving the existing slug-based search and stage value usage.app/Http/Controllers/ProjectStageController.php (1)
50-52: 🩺 Stability & Availability | 🔵 TrivialAvoid reporting routine authorization denials as Sentry exceptions.
AuthorizationExceptionis an expected permission-failure path fromapp/Services/ProjectStageService.php, Lines 151-156. Capturing every denied transition can flood Sentry and obscure actionable failures; prefer an audit/metric event or configure this exception class to be filtered before capture.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/Http/Controllers/ProjectStageController.php` around lines 50 - 52, Update the AuthorizationException catch block in ProjectStageController so routine permission denials are not sent to Sentry via captureException. Replace that reporting with the existing audit or metric mechanism, or filter AuthorizationException from Sentry while preserving the current authorization-failure response behavior.tests/Feature/ProjectStageControllerTest.php (1)
235-246: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAssert that failed validation leaves each stage unchanged.
These tests verify the error text but not state preservation. Capture the initial status before the request and assert it after the response so a partial stage transition cannot regress unnoticed.
Suggested assertions
$stage = $project->stages() ->where('slug', ProjectStageSlug::ANALISE_JURIDICA->value) ->firstOrFail(); + $initialStatus = $stage->status; ... ->assertSessionHasErrors(['message' => 'A etapa precisa estar em andamento para ser aprovada.']); + + $this->assertEquals($initialStatus, $stage->fresh()->status);Apply the same assertion to both tests.
Also applies to: 248-259
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/Feature/ProjectStageControllerTest.php` around lines 235 - 246, Update both stage-advance tests, including test_advance_returns_specific_message_when_stage_not_em_andamento, to capture each relevant stage’s status before the PATCH request and assert afterward that the status is unchanged. Keep the existing validation-message assertions and apply the state-preservation check to every stage covered by these tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/Services/ProjectStageService.php`:
- Around line 116-119: Update returnStage so the
ProjectStageStatus::EM_ANDAMENTO validation occurs before ensureUserHasRole.
Preserve both existing validations and their exception messages, matching the
ordering used by advance and reject.
---
Nitpick comments:
In `@app/Http/Controllers/ProjectStageController.php`:
- Around line 50-52: Update the AuthorizationException catch block in
ProjectStageController so routine permission denials are not sent to Sentry via
captureException. Replace that reporting with the existing audit or metric
mechanism, or filter AuthorizationException from Sentry while preserving the
current authorization-failure response behavior.
In `@resources/js/Pages/ProjectDetails/Partials/Tabs/OpeningTab.vue`:
- Around line 60-64: Update the stage lookup in OpeningTab around STAGE_SLUG and
stage to use computed(), matching the reactive pattern in the sibling tabs,
while preserving the existing slug-based search and stage value usage.
In `@tests/Feature/ProjectStageControllerTest.php`:
- Around line 235-246: Update both stage-advance tests, including
test_advance_returns_specific_message_when_stage_not_em_andamento, to capture
each relevant stage’s status before the PATCH request and assert afterward that
the status is unchanged. Keep the existing validation-message assertions and
apply the state-preservation check to every stage covered by these tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5306c8ab-12f7-43b1-9a76-381c1e10165f
📒 Files selected for processing (14)
app/Http/Controllers/ProjectController.phpapp/Http/Controllers/ProjectStageController.phpapp/Services/ProjectStageService.phpresources/js/Composables/useStageAdvance.jsresources/js/Pages/ProjectDetails/Index.vueresources/js/Pages/ProjectDetails/Partials/ProcessTabs.vueresources/js/Pages/ProjectDetails/Partials/Tabs/BudgetTab.vueresources/js/Pages/ProjectDetails/Partials/Tabs/FormalizationTab.vueresources/js/Pages/ProjectDetails/Partials/Tabs/LegalAnalysisTab.vueresources/js/Pages/ProjectDetails/Partials/Tabs/MonitoringTab.vueresources/js/Pages/ProjectDetails/Partials/Tabs/OpeningTab.vueresources/js/Pages/ProjectDetails/Partials/Tabs/PaymentTab.vuetests/Feature/ProjectControllerTest.phptests/Feature/ProjectStageControllerTest.php
✅ Descrição do propósito desse Pull Request
Validando permissao para TRAMITAR e DEVOLVER no backend
🧭 Referência a Issue
#400
❓ O que foi feito para atingir isso?
🏃♀️ Tipo de mudança
Marque as opções relevantes:
🕵️ Como foi testado?
Checklist: ✔️
Observação:
Summary by CodeRabbit
New Features
Bug Fixes