|
|
@ -49,14 +49,68 @@ describe('POST /query with no songs', () => { |
|
|
|
describe('POST /query with several songs and filters', () => { |
|
|
|
describe('POST /query with several songs and filters', () => { |
|
|
|
it('should give all correct results', done => { |
|
|
|
it('should give all correct results', done => { |
|
|
|
init().then((app) => { |
|
|
|
init().then((app) => { |
|
|
|
|
|
|
|
const song1 = { |
|
|
|
|
|
|
|
songId: 1, |
|
|
|
|
|
|
|
title: 'Song1', |
|
|
|
|
|
|
|
storeLinks: [], |
|
|
|
|
|
|
|
artists: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
artistId: 1, |
|
|
|
|
|
|
|
name: 'Artist1' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
tags: [], |
|
|
|
|
|
|
|
rankings: [] |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
const song2 = { |
|
|
|
|
|
|
|
songId: 2, |
|
|
|
|
|
|
|
title: 'Song2', |
|
|
|
|
|
|
|
storeLinks: [], |
|
|
|
|
|
|
|
artists: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
artistId: 1, |
|
|
|
|
|
|
|
name: 'Artist1' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
tags: [], |
|
|
|
|
|
|
|
rankings: [] |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
const song3 = { |
|
|
|
|
|
|
|
songId: 3, |
|
|
|
|
|
|
|
title: 'Song3', |
|
|
|
|
|
|
|
storeLinks: [], |
|
|
|
|
|
|
|
artists: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
artistId: 2, |
|
|
|
|
|
|
|
name: 'Artist2' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
tags: [], |
|
|
|
|
|
|
|
rankings: [] |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
async function checkAllSongs(req) { |
|
|
|
async function checkAllSongs(req) { |
|
|
|
await req |
|
|
|
await req |
|
|
|
.post('/query') |
|
|
|
.post('/query') |
|
|
|
.send({ "query": {} }) |
|
|
|
.send({ |
|
|
|
|
|
|
|
"query": {}, |
|
|
|
|
|
|
|
'offsetsLimits': { |
|
|
|
|
|
|
|
'songOffset': 0, |
|
|
|
|
|
|
|
'songLimit': 10, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'ordering': { |
|
|
|
|
|
|
|
'orderBy': { |
|
|
|
|
|
|
|
'type': 0, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'ascending': true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
.then((res) => { |
|
|
|
.then((res) => { |
|
|
|
expect(res).to.have.status(200); |
|
|
|
expect(res).to.have.status(200); |
|
|
|
expect(res.body).to.deep.equal({ |
|
|
|
expect(res.body).to.deep.equal({ |
|
|
|
ids: [1, 2, 3] |
|
|
|
songs: [ song1, song2, song3 ], |
|
|
|
|
|
|
|
artists: [], |
|
|
|
|
|
|
|
tags: [] |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -66,15 +120,27 @@ describe('POST /query with several songs and filters', () => { |
|
|
|
.post('/query') |
|
|
|
.post('/query') |
|
|
|
.send({ |
|
|
|
.send({ |
|
|
|
"query": { |
|
|
|
"query": { |
|
|
|
"prop": "id", |
|
|
|
"prop": "songId", |
|
|
|
"propOperator": "IN", |
|
|
|
"propOperator": "IN", |
|
|
|
"propOperand": [1, 3, 5] |
|
|
|
"propOperand": [1, 3, 5] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'offsetsLimits': { |
|
|
|
|
|
|
|
'songOffset': 0, |
|
|
|
|
|
|
|
'songLimit': 10, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'ordering': { |
|
|
|
|
|
|
|
'orderBy': { |
|
|
|
|
|
|
|
'type': 0, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'ascending': true |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then((res) => { |
|
|
|
.then((res) => { |
|
|
|
expect(res).to.have.status(200); |
|
|
|
expect(res).to.have.status(200); |
|
|
|
expect(res.body).to.deep.equal({ |
|
|
|
expect(res.body).to.deep.equal({ |
|
|
|
ids: [1, 3] |
|
|
|
songs: [ song1, song3 ], |
|
|
|
|
|
|
|
artists: [], |
|
|
|
|
|
|
|
tags: [] |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -84,15 +150,27 @@ describe('POST /query with several songs and filters', () => { |
|
|
|
.post('/query') |
|
|
|
.post('/query') |
|
|
|
.send({ |
|
|
|
.send({ |
|
|
|
"query": { |
|
|
|
"query": { |
|
|
|
"prop": "id", |
|
|
|
"prop": "songId", |
|
|
|
"propOperator": "NOTIN", |
|
|
|
"propOperator": "NOTIN", |
|
|
|
"propOperand": [1, 3, 5] |
|
|
|
"propOperand": [1, 3, 5] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'offsetsLimits': { |
|
|
|
|
|
|
|
'songOffset': 0, |
|
|
|
|
|
|
|
'songLimit': 10, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'ordering': { |
|
|
|
|
|
|
|
'orderBy': { |
|
|
|
|
|
|
|
'type': 0, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'ascending': true |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then((res) => { |
|
|
|
.then((res) => { |
|
|
|
expect(res).to.have.status(200); |
|
|
|
expect(res).to.have.status(200); |
|
|
|
expect(res.body).to.deep.equal({ |
|
|
|
expect(res.body).to.deep.equal({ |
|
|
|
ids: [2] |
|
|
|
songs: [ song2 ], |
|
|
|
|
|
|
|
artists: [], |
|
|
|
|
|
|
|
tags: [] |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -102,15 +180,27 @@ describe('POST /query with several songs and filters', () => { |
|
|
|
.post('/query') |
|
|
|
.post('/query') |
|
|
|
.send({ |
|
|
|
.send({ |
|
|
|
"query": { |
|
|
|
"query": { |
|
|
|
"prop": "artistIds", |
|
|
|
"prop": "artistId", |
|
|
|
"propOperator": "IN", |
|
|
|
"propOperator": "IN", |
|
|
|
"propOperand": [1] |
|
|
|
"propOperand": [1] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'offsetsLimits': { |
|
|
|
|
|
|
|
'songOffset': 0, |
|
|
|
|
|
|
|
'songLimit': 10, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'ordering': { |
|
|
|
|
|
|
|
'orderBy': { |
|
|
|
|
|
|
|
'type': 0, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'ascending': true |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then((res) => { |
|
|
|
.then((res) => { |
|
|
|
expect(res).to.have.status(200); |
|
|
|
expect(res).to.have.status(200); |
|
|
|
expect(res.body).to.deep.equal({ |
|
|
|
expect(res.body).to.deep.equal({ |
|
|
|
ids: [1, 2] |
|
|
|
songs: [ song1, song2 ], |
|
|
|
|
|
|
|
artists: [], |
|
|
|
|
|
|
|
tags: [] |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -123,22 +213,34 @@ describe('POST /query with several songs and filters', () => { |
|
|
|
"childrenOperator": "OR", |
|
|
|
"childrenOperator": "OR", |
|
|
|
"children": [ |
|
|
|
"children": [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
"prop": "artistIds", |
|
|
|
"prop": "artistId", |
|
|
|
"propOperator": "IN", |
|
|
|
"propOperator": "IN", |
|
|
|
"propOperand": [2] |
|
|
|
"propOperand": [2] |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
"prop": "id", |
|
|
|
"prop": "songId", |
|
|
|
"propOperator": "EQ", |
|
|
|
"propOperator": "EQ", |
|
|
|
"propOperand": 1 |
|
|
|
"propOperand": 1 |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'offsetsLimits': { |
|
|
|
|
|
|
|
'songOffset': 0, |
|
|
|
|
|
|
|
'songLimit': 10, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'ordering': { |
|
|
|
|
|
|
|
'orderBy': { |
|
|
|
|
|
|
|
'type': 0, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'ascending': true |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then((res) => { |
|
|
|
.then((res) => { |
|
|
|
expect(res).to.have.status(200); |
|
|
|
expect(res).to.have.status(200); |
|
|
|
expect(res.body).to.deep.equal({ |
|
|
|
expect(res.body).to.deep.equal({ |
|
|
|
ids: [1, 3] |
|
|
|
songs: [ song1, song3 ], |
|
|
|
|
|
|
|
artists: [], |
|
|
|
|
|
|
|
tags: [] |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|