fix(server): stack info in asset response for mobile (#7346)

* fix(server): stack info in asset response for mobile

* fix(server): getAllAssets - do not filter by stack ID

* tet(server): GET /assets stack e2e

* chore(server): fix checks

* stack asset height

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
Alex
2024-03-05 23:44:56 -06:00
committed by GitHub
parent 4c0bb2308c
commit 52dfe5fc92
7 changed files with 37 additions and 24 deletions

View File

@@ -14,6 +14,7 @@ import { AssetEntity, AssetStackEntity, AssetType, SharedLinkType } from '@app/i
import { AssetRepository } from '@app/infra/repositories';
import { INestApplication } from '@nestjs/common';
import { errorStub, userDto, uuidStub } from '@test/fixtures';
import { assetApi } from 'e2e/client/asset-api';
import { randomBytes } from 'node:crypto';
import request from 'supertest';
import { api } from '../../client';
@@ -532,6 +533,23 @@ describe(`${AssetController.name} (e2e)`, () => {
}
});
}
it('should return stack data', async () => {
const parentId = asset1.id;
const childIds = [asset2.id, asset3.id];
await request(server)
.put('/asset')
.set('Authorization', `Bearer ${user1.accessToken}`)
.send({ stackParentId: parentId, ids: childIds });
const body = await assetApi.getAllAssets(server, user1.accessToken);
// Response includes parent with stack children count
const parentDto = body.find((a) => a.id == parentId);
expect(parentDto?.stackCount).toEqual(3);
// Response includes children at the root level
expect.arrayContaining([expect.objectContaining({ id: asset1.id }), expect.objectContaining({ id: asset2.id })]);
});
});
describe('POST /asset/upload', () => {