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

fix(ssr): fix missing scopedResults during render #830

Merged
merged 1 commit into from
Aug 6, 2020

Conversation

yannickcr
Copy link
Contributor

The scopedResults object was missing when rendering the widget on server-side, crashing the widgets that were relying on it (like
AisCurrentRefinements for example).

This PR fixes this by recalculating the scoped results and adding them to the render options (for this we're using the same method as in InstantSearch.js https://github.com/algolia/instantsearch.js/blob/68b20f487fcd54fd7dec11b4c494b6aa94a18516/src/widgets/index/index.ts#L154-L167)

Fixes #829

Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

good catch, how does this compare to the scopedResults being resolved by the index widget?

scopedResults: expect.arrayContaining([
expect.objectContaining({
helper: expect.any(Object),
indexId: expect.any(String),
Copy link
Member

Choose a reason for hiding this comment

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

Why don't we assert actual values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since most of the values are coming from the test itself or from mocks then we are just checking the shape of the RenderOptions object, not its actual values.

@yannickcr
Copy link
Contributor Author

@Haroenv should be the same.

@Haroenv Haroenv merged commit 74cf685 into master Aug 6, 2020
@Haroenv Haroenv deleted the fix/scopedResults branch August 6, 2020 07:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AisCurrentRefinements app crash - cannot read property reduce of undefined
3 participants