From a408f1b24d8863d3f49d8a68f887c1c6e922c1e6 Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Sun, 30 Jul 2023 13:25:31 +0200 Subject: [PATCH] Fixig setting and random photo test #683 --- src/backend/model/database/SearchManager.ts | 2 +- test/backend/integration/routers/admin/SettingsRouter.ts | 2 ++ test/backend/unit/model/sql/SearchManager.spec.ts | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backend/model/database/SearchManager.ts b/src/backend/model/database/SearchManager.ts index 6079940f..48755562 100644 --- a/src/backend/model/database/SearchManager.ts +++ b/src/backend/model/database/SearchManager.ts @@ -356,7 +356,7 @@ export class SearchManager { if (!sortings || !Array.isArray(sortings)) { return query; } - if (sortings.includes(SortingMethods.random) && sortings.length > 0) { + if (sortings.includes(SortingMethods.random) && sortings.length > 1) { throw new Error('Error during applying sorting: Can\' randomize and also sort the result. Bad input:' + sortings.map(s => SortingMethods[s]).join(', ')); } for (const sort of sortings) { diff --git a/test/backend/integration/routers/admin/SettingsRouter.ts b/test/backend/integration/routers/admin/SettingsRouter.ts index 649e5e7d..36663cf0 100644 --- a/test/backend/integration/routers/admin/SettingsRouter.ts +++ b/test/backend/integration/routers/admin/SettingsRouter.ts @@ -46,7 +46,9 @@ describe('SettingsRouter', () => { result.body.should.be.a('object'); should.equal(result.body.error, null); (result.body.result as ServerConfig).Environment.upTime = null; + (result.body.result as ServerConfig).Environment.sendMailAvailable = null; originalSettings.Environment.upTime = null; + originalSettings.Environment.sendMailAvailable = null; result.body.result.should.deep.equal(JSON.parse(JSON.stringify(originalSettings.toJSON({ attachState: true, attachVolatile: true, diff --git a/test/backend/unit/model/sql/SearchManager.spec.ts b/test/backend/unit/model/sql/SearchManager.spec.ts index a1b8f92d..3837aaee 100644 --- a/test/backend/unit/model/sql/SearchManager.spec.ts +++ b/test/backend/unit/model/sql/SearchManager.spec.ts @@ -1406,14 +1406,14 @@ describe('SearchManager', (sqlHelper: DBTestHelper) => { } as TextSearch; // eslint-disable-next-line - expect(await sm.getNMedia(query, [SortingMethods.random], 1, true)).to.not.exist; + expect(await sm.getNMedia(query, [SortingMethods.random], 1, true)).to.deep.equalInAnyOrder([]); query = ({ text: 'wookiees', matchType: TextSearchQueryMatchTypes.exact_match, type: SearchQueryTypes.keyword } as TextSearch); - expect(Utils.clone(await sm.getNMedia(query, [SortingMethods.random], 1, true))).to.deep.equalInAnyOrder(searchifyMedia(pFaceLess)); + expect(Utils.clone(await sm.getNMedia(query, [SortingMethods.random], 1, true))).to.deep.equalInAnyOrder([searchifyMedia(pFaceLess)]); }); });