This commit is contained in:
2026-11-03 11:51:44 +02:00
parent badaada043
commit e753f7a0a4
309 changed files with 14537 additions and 529 deletions
+27
View File
@@ -8,6 +8,7 @@ use App\Services\RequisitionCatalogue;
use App\Services\RequisitionWorkflow;
use App\Services\WarehouseFulfilment;
use App\Services\WarehouseRequests;
use App\Services\WorkflowTaskInbox;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Inertia\Testing\AssertableInertia as Assert;
@@ -38,6 +39,32 @@ function taskInboxRequest($test, string $quantity = '4.000'): void
taskInboxCommand($test, $test->f['issuer'], 'submit', ['partial_allowed' => true]);
}
test('task deadline filtering uses the whole authorised projection before pagination and preserves module search scope', function () {
$this->travelTo(now()->startOfDay()->addHours(23)->addMinutes(59));
$rows = [];
for ($i = 0; $i < 28; $i++) {
$rows[] = ['id' => 'deadline:'.$i, 'module' => 'supply', 'reference' => 'PRAZO-'.$i, 'label' => 'Acompanhar origem existente', 'blocked' => false,
'created_at' => now()->subMonth()->toIso8601String(), 'due_on' => today()->subDay()->toDateString(), 'href' => '/compras/fornecimento?view=reservations'];
}
foreach (['today' => today()->toDateString(), 'upcoming' => today()->addDay()->toDateString(), 'undated' => null] as $status => $date) {
$rows[] = [...$rows[0], 'id' => 'deadline:'.$status, 'reference' => 'PRAZO-'.$status, 'due_on' => $date];
}
$rows[] = [...$rows[0], 'id' => 'other', 'module' => 'warehouse', 'reference' => 'OUTRO'];
$this->mock(WorkflowTaskInbox::class)->shouldReceive('build')->andReturn($rows);
$this->get('/requisicoes/tarefas?module=supply&due=overdue')->assertInertia(fn (Assert $p) => $p
->where('tasks.total', 28)->has('tasks.data', 25)->where('tasks.data.0.due_status', 'overdue')
->where('deadlineCounts.overdue', 28)->where('deadlineCounts.today', 1)->where('deadlineCounts.upcoming', 1)->where('deadlineCounts.undated', 1)
->where('counts.warehouse', 1)->where('asOf', today()->toDateString())->where('filters.due', 'overdue')
->where('tasks.next_page_url', fn ($url) => str_contains($url, 'due=overdue') && str_contains($url, 'module=supply')));
$this->get('/requisicoes/tarefas?module=supply&due=overdue&page=2')->assertInertia(fn (Assert $p) => $p->has('tasks.data', 3)->where('tasks.data.0.id', 'deadline:25'));
foreach (['today', 'upcoming', 'undated'] as $status) {
$this->get('/requisicoes/tarefas?module=supply&due='.$status)->assertInertia(fn (Assert $p) => $p->where('tasks.total', 1)->where('tasks.data.0.due_status', $status));
}
$this->get('/requisicoes/tarefas?module=supply&search=PRAZO-today&due=overdue')->assertInertia(fn (Assert $p) => $p
->where('tasks.total', 0)->where('deadlineCounts.today', 1)->where('deadlineCounts.overdue', 0));
$this->getJson('/requisicoes/tarefas?due=invalid')->assertUnprocessable();
});
function taskInboxCommand($test, User $actor, string $action, array $extra = [])
{
$test->actingAs($actor);