mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat: audit cleanup (#21567)
This commit is contained in:
parent
af1e18d07e
commit
28179a3a1d
40 changed files with 839 additions and 299 deletions
|
|
@ -24,7 +24,6 @@ describe(SyncEntityType.PersonV1, () => {
|
|||
const { person } = await ctx.newPerson({ ownerId: auth.user.id });
|
||||
|
||||
const response = await ctx.syncStream(auth, [SyncRequestType.PeopleV1]);
|
||||
expect(response).toHaveLength(1);
|
||||
expect(response).toEqual([
|
||||
{
|
||||
ack: expect.any(String),
|
||||
|
|
@ -40,10 +39,11 @@ describe(SyncEntityType.PersonV1, () => {
|
|||
}),
|
||||
type: 'PersonV1',
|
||||
},
|
||||
expect.objectContaining({ type: SyncEntityType.SyncCompleteV1 }),
|
||||
]);
|
||||
|
||||
await ctx.syncAckAll(auth, response);
|
||||
await expect(ctx.syncStream(auth, [SyncRequestType.PeopleV1])).resolves.toEqual([]);
|
||||
await ctx.assertSyncIsComplete(auth, [SyncRequestType.PeopleV1]);
|
||||
});
|
||||
|
||||
it('should detect and sync a deleted person', async () => {
|
||||
|
|
@ -53,7 +53,6 @@ describe(SyncEntityType.PersonV1, () => {
|
|||
await personRepo.delete([person.id]);
|
||||
|
||||
const response = await ctx.syncStream(auth, [SyncRequestType.PeopleV1]);
|
||||
expect(response).toHaveLength(1);
|
||||
expect(response).toEqual([
|
||||
{
|
||||
ack: expect.any(String),
|
||||
|
|
@ -62,10 +61,11 @@ describe(SyncEntityType.PersonV1, () => {
|
|||
},
|
||||
type: 'PersonDeleteV1',
|
||||
},
|
||||
expect.objectContaining({ type: SyncEntityType.SyncCompleteV1 }),
|
||||
]);
|
||||
|
||||
await ctx.syncAckAll(auth, response);
|
||||
await expect(ctx.syncStream(auth, [SyncRequestType.PeopleV1])).resolves.toEqual([]);
|
||||
await ctx.assertSyncIsComplete(auth, [SyncRequestType.PeopleV1]);
|
||||
});
|
||||
|
||||
it('should not sync a person or person delete for an unrelated user', async () => {
|
||||
|
|
@ -76,11 +76,18 @@ describe(SyncEntityType.PersonV1, () => {
|
|||
const { person } = await ctx.newPerson({ ownerId: user2.id });
|
||||
const auth2 = factory.auth({ session, user: user2 });
|
||||
|
||||
expect(await ctx.syncStream(auth2, [SyncRequestType.PeopleV1])).toHaveLength(1);
|
||||
expect(await ctx.syncStream(auth, [SyncRequestType.PeopleV1])).toHaveLength(0);
|
||||
expect(await ctx.syncStream(auth2, [SyncRequestType.PeopleV1])).toEqual([
|
||||
expect.objectContaining({ type: SyncEntityType.PersonV1 }),
|
||||
expect.objectContaining({ type: SyncEntityType.SyncCompleteV1 }),
|
||||
]);
|
||||
await ctx.assertSyncIsComplete(auth, [SyncRequestType.PeopleV1]);
|
||||
|
||||
await personRepo.delete([person.id]);
|
||||
expect(await ctx.syncStream(auth2, [SyncRequestType.PeopleV1])).toHaveLength(1);
|
||||
expect(await ctx.syncStream(auth, [SyncRequestType.PeopleV1])).toHaveLength(0);
|
||||
|
||||
expect(await ctx.syncStream(auth2, [SyncRequestType.PeopleV1])).toEqual([
|
||||
expect.objectContaining({ type: SyncEntityType.PersonDeleteV1 }),
|
||||
expect.objectContaining({ type: SyncEntityType.SyncCompleteV1 }),
|
||||
]);
|
||||
await ctx.assertSyncIsComplete(auth, [SyncRequestType.PeopleV1]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue