mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-04 12:29:43 +00:00
Fix re-ordering of StoredObjectVersion in the list of versions
As some intermediate versions are remove, this may lead to situation where the indexes are not continous. In that case, the array is not a list, and is rendered as an array with numeric indexes, instead of a list of elements. The HistoryListItem component fails to render. - Ensured proper handling of removed versions by using `array_values` to reindex items. - Added test case to validate the result after removing a version. - Asserted the results are a proper list in the API response.
This commit is contained in:
6
.changes/unreleased/Fixed-20251003-224044.yaml
Normal file
6
.changes/unreleased/Fixed-20251003-224044.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
kind: Fixed
|
||||
body: Fix the rendering of list of StoredObjectVersions, where there are kept version (before converting to pdf) and intermediate versions deleted
|
||||
time: 2025-10-03T22:40:44.685474863+02:00
|
||||
custom:
|
||||
Issue: ""
|
||||
SchemaChange: No schema change
|
@@ -59,7 +59,7 @@ final readonly class StoredObjectVersionApiController
|
||||
|
||||
return new JsonResponse(
|
||||
$this->serializer->serialize(
|
||||
new Collection($items, $paginator),
|
||||
new Collection(array_values($items->toArray()), $paginator),
|
||||
'json',
|
||||
[AbstractNormalizer::GROUPS => ['read', StoredObjectVersionNormalizer::WITH_POINT_IN_TIMES_CONTEXT, StoredObjectVersionNormalizer::WITH_RESTORED_CONTEXT]]
|
||||
),
|
||||
|
@@ -40,6 +40,10 @@ class StoredObjectVersionApiControllerTest extends \PHPUnit\Framework\TestCase
|
||||
$storedObject->registerVersion();
|
||||
}
|
||||
|
||||
// remove one version in the history
|
||||
$v5 = $storedObject->getVersions()->get(5);
|
||||
$storedObject->removeVersion($v5);
|
||||
|
||||
$security = $this->prophesize(Security::class);
|
||||
$security->isGranted(StoredObjectRoleEnum::SEE->value, $storedObject)
|
||||
->willReturn(true)
|
||||
@@ -53,6 +57,7 @@ class StoredObjectVersionApiControllerTest extends \PHPUnit\Framework\TestCase
|
||||
self::assertEquals($response->getStatusCode(), 200);
|
||||
self::assertIsArray($body);
|
||||
self::assertArrayHasKey('results', $body);
|
||||
self::assertIsList($body['results']);
|
||||
self::assertCount(10, $body['results']);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user