Added tests for due-or-overdue

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-04-26 20:59:04 +01:00
parent fc61a4b88d
commit 494ec5cd9c

View file

@ -65,6 +65,25 @@ class AssetIndexTest extends TestCase
}
public function testAssetApiIndexReturnsDueOrOverdueForAudit()
{
Asset::factory()->count(3)->create(['next_audit_date' => Carbon::now()->format('Y-m-d')]);
Asset::factory()->count(2)->create(['next_audit_date' => Carbon::now()->subDays(1)->format('Y-m-d')]);
$this->assertTrue(Asset::count() === 5);
$this->actingAsForApi(User::factory()->superuser()->create())
->getJson(
route('api.assets.list-upcoming', ['action' => 'audits', 'upcoming_status' => 'due-or-overdue']))
->assertOk()
->assertJsonStructure([
'total',
'rows',
])
->assertJson(fn(AssertableJson $json) => $json->has('rows', 5)->etc());
}
public function testAssetApiIndexReturnsDueForExpectedCheckin()
{
@ -100,6 +119,23 @@ class AssetIndexTest extends TestCase
->assertJson(fn(AssertableJson $json) => $json->has('rows', 3)->etc());
}
public function testAssetApiIndexReturnsDueOrOverdueForExpectedCheckin()
{
Asset::factory()->count(3)->create(['assigned_to' => '1', 'expected_checkin' => Carbon::now()->subDays(1)->format('Y-m-d')]);
Asset::factory()->count(2)->create(['assigned_to' => '1', 'expected_checkin' => Carbon::now()->format('Y-m-d')]);
$this->assertTrue(Asset::count() === 5);
$this->actingAsForApi(User::factory()->superuser()->create())
->getJson(route('api.assets.list-upcoming', ['action' => 'checkins', 'upcoming_status' => 'due-or-overdue']))
->assertOk()
->assertJsonStructure([
'total',
'rows',
])
->assertJson(fn(AssertableJson $json) => $json->has('rows', 5)->etc());
}
public function testAssetApiIndexAdheresToCompanyScoping()
{
[$companyA, $companyB] = Company::factory()->count(2)->create();