mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:04:16 -04:00
update timeline tests
This commit is contained in:
parent
85359bfc1a
commit
3ace02b3e7
@ -150,20 +150,20 @@ describe('/timeline', () => {
|
|||||||
expect(status).toBe(200);
|
expect(status).toBe(200);
|
||||||
expect(body).toEqual({
|
expect(body).toEqual({
|
||||||
bucketAssets: {
|
bucketAssets: {
|
||||||
description: [],
|
city: [],
|
||||||
|
country: [],
|
||||||
duration: [],
|
duration: [],
|
||||||
id: [],
|
id: [],
|
||||||
isArchived: [],
|
isArchived: [],
|
||||||
isFavorite: [],
|
isFavorite: [],
|
||||||
isImage: [],
|
isImage: [],
|
||||||
isTrashed: [],
|
isTrashed: [],
|
||||||
isVideo: [],
|
|
||||||
livePhotoVideoId: [],
|
livePhotoVideoId: [],
|
||||||
localDateTime: [],
|
localDateTime: [],
|
||||||
ownerId: [],
|
ownerId: [],
|
||||||
projectionType: [],
|
projectionType: [],
|
||||||
ratio: [],
|
ratio: [],
|
||||||
stack: [],
|
status: [],
|
||||||
thumbhash: [],
|
thumbhash: [],
|
||||||
},
|
},
|
||||||
hasNextPage: false,
|
hasNextPage: false,
|
||||||
@ -190,7 +190,8 @@ describe('/timeline', () => {
|
|||||||
expect(status).toBe(200);
|
expect(status).toBe(200);
|
||||||
expect(body).toEqual({
|
expect(body).toEqual({
|
||||||
bucketAssets: {
|
bucketAssets: {
|
||||||
description: [],
|
city: [],
|
||||||
|
country: [],
|
||||||
duration: [],
|
duration: [],
|
||||||
id: [],
|
id: [],
|
||||||
isArchived: [],
|
isArchived: [],
|
||||||
@ -203,7 +204,7 @@ describe('/timeline', () => {
|
|||||||
ownerId: [],
|
ownerId: [],
|
||||||
projectionType: [],
|
projectionType: [],
|
||||||
ratio: [],
|
ratio: [],
|
||||||
stack: [],
|
status: [],
|
||||||
thumbhash: [],
|
thumbhash: [],
|
||||||
},
|
},
|
||||||
hasNextPage: false,
|
hasNextPage: false,
|
||||||
|
@ -27,30 +27,23 @@ describe(TimelineService.name, () => {
|
|||||||
describe('getTimeBucket', () => {
|
describe('getTimeBucket', () => {
|
||||||
it('should return the assets for a album time bucket if user has album.read', async () => {
|
it('should return the assets for a album time bucket if user has album.read', async () => {
|
||||||
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-id']));
|
mocks.access.album.checkOwnerAccess.mockResolvedValue(new Set(['album-id']));
|
||||||
mocks.asset.getTimeBucket.mockResolvedValue([{ id: 'asset-id' } as any]);
|
const json = `[{ id: ['asset-id'] }]`;
|
||||||
|
mocks.asset.getTimeBucket.mockResolvedValue({ assets: json });
|
||||||
|
|
||||||
await expect(sut.getTimeBucket(authStub.admin, { timeBucket: 'bucket', albumId: 'album-id' })).resolves.toEqual(
|
await expect(sut.getTimeBucket(authStub.admin, { timeBucket: 'bucket', albumId: 'album-id' })).resolves.toEqual(
|
||||||
expect.objectContaining({
|
json,
|
||||||
bucketAssets: expect.objectContaining({ id: expect.arrayContaining(['asset-id']) }),
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(mocks.access.album.checkOwnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['album-id']));
|
expect(mocks.access.album.checkOwnerAccess).toHaveBeenCalledWith(authStub.admin.user.id, new Set(['album-id']));
|
||||||
expect(mocks.asset.getTimeBucket).toHaveBeenCalledWith(
|
expect(mocks.asset.getTimeBucket).toHaveBeenCalledWith('bucket', {
|
||||||
'bucket',
|
timeBucket: 'bucket',
|
||||||
{
|
albumId: 'album-id',
|
||||||
timeBucket: 'bucket',
|
});
|
||||||
albumId: 'album-id',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
skip: 1,
|
|
||||||
take: -1,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the assets for a archive time bucket if user has archive.read', async () => {
|
it('should return the assets for a archive time bucket if user has archive.read', async () => {
|
||||||
mocks.asset.getTimeBucket.mockResolvedValue([{ id: 'asset-id' } as any]);
|
const json = `[{ id: ['asset-id'] }]`;
|
||||||
|
mocks.asset.getTimeBucket.mockResolvedValue({ assets: json });
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
sut.getTimeBucket(authStub.admin, {
|
sut.getTimeBucket(authStub.admin, {
|
||||||
@ -58,11 +51,7 @@ describe(TimelineService.name, () => {
|
|||||||
isArchived: true,
|
isArchived: true,
|
||||||
userId: authStub.admin.user.id,
|
userId: authStub.admin.user.id,
|
||||||
}),
|
}),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(json);
|
||||||
expect.objectContaining({
|
|
||||||
bucketAssets: expect.objectContaining({ id: expect.arrayContaining(['asset-id']) }),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
expect(mocks.asset.getTimeBucket).toHaveBeenCalledWith(
|
expect(mocks.asset.getTimeBucket).toHaveBeenCalledWith(
|
||||||
'bucket',
|
'bucket',
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
@ -70,15 +59,12 @@ describe(TimelineService.name, () => {
|
|||||||
isArchived: true,
|
isArchived: true,
|
||||||
userIds: [authStub.admin.user.id],
|
userIds: [authStub.admin.user.id],
|
||||||
}),
|
}),
|
||||||
{
|
|
||||||
skip: 1,
|
|
||||||
take: -1,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should include partner shared assets', async () => {
|
it('should include partner shared assets', async () => {
|
||||||
mocks.asset.getTimeBucket.mockResolvedValue([{ id: 'asset-id' } as any]);
|
const json = `[{ id: ['asset-id'] }]`;
|
||||||
|
mocks.asset.getTimeBucket.mockResolvedValue({ assets: json });
|
||||||
mocks.partner.getAll.mockResolvedValue([]);
|
mocks.partner.getAll.mockResolvedValue([]);
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
@ -88,28 +74,18 @@ describe(TimelineService.name, () => {
|
|||||||
userId: authStub.admin.user.id,
|
userId: authStub.admin.user.id,
|
||||||
withPartners: true,
|
withPartners: true,
|
||||||
}),
|
}),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(json);
|
||||||
expect.objectContaining({
|
expect(mocks.asset.getTimeBucket).toHaveBeenCalledWith('bucket', {
|
||||||
bucketAssets: expect.objectContaining({ id: expect.arrayContaining(['asset-id']) }),
|
timeBucket: 'bucket',
|
||||||
}),
|
isArchived: false,
|
||||||
);
|
withPartners: true,
|
||||||
expect(mocks.asset.getTimeBucket).toHaveBeenCalledWith(
|
userIds: [authStub.admin.user.id],
|
||||||
'bucket',
|
});
|
||||||
{
|
|
||||||
timeBucket: 'bucket',
|
|
||||||
isArchived: false,
|
|
||||||
withPartners: true,
|
|
||||||
userIds: [authStub.admin.user.id],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
skip: 1,
|
|
||||||
take: -1,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should check permissions to read tag', async () => {
|
it('should check permissions to read tag', async () => {
|
||||||
mocks.asset.getTimeBucket.mockResolvedValue([{ id: 'asset-id' } as any]);
|
const json = `[{ id: ['asset-id'] }]`;
|
||||||
|
mocks.asset.getTimeBucket.mockResolvedValue({ assets: json });
|
||||||
mocks.access.tag.checkOwnerAccess.mockResolvedValue(new Set(['tag-123']));
|
mocks.access.tag.checkOwnerAccess.mockResolvedValue(new Set(['tag-123']));
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
@ -118,48 +94,30 @@ describe(TimelineService.name, () => {
|
|||||||
userId: authStub.admin.user.id,
|
userId: authStub.admin.user.id,
|
||||||
tagId: 'tag-123',
|
tagId: 'tag-123',
|
||||||
}),
|
}),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(json);
|
||||||
expect.objectContaining({
|
expect(mocks.asset.getTimeBucket).toHaveBeenCalledWith('bucket', {
|
||||||
bucketAssets: expect.objectContaining({ id: expect.arrayContaining(['asset-id']) }),
|
tagId: 'tag-123',
|
||||||
}),
|
timeBucket: 'bucket',
|
||||||
);
|
userIds: [authStub.admin.user.id],
|
||||||
expect(mocks.asset.getTimeBucket).toHaveBeenCalledWith(
|
});
|
||||||
'bucket',
|
|
||||||
{
|
|
||||||
tagId: 'tag-123',
|
|
||||||
timeBucket: 'bucket',
|
|
||||||
userIds: [authStub.admin.user.id],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
skip: 1,
|
|
||||||
take: -1,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the assets for a library time bucket if user has library.read', async () => {
|
it('should return the assets for a library time bucket if user has library.read', async () => {
|
||||||
mocks.asset.getTimeBucket.mockResolvedValue([{ id: 'asset-id' } as any]);
|
const json = `[{ id: ['asset-id'] }]`;
|
||||||
|
mocks.asset.getTimeBucket.mockResolvedValue({ assets: json });
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
sut.getTimeBucket(authStub.admin, {
|
sut.getTimeBucket(authStub.admin, {
|
||||||
timeBucket: 'bucket',
|
timeBucket: 'bucket',
|
||||||
userId: authStub.admin.user.id,
|
userId: authStub.admin.user.id,
|
||||||
}),
|
}),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(json);
|
||||||
expect.objectContaining({
|
|
||||||
bucketAssets: expect.objectContaining({ id: expect.arrayContaining(['asset-id']) }),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
expect(mocks.asset.getTimeBucket).toHaveBeenCalledWith(
|
expect(mocks.asset.getTimeBucket).toHaveBeenCalledWith(
|
||||||
'bucket',
|
'bucket',
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
timeBucket: 'bucket',
|
timeBucket: 'bucket',
|
||||||
userIds: [authStub.admin.user.id],
|
userIds: [authStub.admin.user.id],
|
||||||
}),
|
}),
|
||||||
{
|
|
||||||
skip: 1,
|
|
||||||
take: -1,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user