Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(getConfiguration): burn it to the ground 🔥 #4083

Merged
merged 31 commits into from
Sep 4, 2019

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Aug 29, 2019

  1. remove getConfiguration in every widget
  2. remove getConfiguration from types & expectations
  3. change tests which were using getConfiguration to getWidgetSearchParameters

@Haroenv Haroenv requested review from francoischalifour, samouss and a team August 29, 2019 15:50
@ghost ghost removed their request for review August 29, 2019 15:50
@@ -62,15 +62,20 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/range-slide
});

describe('min option', () => {
it('refines when no previous configuration', () => {
// @TODO: gWSP does not yet take min & max in account
it.skip('refines when no previous configuration', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these need to be fixed in a separate PR, cc @samouss

Copy link
Contributor Author

Choose a reason for hiding this comment

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

// can not use setQueryParameters || removeNumericRefinements, because
// they both keep the old value. This isn't immutable, but it is fine
// since it's already a copy.
stateWithoutDisjunctive.numericRefinements = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if we can find a better solution for this

Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC you can use removeNumericRefinements with the attribute only, it will perform a clear under the hood.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn’t actually remove the refinement, I havent found a solution which doesn’t break for refining to an empty state

Copy link
Contributor

@samouss samouss left a comment

Choose a reason for hiding this comment

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

I went through the changes didn't read everything carefully but it looks good overall.

getWidgetState?(
uiState: IndexUiState,
widgetStateOptions: WidgetStateOptions
): IndexUiState;
/**
* This function is required for a widget to behave correctly when a URL is
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 half true since we know use this function to sets the configuration too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have a better description? “Also used to keep track (or merge) of refinements when other widgets are added/removed”?

src/connectors/menu/__tests__/connectMenu-test.js Outdated Show resolved Hide resolved
// can not use setQueryParameters || removeNumericRefinements, because
// they both keep the old value. This isn't immutable, but it is fine
// since it's already a copy.
stateWithoutDisjunctive.numericRefinements = {
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC you can use removeNumericRefinements with the attribute only, it will perform a clear under the hood.

@Haroenv Haroenv requested review from yannickcr and tkrugg and removed request for francoischalifour September 2, 2019 08:16
@Haroenv Haroenv force-pushed the chore/getConfiguration branch from 34516f7 to 18b7730 Compare September 2, 2019 09:22
src/connectors/range/connectRange.js Outdated Show resolved Hide resolved
],
})
);
it('does not remove refinement', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure I get this part.
Removing the widget should remove the refinement, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, a breadcrumb's refinement is set by a configure or hierarchical facet, and should thus stay. This didn't change in this PR by the way, it was simply not tested

).toEqual(
new SearchParameters({
hitsPerPage: 20,
hitsPerPage: 10,
Copy link
Contributor

@tkrugg tkrugg Sep 4, 2019

Choose a reason for hiding this comment

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

isn't this supposed to be 20?
this doesn't look like it overrides it, right?

Or is it the undefined value that overrides the 20, so we end up fallbacking to the default 10 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we override the previously set hPP with the "default" one, this was defined by #4069

@Haroenv Haroenv force-pushed the chore/getConfiguration branch from 7e0ae3d to 7466f90 Compare September 4, 2019 13:56
@Haroenv Haroenv merged commit a38fb6f into next Sep 4, 2019
@Haroenv Haroenv deleted the chore/getConfiguration branch September 4, 2019 14:33
samouss pushed a commit that referenced this pull request Sep 17, 2019
* chore: remove enhanceConfiguration

* chore: remove getConfiguration from types

* chore: remove getConfiguration from widgets

* test(autocomplete): replace getConfiguration tests

* chore: remove enhanceConfiguration test

* test(refinementlist): replace getConfiguration tests

* test(pagination): replace getConfiguration test

* test(searchbox): replace getConfiguration tests

* test(configure): replace getConfiguration in tests

* test(ratingMenu): update usage of getConfiguration

* test(breadcrumb): move getConfiguration tests

* test(hitsPerPage): migrate getConfiguration tests

* test(infinitehits): remove duplicate getConfiguration tests

* test(stats): remove useless (common) test

* chore: update comment

* test(toggleRefinement): swap getConfiguration usages

* test(refinementlist): migrate getConfiguration tests

* test(clear): remove useless assertion

* test(current): remove useless assertion

* test(menu): update calls

* test(pagination): !fixup

* test(hierarchical-menu): remove redundant tests

* test(sortBy): remove redundant tests

* test(hits): remove redundant tests

* test: remove redundant tests

* test(range): update getConfiguration tests (with caveats)

* !fixup linting

* chore(test): remove commented code

* chore: fix message

Co-Authored-By: Yannick Croissant <yannick.croissant@gmail.com>

* fix(range): apply min/max to getWidgetSearchParameters (#4088)

* fix(connectRange): apply min/max

* fix(connectRange): throw an error when max is lower than min

* test(hpp): cleaner test without snapshots
samouss pushed a commit that referenced this pull request Sep 17, 2019
* chore: remove enhanceConfiguration

* chore: remove getConfiguration from types

* chore: remove getConfiguration from widgets

* test(autocomplete): replace getConfiguration tests

* chore: remove enhanceConfiguration test

* test(refinementlist): replace getConfiguration tests

* test(pagination): replace getConfiguration test

* test(searchbox): replace getConfiguration tests

* test(configure): replace getConfiguration in tests

* test(ratingMenu): update usage of getConfiguration

* test(breadcrumb): move getConfiguration tests

* test(hitsPerPage): migrate getConfiguration tests

* test(infinitehits): remove duplicate getConfiguration tests

* test(stats): remove useless (common) test

* chore: update comment

* test(toggleRefinement): swap getConfiguration usages

* test(refinementlist): migrate getConfiguration tests

* test(clear): remove useless assertion

* test(current): remove useless assertion

* test(menu): update calls

* test(pagination): !fixup

* test(hierarchical-menu): remove redundant tests

* test(sortBy): remove redundant tests

* test(hits): remove redundant tests

* test: remove redundant tests

* test(range): update getConfiguration tests (with caveats)

* !fixup linting

* chore(test): remove commented code

* chore: fix message

Co-Authored-By: Yannick Croissant <yannick.croissant@gmail.com>

* fix(range): apply min/max to getWidgetSearchParameters (#4088)

* fix(connectRange): apply min/max

* fix(connectRange): throw an error when max is lower than min

* test(hpp): cleaner test without snapshots
samouss pushed a commit that referenced this pull request Sep 17, 2019
* chore: remove enhanceConfiguration

* chore: remove getConfiguration from types

* chore: remove getConfiguration from widgets

* test(autocomplete): replace getConfiguration tests

* chore: remove enhanceConfiguration test

* test(refinementlist): replace getConfiguration tests

* test(pagination): replace getConfiguration test

* test(searchbox): replace getConfiguration tests

* test(configure): replace getConfiguration in tests

* test(ratingMenu): update usage of getConfiguration

* test(breadcrumb): move getConfiguration tests

* test(hitsPerPage): migrate getConfiguration tests

* test(infinitehits): remove duplicate getConfiguration tests

* test(stats): remove useless (common) test

* chore: update comment

* test(toggleRefinement): swap getConfiguration usages

* test(refinementlist): migrate getConfiguration tests

* test(clear): remove useless assertion

* test(current): remove useless assertion

* test(menu): update calls

* test(pagination): !fixup

* test(hierarchical-menu): remove redundant tests

* test(sortBy): remove redundant tests

* test(hits): remove redundant tests

* test: remove redundant tests

* test(range): update getConfiguration tests (with caveats)

* !fixup linting

* chore(test): remove commented code

* chore: fix message

Co-Authored-By: Yannick Croissant <yannick.croissant@gmail.com>

* fix(range): apply min/max to getWidgetSearchParameters (#4088)

* fix(connectRange): apply min/max

* fix(connectRange): throw an error when max is lower than min

* test(hpp): cleaner test without snapshots
samouss pushed a commit that referenced this pull request Sep 17, 2019
* chore: remove enhanceConfiguration

* chore: remove getConfiguration from types

* chore: remove getConfiguration from widgets

* test(autocomplete): replace getConfiguration tests

* chore: remove enhanceConfiguration test

* test(refinementlist): replace getConfiguration tests

* test(pagination): replace getConfiguration test

* test(searchbox): replace getConfiguration tests

* test(configure): replace getConfiguration in tests

* test(ratingMenu): update usage of getConfiguration

* test(breadcrumb): move getConfiguration tests

* test(hitsPerPage): migrate getConfiguration tests

* test(infinitehits): remove duplicate getConfiguration tests

* test(stats): remove useless (common) test

* chore: update comment

* test(toggleRefinement): swap getConfiguration usages

* test(refinementlist): migrate getConfiguration tests

* test(clear): remove useless assertion

* test(current): remove useless assertion

* test(menu): update calls

* test(pagination): !fixup

* test(hierarchical-menu): remove redundant tests

* test(sortBy): remove redundant tests

* test(hits): remove redundant tests

* test: remove redundant tests

* test(range): update getConfiguration tests (with caveats)

* !fixup linting

* chore(test): remove commented code

* chore: fix message

Co-Authored-By: Yannick Croissant <yannick.croissant@gmail.com>

* fix(range): apply min/max to getWidgetSearchParameters (#4088)

* fix(connectRange): apply min/max

* fix(connectRange): throw an error when max is lower than min

* test(hpp): cleaner test without snapshots
Haroenv added a commit that referenced this pull request Oct 23, 2019
* chore: remove enhanceConfiguration

* chore: remove getConfiguration from types

* chore: remove getConfiguration from widgets

* test(autocomplete): replace getConfiguration tests

* chore: remove enhanceConfiguration test

* test(refinementlist): replace getConfiguration tests

* test(pagination): replace getConfiguration test

* test(searchbox): replace getConfiguration tests

* test(configure): replace getConfiguration in tests

* test(ratingMenu): update usage of getConfiguration

* test(breadcrumb): move getConfiguration tests

* test(hitsPerPage): migrate getConfiguration tests

* test(infinitehits): remove duplicate getConfiguration tests

* test(stats): remove useless (common) test

* chore: update comment

* test(toggleRefinement): swap getConfiguration usages

* test(refinementlist): migrate getConfiguration tests

* test(clear): remove useless assertion

* test(current): remove useless assertion

* test(menu): update calls

* test(pagination): !fixup

* test(hierarchical-menu): remove redundant tests

* test(sortBy): remove redundant tests

* test(hits): remove redundant tests

* test: remove redundant tests

* test(range): update getConfiguration tests (with caveats)

* !fixup linting

* chore(test): remove commented code

* chore: fix message

Co-Authored-By: Yannick Croissant <yannick.croissant@gmail.com>

* fix(range): apply min/max to getWidgetSearchParameters (#4088)

* fix(connectRange): apply min/max

* fix(connectRange): throw an error when max is lower than min

* test(hpp): cleaner test without snapshots
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants