-
Notifications
You must be signed in to change notification settings - Fork 47
EZP-26325: Use query and filter in PlatformUI #712
Conversation
a0db9c0
to
e8a410b
Compare
d170b2d
to
5c98737
Compare
5c98737
to
34890e5
Compare
ready for review @dpobel @yannickroger |
method: 'setFilter', | ||
args: [Mock.Value.Object], | ||
run: Y.bind(function (arg) { | ||
this.query.body.ViewInput.LocationQuery.Filter = arg; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should not need that. The point of defining a Mock is too avoid this (reimplementation of the object being mocked)
method: 'setFilter', | ||
args: [Mock.Value.Object], | ||
run: Y.bind(function (arg) { | ||
this.viewCreateStruct.body.ViewInput.LocationQuery.Filter = arg; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -22,8 +37,15 @@ YUI.add('ez-searchplugin-tests', function (Y) { | |||
this.capi = new Mock(); | |||
this.contentService = new Mock(); | |||
this.viewName = 'REST-View-Name'; | |||
this.query = {body: {ViewInput: {ContentQuery: {}}}}; | |||
|
|||
this.query = new Y.Mock({body: {ViewInput: {ContentQuery: {}}}}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for the parameter
method: 'createView', | ||
args: [context.query, Mock.Value.Function], | ||
run: Y.bind(function () { | ||
Y.Mock.verify(context.query); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should not do that here, you have no guarantee this will be called. You should do that at the end of each test.
this.query = new Y.Mock({body: {ViewInput: {ContentQuery: {}}}}); | ||
Mock.expect(this.query, { | ||
method: 'setLimitAndOffset', | ||
args: [Mock.Value.Any, Mock.Value.Any], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method is supposed to receive specific values not Any
}); | ||
Mock.expect(this.query, { | ||
method: 'setSortClauses', | ||
args: [Mock.Value.Object], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, you are expecting a very specific object
@@ -296,8 +316,16 @@ YUI.add('ez-searchplugin-tests', function (Y) { | |||
this.capi = new Mock(); | |||
this.contentService = new Mock(); | |||
this.viewName = 'REST-View-Name'; | |||
this.query = {body: {ViewInput: {LocationQuery: {}}}}; | |||
this.query = new Mock({body: {ViewInput: {LocationQuery: {}}}}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same remarks as in contentSearchTests
|
||
Mock.expect(this.query, { | ||
method: 'setLimitAndOffset', | ||
args: [Mock.Value.Any, Mock.Value.Any], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and same as in the others tests
@@ -796,8 +840,8 @@ YUI.add('ez-searchplugin-tests', function (Y) { | |||
this.capi = new Mock(); | |||
this.contentService = new Mock(); | |||
this.viewName = 'REST-View-Name'; | |||
this.locationQuery = {body: {ViewInput: {LocationQuery: {}}}}; | |||
this.contentQuery = {body: {ViewInput: {ContentQuery: {}}}}; | |||
this.locationQuery = new Mock({body: {ViewInput: {LocationQuery: {}}}}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for the parameter
Note: Added todo in description in order to make sure we update composer requirements once the rest client changes are merged and tagged for UI use. |
7c05985
to
28085b7
Compare
updated @dpobel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and about the changes in ezsystems/ez-js-rest-client#80 ?
@@ -69,6 +69,7 @@ YUI.add('ez-searchplugin', function (Y) { | |||
} | |||
if (search.criteria) { | |||
query.setCriteria(search.criteria); | |||
console.warn("Criteria query's property is deprecated"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's not the standard deprecation log format
this.sortClauses = {}; | ||
Mock.expect(this.query, { | ||
method: 'setLimitAndOffset', | ||
args: [Mock.Value.Number, Mock.Value.Number], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still too weak, you don't expect any number but very specific values for limit and offset
}); | ||
Mock.expect(this.query, { | ||
method: 'setSortClauses', | ||
args: [Mock.Value.Object], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of having a run
function with an assertion, you can directly put this.sortClauses
here
@@ -111,7 +147,8 @@ YUI.add('ez-searchplugin-tests', function (Y) { | |||
this.view.fire('contentSearch', { | |||
viewName: this.viewName, | |||
search: { | |||
criteria: {}, | |||
offset: 42, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need to add offset
and limit
? those parameters are documented as optional, so this should not be needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I understand, with your patch offset and limit become mandatory. This is a BC break (most likely this breaks some parts of PlatformUI) so the solution is not to fix the unit tests but fix the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well no, offset and limit aren't mandatory... But the query mocks now expect 2 args number now for their setLimitAndOffset method (that's why i had Y.Mock.Any before). So now I had to fill the tests with limit and offset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then it's completely useless and you fix your mock instead of changing each and every test
}); | ||
Mock.expect(this.query, { | ||
method: 'setSortClauses', | ||
args: [Mock.Value.Object], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as previously, this.sortClauses
can be used
|
||
Mock.expect(this.query, { | ||
method: 'setLimitAndOffset', | ||
args: [Mock.Value.Number, Mock.Value.Number], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too weak as well
28085b7
to
3b8d69d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to squash your commits.
3b8d69d
to
97ca9cc
Compare
0c0a098
to
85e5d51
Compare
85e5d51
to
125ec4a
Compare
PR approved by QA |
Jira: https://jira.ez.no/browse/EZP-26325
Description
The goal here was to be able to use query and filter Query properties instead of criteria. By using this users will now be able, while using Solr, to get search results sorted with relevancy.
BTW you need to have a ez-JS-REST-client up to date with ezsystems/ez-js-rest-client#80 (hopefully merged soon).
Tests
Todo