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:
parent
91114cb67b
commit
7383c3e01f
2 changed files with 82 additions and 2 deletions
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue