Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
robgietema committed Dec 3, 2024
1 parent ecc5545 commit cc7a873
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
4 changes: 4 additions & 0 deletions docs/examples/vocabularies/list.res
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Content-Type: application/json
"@id": "http://localhost:8080/@vocabularies/boolean",
"title": "boolean"
},
{
"@id": "http://localhost:8080/@vocabularies/captchaProviders",
"title": "captchaProviders"
},
{
"@id": "http://localhost:8080/@vocabularies/groups",
"title": "groups"
Expand Down
3 changes: 0 additions & 3 deletions src/models/_model/_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ export class Model extends mixin(ObjectionModel, [
operator = '=';
valueWrapper = 'all(?)';
}
if (operator === 'like') {
valueWrapper = '%?%';
}
if (operator === '@@') {
valueWrapper = 'to_tsquery(?)';
}
Expand Down
6 changes: 6 additions & 0 deletions src/routes/form/form.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import app from '../../app';
import { testRequest } from '../../helpers';

describe('Form', () => {
it('should submit a form', () => testRequest(app, 'search/post'));
});
23 changes: 16 additions & 7 deletions src/routes/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ import { Catalog, Index } from '../../models';
const querystringToQuery = async (querystring, path = '/', req, trx) => {
// Get root url
const root = endsWith(path, '/') ? path : `${path}/`;
const indexes = (
await Index.fetchAll({ enabled: true, metadata: false }, {}, trx)
).toJSON(req);

// Get indexes
let indexes = {};
(await Index.fetchAll({ metadata: false }, {}, trx)).map((index) => {
indexes[index.name] = index;
});

const where = {};

// Default options
Expand Down Expand Up @@ -129,7 +133,7 @@ const querystringToQuery = async (querystring, path = '/', req, trx) => {
where[query.i] = req.user.id;
break;
case 'string.contains':
where[query.i] = ['like', query.v];
where[query.i] = ['like', `%${query.v}%`];
break;
default:
break;
Expand All @@ -151,9 +155,12 @@ const querystringToQuery = async (querystring, path = '/', req, trx) => {
const queryparamToQuery = async (queryparam, path = '/', req, trx) => {
// Get root url
const root = endsWith(path, '/') ? path : `${path}/`;
const indexes = (
await Index.fetchAll({ enabled: true, metadata: false }, {}, trx)
).toJSON(req);

// Get indexes
let indexes = {};
(await Index.fetchAll({ metadata: false }, {}, trx)).map((index) => {
indexes[index.name] = index;
});

// Set path search
const where = {
Expand All @@ -169,6 +176,8 @@ const queryparamToQuery = async (queryparam, path = '/', req, trx) => {
reverse: false,
},
};

// Loop through query params
mapKeys(queryparam, (value, key) => {
switch (key) {
case 'sort_on':
Expand Down

0 comments on commit cc7a873

Please sign in to comment.