mirror of
https://github.com/immich-app/immich.git
synced 2025-01-07 00:50:23 -05:00
fix(server): empty trash for archived assets (#12281)
* fix(server): empty trash for archived assets * use withArchived * add e2e test
This commit is contained in:
parent
e5667f09c7
commit
6f37ab6a9e
3 changed files with 22 additions and 0 deletions
|
@ -42,6 +42,23 @@ describe('/trash', () => {
|
||||||
const after = await getAssetStatistics({ isTrashed: true }, { headers: asBearerAuth(admin.accessToken) });
|
const after = await getAssetStatistics({ isTrashed: true }, { headers: asBearerAuth(admin.accessToken) });
|
||||||
expect(after.total).toBe(0);
|
expect(after.total).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should empty the trash with archived assets', async () => {
|
||||||
|
const { id: assetId } = await utils.createAsset(admin.accessToken);
|
||||||
|
await utils.archiveAssets(admin.accessToken, [assetId]);
|
||||||
|
await utils.deleteAssets(admin.accessToken, [assetId]);
|
||||||
|
|
||||||
|
const before = await getAssetInfo({ id: assetId }, { headers: asBearerAuth(admin.accessToken) });
|
||||||
|
expect(before).toStrictEqual(expect.objectContaining({ id: assetId, isTrashed: true, isArchived: true }));
|
||||||
|
|
||||||
|
const { status } = await request(app).post('/trash/empty').set('Authorization', `Bearer ${admin.accessToken}`);
|
||||||
|
expect(status).toBe(204);
|
||||||
|
|
||||||
|
await utils.waitForWebsocketEvent({ event: 'assetDelete', id: assetId });
|
||||||
|
|
||||||
|
const after = await getAssetStatistics({ isTrashed: true }, { headers: asBearerAuth(admin.accessToken) });
|
||||||
|
expect(after.total).toBe(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('POST /trash/restore', () => {
|
describe('POST /trash/restore', () => {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import {
|
||||||
signUpAdmin,
|
signUpAdmin,
|
||||||
updateAdminOnboarding,
|
updateAdminOnboarding,
|
||||||
updateAlbumUser,
|
updateAlbumUser,
|
||||||
|
updateAssets,
|
||||||
updateConfig,
|
updateConfig,
|
||||||
validate,
|
validate,
|
||||||
} from '@immich/sdk';
|
} from '@immich/sdk';
|
||||||
|
@ -389,6 +390,9 @@ export const utils = {
|
||||||
return searchMetadata({ metadataSearchDto: dto }, { headers: asBearerAuth(accessToken) });
|
return searchMetadata({ metadataSearchDto: dto }, { headers: asBearerAuth(accessToken) });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
archiveAssets: (accessToken: string, ids: string[]) =>
|
||||||
|
updateAssets({ assetBulkUpdateDto: { ids, isArchived: true } }, { headers: asBearerAuth(accessToken) }),
|
||||||
|
|
||||||
deleteAssets: (accessToken: string, ids: string[]) =>
|
deleteAssets: (accessToken: string, ids: string[]) =>
|
||||||
deleteAssets({ assetBulkDeleteDto: { ids } }, { headers: asBearerAuth(accessToken) }),
|
deleteAssets({ assetBulkDeleteDto: { ids } }, { headers: asBearerAuth(accessToken) }),
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ export class TrashService {
|
||||||
const assetPagination = usePagination(JOBS_ASSET_PAGINATION_SIZE, (pagination) =>
|
const assetPagination = usePagination(JOBS_ASSET_PAGINATION_SIZE, (pagination) =>
|
||||||
this.assetRepository.getByUserId(pagination, auth.user.id, {
|
this.assetRepository.getByUserId(pagination, auth.user.id, {
|
||||||
trashedBefore: DateTime.now().toJSDate(),
|
trashedBefore: DateTime.now().toJSDate(),
|
||||||
|
withArchived: true,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue