commit melhorias compras3
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-11-22 10:56:58 +02:00
parent 4fac443dda
commit efd97e265b
130 changed files with 8917 additions and 363 deletions
+16
View File
@@ -228,6 +228,22 @@ test('procurement reading distinguishes submission age need dates and incomplete
expect(AuditLog::query()->count())->toBe($audits);
});
test('approval duration uses complete native decisions and filters without inventing missing dates', function () {
$this->travelTo(CarbonImmutable::parse('2026-11-22 12:00:00'));
$before = AuditLog::query()->count();
foreach ([['FAST', '2026-11-21 13:00:00'], ['SLOW', '2026-11-21 15:00:00'], ['FUTURE', '2026-11-23 12:00:00'], ['REVERSED', '2026-11-20 12:00:00']] as [$number, $date]) {
$r = reportCopy($this->f['r'], 'DURATION-'.$number, ['status' => 'approved', 'submitted_at' => '2026-11-21 12:00:00']);
$r->steps()->create(['tenant_id' => $r->tenant_id, 'position' => 1, 'role' => 'department_head', 'decision' => 'approved', 'decided_at' => $date]);
}
reportCopy($this->f['r'], 'DURATION-MISSING', ['status' => 'approved', 'submitted_at' => null]);
$this->get('/relatorios?search=DURATION')->assertInertia(fn (Assert $page) => $page
->where('insights.approval_times.measured', 2)->where('insights.approval_times.unknown', 3)
->where('insights.approval_times.total_seconds', 14400)->where('insights.approval_times.min_seconds', 3600)->where('insights.approval_times.max_seconds', 10800));
$this->get('/relatorios?search=DURATION-MISSING')->assertInertia(fn (Assert $page) => $page
->where('insights.approval_times.measured', 0)->where('insights.approval_times.unknown', 1)->where('insights.approval_times.min_seconds', null));
expect(AuditLog::query()->count())->toBe($before);
});
test('reports reject invalid filters on both the screen and export', function () {
foreach (['status=unknown', 'from=invalid', 'from=2026-02-02&to=2026-01-01', 'department_id=-1'] as $filter) {
$this->getJson('/relatorios?'.$filter)->assertUnprocessable();