diff --git a/server/e2e/client/library-api.ts b/server/e2e/client/library-api.ts index 98e50bf12..523b6d6ea 100644 --- a/server/e2e/client/library-api.ts +++ b/server/e2e/client/library-api.ts @@ -31,7 +31,9 @@ export const libraryApi = { expect(status).toBe(204); }, scanDeletedFiles: async (server: any, accessToken: string, id: string, dto: ScanLibraryDto = {}) => { - const { status } = await request(server).post(`/library/${id}/scan`).set('Authorization', `Bearer ${accessToken}`); + const { status } = await request(server) + .post(`/library/${id}/scanDeleted`) + .set('Authorization', `Bearer ${accessToken}`); expect(status).toBe(204); }, }; diff --git a/server/e2e/jobs/specs/library.e2e-spec.ts b/server/e2e/jobs/specs/library.e2e-spec.ts index c46ba8857..bd34c6e38 100644 --- a/server/e2e/jobs/specs/library.e2e-spec.ts +++ b/server/e2e/jobs/specs/library.e2e-spec.ts @@ -35,41 +35,6 @@ describe(`${LibraryController.name} (e2e)`, () => { }); describe('POST /library/:id/scan', () => { - it('should offline a missing file when called with checkForOffline', async () => { - await fs.promises.cp(`${IMMICH_TEST_ASSET_PATH}/albums/nature`, `${IMMICH_TEST_ASSET_TEMP_PATH}/albums/nature`, { - recursive: true, - }); - - const library = await api.libraryApi.create(server, admin.accessToken, { - type: LibraryType.EXTERNAL, - importPaths: [`${IMMICH_TEST_ASSET_TEMP_PATH}`], - }); - - await api.libraryApi.scanLibrary(server, admin.accessToken, library.id); - - const onlineAssets = await api.assetApi.getAllAssets(server, admin.accessToken); - expect(onlineAssets.length).toBeGreaterThan(1); - - await fs.promises.rm(`${IMMICH_TEST_ASSET_TEMP_PATH}/albums/nature/silver_fir.jpg`); - - await api.libraryApi.scanDeletedFiles(server, admin.accessToken, library.id); - - const assets = await api.assetApi.getAllAssets(server, admin.accessToken); - - expect(assets).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - isOffline: true, - originalFileName: 'silver_fir', - }), - expect.objectContaining({ - isOffline: false, - originalFileName: 'tanners_ridge', - }), - ]), - ); - }); - it('should mark a rediscovered file as back online', async () => { await fs.promises.cp(`${IMMICH_TEST_ASSET_PATH}/albums/nature`, `${IMMICH_TEST_ASSET_TEMP_PATH}/albums/nature`, { recursive: true, @@ -278,6 +243,43 @@ describe(`${LibraryController.name} (e2e)`, () => { }); }); + describe('POST /library/:id/scanDeleted', () => { + it('should offline a missing file', async () => { + await fs.promises.cp(`${IMMICH_TEST_ASSET_PATH}/albums/nature`, `${IMMICH_TEST_ASSET_TEMP_PATH}/albums/nature`, { + recursive: true, + }); + + const library = await api.libraryApi.create(server, admin.accessToken, { + type: LibraryType.EXTERNAL, + importPaths: [`${IMMICH_TEST_ASSET_TEMP_PATH}`], + }); + + await api.libraryApi.scanLibrary(server, admin.accessToken, library.id); + + const onlineAssets = await api.assetApi.getAllAssets(server, admin.accessToken); + expect(onlineAssets.length).toBeGreaterThan(1); + + await fs.promises.rm(`${IMMICH_TEST_ASSET_TEMP_PATH}/albums/nature/silver_fir.jpg`); + + await api.libraryApi.scanDeletedFiles(server, admin.accessToken, library.id); + + const assets = await api.assetApi.getAllAssets(server, admin.accessToken); + + expect(assets).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + isOffline: true, + originalFileName: 'silver_fir', + }), + expect.objectContaining({ + isOffline: false, + originalFileName: 'tanners_ridge', + }), + ]), + ); + }); + }); + describe('POST /library/:id/removeOffline', () => { it('should require authentication', async () => { const { status, body } = await request(server).post(`/library/${uuidStub.notFound}/removeOffline`).send({});