test(IncoSheets): update tests for short form inco sheets response

Enhance tests to verify the structure of inco sheets when the short parameter is true or numeric 1.
This commit is contained in:
Jérémy Munsch 2026-08-14 15:57:58 +02:00
parent 91114cb67b
commit 7383c3e01f
Signed by: forge-joniko
GPG key ID: D7EFE2F5CB6CC0E4
2 changed files with 82 additions and 2 deletions

View file

@ -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');
});
});

View file

@ -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 {