1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Fixig setting and random photo test #683

This commit is contained in:
Patrik J. Braun 2023-07-30 13:25:31 +02:00
parent e113062208
commit a408f1b24d
3 changed files with 5 additions and 3 deletions

View File

@ -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) {

View File

@ -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,

View File

@ -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)]);
});
});