Skip to content

A free open source IT asset/license management system

Updated tests

snipe9c13951d32b7
diff --git a/tests/Feature/Requests/Ui/AccessoryRequestTest.php b/tests/Feature/Requests/Ui/AccessoryRequestTest.php
index 99f63d8214..026d8f7cbf 100644
--- a/tests/Feature/Requests/Ui/AccessoryRequestTest.php
+++ b/tests/Feature/Requests/Ui/AccessoryRequestTest.php
@@ -11,14 +11,28 @@ class AccessoryRequestTest extends TestCase
{
public function test_requestable_index_lists_requestable_accessories(): void
{
- $accessory = Accessory::factory()->create(['requestable' => true]);
- Accessory::factory()->create(['requestable' => false]);
+ // The accessories tab on /account/requestable-assets is now
+ // API-backed via api.accessories.requestable. Shell page still
+ // needs a non-empty $accessories view var so the tab-badge
+ // count renders (0 hides the tab entirely), and the API row
+ // shape has to include the requestable one + omit the
+ // non-requestable one.
+ $requestableAccessory = Accessory::factory()->create(['requestable' => true]);
+ $nonRequestable = Accessory::factory()->create(['requestable' => false]);
$this->actingAs(User::factory()->create())
->get(route('requestable-assets'))
->assertOk()
- ->assertViewHas('accessories')
- ->assertSeeText($accessory->name);
+ ->assertViewHas('accessories');
+
+ $rows = $this->actingAsForApi(User::factory()->create())
+ ->getJson(route('api.accessories.requestable'))
+ ->assertOk()
+ ->json('rows');
+
+ $ids = collect($rows)->pluck('id')->all();
+ $this->assertContains($requestableAccessory->id, $ids);
+ $this->assertNotContains($nonRequestable->id, $ids);
}
public function test_user_can_request_a_requestable_accessory(): void
diff --git a/tests/Feature/Requests/Ui/ConsumableRequestTest.php b/tests/Feature/Requests/Ui/ConsumableRequestTest.php
index b1acebd2c5..95ca5ce1f9 100644
--- a/tests/Feature/Requests/Ui/ConsumableRequestTest.php
+++ b/tests/Feature/Requests/Ui/ConsumableRequestTest.php
@@ -18,14 +18,25 @@ class ConsumableRequestTest extends TestCase
{
public function test_requestable_index_lists_requestable_consumables(): void
{
- $consumable = Consumable::factory()->create(['requestable' => true]);
- Consumable::factory()->create(['requestable' => false]);
+ // The consumables tab on /account/requestable-assets is now
+ // API-backed via api.consumables.requestable. See the sibling
+ // AccessoryRequestTest for the shell-page + API-shape rationale.
+ $requestable = Consumable::factory()->create(['requestable' => true]);
+ $nonRequestable = Consumable::factory()->create(['requestable' => false]);
$this->actingAs(User::factory()->create())
->get(route('requestable-assets'))
->assertOk()
- ->assertViewHas('consumables')
- ->assertSeeText($consumable->name);
+ ->assertViewHas('consumables');
+
+ $rows = $this->actingAsForApi(User::factory()->create())
+ ->getJson(route('api.consumables.requestable'))
+ ->assertOk()
+ ->json('rows');
+
+ $ids = collect($rows)->pluck('id')->all();
+ $this->assertContains($requestable->id, $ids);
+ $this->assertNotContains($nonRequestable->id, $ids);
}
public function test_user_can_request_a_requestable_consumable(): void