diff --git a/tests/Feature/Api/V1/IncoSheets/IncoSheetsIndexTest.php b/tests/Feature/Api/V1/IncoSheets/IncoSheetsIndexTest.php index aee93b7..a926559 100644 --- a/tests/Feature/Api/V1/IncoSheets/IncoSheetsIndexTest.php +++ b/tests/Feature/Api/V1/IncoSheets/IncoSheetsIndexTest.php @@ -75,7 +75,7 @@ describe('IncoSheets Index Feature API', function (): void { ['updatedAt', 'Ascending'], ]); - it('returns 200 OK for short projection query', function (): void { + it('returns 200 OK with short form inco sheets when short parameter is true', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; @@ -91,8 +91,49 @@ describe('IncoSheets Index Feature API', function (): void { 'id', 'name', 'label', + 'createdAt', + 'updatedAt', ], ], + 'pagination', ]); + + $firstItem = $response->json('incoSheets.0'); + expect($firstItem) + ->toHaveKeys(['id', 'name', 'label', 'createdAt', 'updatedAt']) + ->and($firstItem)->not->toHaveKey('description') + ->and($firstItem)->not->toHaveKey('allegations') + ->and($firstItem)->not->toHaveKey('ingredients') + ->and($firstItem)->not->toHaveKey('brand'); + }); + + it('returns 200 OK with short form inco sheets when short parameter is numeric 1', function (): void { + // GIVEN + /** @var \Tests\TestCase $test */ + $test = $this; + + // WHEN + $response = $test->getJson('/api/v1/inco-sheets?short=1'); + + // THEN + $response->assertStatus(200); + $response->assertJsonStructure([ + 'incoSheets' => [ + '*' => [ + 'id', + 'name', + 'label', + 'createdAt', + 'updatedAt', + ], + ], + 'pagination', + ]); + + $firstItem = $response->json('incoSheets.0'); + expect($firstItem) + ->toHaveKeys(['id', 'name', 'label', 'createdAt', 'updatedAt']) + ->and($firstItem)->not->toHaveKey('description') + ->and($firstItem)->not->toHaveKey('ingredients'); }); }); diff --git a/tests/Feature/Api/V1/IncoSheets/IncoSheetsSearchTest.php b/tests/Feature/Api/V1/IncoSheets/IncoSheetsSearchTest.php index ed72420..cb0f00f 100644 --- a/tests/Feature/Api/V1/IncoSheets/IncoSheetsSearchTest.php +++ b/tests/Feature/Api/V1/IncoSheets/IncoSheetsSearchTest.php @@ -66,7 +66,7 @@ describe('IncoSheets Search Feature API', function (): void { $response->assertJsonPath('incoSheets.0.id', '1000101'); }); - it('returns 200 OK with short projection when short is true', function (): void { + it('returns 200 OK with short form inco sheets when short parameter is true', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; @@ -89,6 +89,45 @@ describe('IncoSheets Search Feature API', function (): void { ], 'pagination', ]); + + $firstItem = $response->json('incoSheets.0'); + expect($firstItem) + ->toHaveKeys(['id', 'name', 'label', 'createdAt', 'updatedAt']) + ->and($firstItem)->not->toHaveKey('description') + ->and($firstItem)->not->toHaveKey('allegations') + ->and($firstItem)->not->toHaveKey('ingredients') + ->and($firstItem)->not->toHaveKey('brand'); + }); + + it('returns 200 OK with short form inco sheets when short parameter is numeric 1', function (): void { + // GIVEN + /** @var \Tests\TestCase $test */ + $test = $this; + $query = urlencode('%10001%'); + + // WHEN + $response = $test->getJson("/api/v1/inco-sheets/search?incoIdLike={$query}&short=1"); + + // THEN + $response->assertStatus(200); + $response->assertJsonStructure([ + 'incoSheets' => [ + '*' => [ + 'id', + 'name', + 'label', + 'createdAt', + 'updatedAt', + ], + ], + 'pagination', + ]); + + $firstItem = $response->json('incoSheets.0'); + expect($firstItem) + ->toHaveKeys(['id', 'name', 'label', 'createdAt', 'updatedAt']) + ->and($firstItem)->not->toHaveKey('description') + ->and($firstItem)->not->toHaveKey('ingredients'); }); it('returns 200 OK with empty incoSheets list when no matching inco sheets found', function (): void {