Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

EZP-26325: Use query and filter in PlatformUI #712

Merged
merged 9 commits into from
Dec 15, 2016

Conversation

StephaneDiot
Copy link
Contributor

@StephaneDiot StephaneDiot commented Nov 3, 2016

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

  • unit tests

Todo

  • Review & fixes
  • Bump composer.json / * requirements on rest client once that has been merged and new tag is out

@StephaneDiot StephaneDiot changed the base branch from master to 1.6 November 3, 2016 08:57
@StephaneDiot StephaneDiot changed the base branch from 1.6 to master November 3, 2016 08:58
@StephaneDiot StephaneDiot force-pushed the EZP-26325_PlatformUI_search_sorting branch from a0db9c0 to e8a410b Compare November 3, 2016 09:00
@StephaneDiot StephaneDiot changed the base branch from master to 1.6 November 3, 2016 09:01
@StephaneDiot StephaneDiot force-pushed the EZP-26325_PlatformUI_search_sorting branch 2 times, most recently from d170b2d to 5c98737 Compare November 3, 2016 09:57
@StephaneDiot StephaneDiot changed the title [WIP] EZP-26325: Use query and filter in PlatformUI EZP-26325: Use query and filter in PlatformUI Nov 3, 2016
@StephaneDiot StephaneDiot force-pushed the EZP-26325_PlatformUI_search_sorting branch from 5c98737 to 34890e5 Compare November 3, 2016 10:05
@StephaneDiot
Copy link
Contributor Author

ready for review @dpobel @yannickroger

method: 'setFilter',
args: [Mock.Value.Object],
run: Y.bind(function (arg) {
this.query.body.ViewInput.LocationQuery.Filter = arg;
Copy link
Contributor

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;
Copy link
Contributor

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: {}}}});
Copy link
Contributor

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);
Copy link
Contributor

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],
Copy link
Contributor

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],
Copy link
Contributor

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: {}}}});
Copy link
Contributor

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],
Copy link
Contributor

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: {}}}});
Copy link
Contributor

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

@andrerom
Copy link
Contributor

andrerom commented Nov 3, 2016

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.

@StephaneDiot StephaneDiot force-pushed the EZP-26325_PlatformUI_search_sorting branch from 7c05985 to 28085b7 Compare November 7, 2016 14:16
@StephaneDiot
Copy link
Contributor Author

updated @dpobel

Copy link
Contributor

@dpobel dpobel left a 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");
Copy link
Contributor

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],
Copy link
Contributor

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],
Copy link
Contributor

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,
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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],
Copy link
Contributor

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],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too weak as well

@StephaneDiot StephaneDiot force-pushed the EZP-26325_PlatformUI_search_sorting branch from 28085b7 to 3b8d69d Compare November 9, 2016 13:03
Copy link
Contributor

@yannickroger yannickroger left a 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.

@dpobel dpobel force-pushed the EZP-26325_PlatformUI_search_sorting branch from 3b8d69d to 97ca9cc Compare December 5, 2016 10:11
@StephaneDiot StephaneDiot force-pushed the EZP-26325_PlatformUI_search_sorting branch 2 times, most recently from 0c0a098 to 85e5d51 Compare December 13, 2016 10:52
@StephaneDiot StephaneDiot force-pushed the EZP-26325_PlatformUI_search_sorting branch from 85e5d51 to 125ec4a Compare December 13, 2016 10:58
@miguelcleverti
Copy link

PR approved by QA

@StephaneDiot StephaneDiot merged commit c487744 into 1.6 Dec 15, 2016
@andrerom andrerom deleted the EZP-26325_PlatformUI_search_sorting branch January 18, 2017 11:25
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants