|
|
|
@ -353,7 +353,7 @@ describe('/libraries', () => {
|
|
|
|
|
|
|
|
|
|
|
|
expect(assets.count).toBe(2);
|
|
|
|
expect(assets.count).toBe(2);
|
|
|
|
|
|
|
|
|
|
|
|
utils.createImageFile(`${testAssetDir}/temp/directoryA/assetB.png`);
|
|
|
|
utils.createImageFile(`${testAssetDir}/temp/directoryA/assetC.png`);
|
|
|
|
|
|
|
|
|
|
|
|
await scan(admin.accessToken, library.id);
|
|
|
|
await scan(admin.accessToken, library.id);
|
|
|
|
await utils.waitForWebsocketEvent({ event: 'assetUpload', total: 3 });
|
|
|
|
await utils.waitForWebsocketEvent({ event: 'assetUpload', total: 3 });
|
|
|
|
@ -361,11 +361,11 @@ describe('/libraries', () => {
|
|
|
|
const { assets: newAssets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id });
|
|
|
|
const { assets: newAssets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id });
|
|
|
|
|
|
|
|
|
|
|
|
expect(newAssets.count).toBe(3);
|
|
|
|
expect(newAssets.count).toBe(3);
|
|
|
|
utils.removeImageFile(`${testAssetDir}/temp/directoryA/assetB.png`);
|
|
|
|
utils.removeImageFile(`${testAssetDir}/temp/directoryA/assetC.png`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should offline a file missing from disk', async () => {
|
|
|
|
it('should offline a file missing from disk', async () => {
|
|
|
|
utils.createImageFile(`${testAssetDir}/temp/directoryA/assetB.png`);
|
|
|
|
utils.createImageFile(`${testAssetDir}/temp/directoryA/assetC.png`);
|
|
|
|
const library = await utils.createLibrary(admin.accessToken, {
|
|
|
|
const library = await utils.createLibrary(admin.accessToken, {
|
|
|
|
ownerId: admin.userId,
|
|
|
|
ownerId: admin.userId,
|
|
|
|
importPaths: [`${testAssetDirInternal}/temp`],
|
|
|
|
importPaths: [`${testAssetDirInternal}/temp`],
|
|
|
|
@ -374,26 +374,28 @@ describe('/libraries', () => {
|
|
|
|
await scan(admin.accessToken, library.id);
|
|
|
|
await scan(admin.accessToken, library.id);
|
|
|
|
await utils.waitForQueueFinish(admin.accessToken, 'library');
|
|
|
|
await utils.waitForQueueFinish(admin.accessToken, 'library');
|
|
|
|
|
|
|
|
|
|
|
|
utils.removeImageFile(`${testAssetDir}/temp/directoryA/assetB.png`);
|
|
|
|
const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id });
|
|
|
|
|
|
|
|
expect(assets.count).toBe(3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
utils.removeImageFile(`${testAssetDir}/temp/directoryA/assetC.png`);
|
|
|
|
|
|
|
|
|
|
|
|
await scan(admin.accessToken, library.id);
|
|
|
|
await scan(admin.accessToken, library.id);
|
|
|
|
await utils.waitForQueueFinish(admin.accessToken, 'library');
|
|
|
|
await utils.waitForQueueFinish(admin.accessToken, 'library');
|
|
|
|
|
|
|
|
|
|
|
|
const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id });
|
|
|
|
const { assets: newAssets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id });
|
|
|
|
|
|
|
|
expect(newAssets.count).toBe(3);
|
|
|
|
|
|
|
|
|
|
|
|
expect(assets.items).toEqual(
|
|
|
|
expect(newAssets.items).toEqual(
|
|
|
|
expect.arrayContaining([
|
|
|
|
expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
expect.objectContaining({
|
|
|
|
isOffline: true,
|
|
|
|
isOffline: true,
|
|
|
|
originalFileName: 'assetB.png',
|
|
|
|
originalFileName: 'assetC.png',
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should offline a file outside of import paths', async () => {
|
|
|
|
it('should offline a file outside of import paths', async () => {
|
|
|
|
utils.createImageFile(`${testAssetDir}/temp/directoryA/assetB.png`);
|
|
|
|
|
|
|
|
utils.createImageFile(`${testAssetDir}/temp/directoryB/assetC.png`);
|
|
|
|
|
|
|
|
const library = await utils.createLibrary(admin.accessToken, {
|
|
|
|
const library = await utils.createLibrary(admin.accessToken, {
|
|
|
|
ownerId: admin.userId,
|
|
|
|
ownerId: admin.userId,
|
|
|
|
importPaths: [`${testAssetDirInternal}/temp`],
|
|
|
|
importPaths: [`${testAssetDirInternal}/temp`],
|
|
|
|
@ -416,16 +418,49 @@ describe('/libraries', () => {
|
|
|
|
expect.arrayContaining([
|
|
|
|
expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
expect.objectContaining({
|
|
|
|
isOffline: false,
|
|
|
|
isOffline: false,
|
|
|
|
originalFileName: 'assetB.png',
|
|
|
|
originalFileName: 'assetA.png',
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
expect.objectContaining({
|
|
|
|
expect.objectContaining({
|
|
|
|
isOffline: true,
|
|
|
|
isOffline: true,
|
|
|
|
originalFileName: 'assetC.png',
|
|
|
|
originalFileName: 'assetB.png',
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
utils.removeImageFile(`${testAssetDir}/temp/directoryB/assetC.png`);
|
|
|
|
it('should offline a file covered by an exclusion pattern', async () => {
|
|
|
|
|
|
|
|
const library = await utils.createLibrary(admin.accessToken, {
|
|
|
|
|
|
|
|
ownerId: admin.userId,
|
|
|
|
|
|
|
|
importPaths: [`${testAssetDirInternal}/temp`],
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await scan(admin.accessToken, library.id);
|
|
|
|
|
|
|
|
await utils.waitForQueueFinish(admin.accessToken, 'library');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await request(app)
|
|
|
|
|
|
|
|
.put(`/libraries/${library.id}`)
|
|
|
|
|
|
|
|
.set('Authorization', `Bearer ${admin.accessToken}`)
|
|
|
|
|
|
|
|
.send({ exclusionPatterns: ['**/directoryB/**'] });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await scan(admin.accessToken, library.id);
|
|
|
|
|
|
|
|
await utils.waitForQueueFinish(admin.accessToken, 'library');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(assets.count).toBe(2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(assets.items).toEqual(
|
|
|
|
|
|
|
|
expect.arrayContaining([
|
|
|
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
|
|
|
isOffline: false,
|
|
|
|
|
|
|
|
originalFileName: 'assetA.png',
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
expect.objectContaining({
|
|
|
|
|
|
|
|
isOffline: true,
|
|
|
|
|
|
|
|
originalFileName: 'assetB.png',
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should not try to delete offline files', async () => {
|
|
|
|
it('should not try to delete offline files', async () => {
|
|
|
|
@ -471,6 +506,8 @@ describe('/libraries', () => {
|
|
|
|
await utils.waitForWebsocketEvent({ event: 'assetDelete', total: 1 });
|
|
|
|
await utils.waitForWebsocketEvent({ event: 'assetDelete', total: 1 });
|
|
|
|
|
|
|
|
|
|
|
|
expect(existsSync(`${testAssetDir}/temp/offline1/assetA.png`)).toBe(true);
|
|
|
|
expect(existsSync(`${testAssetDir}/temp/offline1/assetA.png`)).toBe(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
utils.removeImageFile(`${testAssetDir}/temp/offline1/assetA.png`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should scan new files', async () => {
|
|
|
|
it('should scan new files', async () => {
|
|
|
|
@ -482,14 +519,14 @@ describe('/libraries', () => {
|
|
|
|
await scan(admin.accessToken, library.id);
|
|
|
|
await scan(admin.accessToken, library.id);
|
|
|
|
await utils.waitForQueueFinish(admin.accessToken, 'library');
|
|
|
|
await utils.waitForQueueFinish(admin.accessToken, 'library');
|
|
|
|
|
|
|
|
|
|
|
|
utils.createImageFile(`${testAssetDir}/temp/directoryA/assetC.png`);
|
|
|
|
utils.createImageFile(`${testAssetDir}/temp/directoryC/assetC.png`);
|
|
|
|
|
|
|
|
|
|
|
|
await scan(admin.accessToken, library.id);
|
|
|
|
await scan(admin.accessToken, library.id);
|
|
|
|
await utils.waitForQueueFinish(admin.accessToken, 'library');
|
|
|
|
await utils.waitForQueueFinish(admin.accessToken, 'library');
|
|
|
|
|
|
|
|
|
|
|
|
utils.removeImageFile(`${testAssetDir}/temp/directoryA/assetC.png`);
|
|
|
|
|
|
|
|
const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id });
|
|
|
|
const { assets } = await utils.metadataSearch(admin.accessToken, { libraryId: library.id });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(assets.count).toBe(3);
|
|
|
|
expect(assets.items).toEqual(
|
|
|
|
expect(assets.items).toEqual(
|
|
|
|
expect.arrayContaining([
|
|
|
|
expect.arrayContaining([
|
|
|
|
expect.objectContaining({
|
|
|
|
expect.objectContaining({
|
|
|
|
@ -497,6 +534,8 @@ describe('/libraries', () => {
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
utils.removeImageFile(`${testAssetDir}/temp/directoryC/assetC.png`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('with refreshModifiedFiles=true', () => {
|
|
|
|
describe('with refreshModifiedFiles=true', () => {
|
|
|
|
|