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

fix(createInstantSearchManager): fix multi-index search #2570

Merged
merged 8 commits into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
},
{
"path": "packages/react-instantsearch/dist/umd/Connectors.min.js",
"maxSize": "41.75 kB"
"maxSize": "41.80 kB"
},
{
"path": "packages/react-instantsearch/dist/umd/Dom.min.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ describe('createInstantSearchManager with multi index', () => {
// <SearchBox defaultRefinement="first query 1" />
ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setQuery('first query 1'),
context: {},
props: {},
});

// <Index indexName="first" indexId="first" />
ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setIndex('first'),
context: {},
props: {
indexName: 'first',
indexId: 'first',
Expand All @@ -66,18 +64,16 @@ describe('createInstantSearchManager with multi index', () => {
// </Index>
ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setPage(3),
context: {
multiIndexContext: {
props: {
indexContextValue: {
targetedIndex: 'first',
},
},
props: {},
});

// <Index indexName="second" indexId="second" />
ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setIndex('second'),
context: {},
props: {
indexName: 'second',
indexId: 'second',
Expand All @@ -89,12 +85,11 @@ describe('createInstantSearchManager with multi index', () => {
// </Index>
ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setQuery('second query 1'),
context: {
multiIndexContext: {
props: {
indexContextValue: {
targetedIndex: 'second',
},
},
props: {},
});

expect(ism.store.getState().results).toBe(null);
Expand Down Expand Up @@ -171,14 +166,12 @@ describe('createInstantSearchManager with multi index', () => {
// <SearchBox defaultRefinement="query" />
ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setQuery('query'),
context: {},
props: {},
});

// <Index indexName="first" indexId="first" />
ism.widgetsManager.registerWidget({
getSearchParameters: x => x.setIndex('first'),
context: {},
props: {
indexName: 'first',
indexId: 'first',
Expand All @@ -190,18 +183,16 @@ describe('createInstantSearchManager with multi index', () => {
// </Index>
ism.widgetsManager.registerWidget({
getSearchParameters: x => x.setIndex('third'),
context: {
multiIndexContext: {
props: {
indexContextValue: {
targetedIndex: 'first',
},
},
props: {},
});

// <Index indexName="second" indexId="second" />
ism.widgetsManager.registerWidget({
getSearchParameters: x => x.setIndex('second'),
context: {},
props: {
indexName: 'second',
indexId: 'second',
Expand Down Expand Up @@ -249,7 +240,6 @@ describe('createInstantSearchManager with multi index', () => {
// <Index indexName="first" />
ism.widgetsManager.registerWidget({
getSearchParameters: x => x.setIndex('first'),
context: {},
props: {
indexName: 'first',
indexId: 'first',
Expand All @@ -259,7 +249,6 @@ describe('createInstantSearchManager with multi index', () => {
// <Index indexName="second" />
ism.widgetsManager.registerWidget({
getSearchParameters: x => x.setIndex('second'),
context: {},
props: {
indexName: 'second',
indexId: 'second',
Expand All @@ -269,7 +258,6 @@ describe('createInstantSearchManager with multi index', () => {
// <Index indexName="third" />
ism.widgetsManager.registerWidget({
getSearchParameters: x => x.setIndex('third'),
context: {},
props: {
indexName: 'third',
indexId: 'third',
Expand All @@ -279,7 +267,6 @@ describe('createInstantSearchManager with multi index', () => {
// <Index indexName="four" />
ism.widgetsManager.registerWidget({
getSearchParameters: x => x.setIndex('four'),
context: {},
props: {
indexName: 'four',
indexId: 'four',
Expand Down Expand Up @@ -327,7 +314,6 @@ describe('createInstantSearchManager with multi index', () => {
// <Index indexName="first" indexId="first_5_hits" />
ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setIndex('first'),
context: {},
props: {
indexName: 'first',
indexId: 'first_5_hits',
Expand All @@ -339,18 +325,16 @@ describe('createInstantSearchManager with multi index', () => {
// </Index>
ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setQueryParameter('hitsPerPage', 5),
context: {
multiIndexContext: {
props: {
indexContextValue: {
targetedIndex: 'first_5_hits',
},
},
props: {},
});

// <Index indexName="first" indexId="first_10_hits" />
ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setIndex('first'),
context: {},
props: {
indexName: 'first',
indexId: 'first_10_hits',
Expand All @@ -363,12 +347,11 @@ describe('createInstantSearchManager with multi index', () => {
ism.widgetsManager.registerWidget({
getSearchParameters: params =>
params.setQueryParameter('hitsPerPage', 10),
context: {
multiIndexContext: {
props: {
indexContextValue: {
targetedIndex: 'first_10_hits',
},
},
props: {},
});

expect(ism.store.getState().results).toBe(null);
Expand Down Expand Up @@ -415,14 +398,12 @@ describe('createInstantSearchManager with multi index', () => {
// <SearchBox defaultRefinement="first query 1" />
ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setQuery('first query 1'),
context: {},
props: {},
});

// <Index indexName="first" indexId="first" />
const unregisterFirstIndexWidget = ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setIndex('first'),
context: {},
props: {
indexName: 'first',
indexId: 'first',
Expand All @@ -434,18 +415,16 @@ describe('createInstantSearchManager with multi index', () => {
// </Index>
const unregisterPaginationWidget = ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setPage(3),
context: {
multiIndexContext: {
props: {
indexContextValue: {
targetedIndex: 'first',
},
},
props: {},
});

// <Index indexName="second" indexId="second" />
const unregisterSecondIndexWidget = ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setIndex('second'),
context: {},
props: {
indexName: 'second',
indexId: 'second',
Expand All @@ -457,12 +436,11 @@ describe('createInstantSearchManager with multi index', () => {
// </Index>
const unregisterSecondSearchBoxWidget = ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setQuery('second query 1'),
context: {
multiIndexContext: {
props: {
indexContextValue: {
targetedIndex: 'second',
},
},
props: {},
});

expect(ism.store.getState().results).toBe(null);
Expand Down Expand Up @@ -506,7 +484,6 @@ describe('createInstantSearchManager with multi index', () => {
// <Index indexName="first" indexId="first" />
ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setIndex('first'),
context: {},
props: {
indexName: 'first',
indexId: 'first',
Expand All @@ -518,18 +495,16 @@ describe('createInstantSearchManager with multi index', () => {
// </Index>
ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setPage(3),
context: {
multiIndexContext: {
props: {
indexContextValue: {
targetedIndex: 'first',
},
},
props: {},
});

// <Index indexName="second" indexId="second" />
ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setIndex('second'),
context: {},
props: {
indexName: 'second',
indexId: 'second',
Expand All @@ -541,12 +516,11 @@ describe('createInstantSearchManager with multi index', () => {
// </Index>
ism.widgetsManager.registerWidget({
getSearchParameters: params => params.setQuery('second query 2'),
context: {
multiIndexContext: {
props: {
indexContextValue: {
targetedIndex: 'second',
},
},
props: {},
});

await runAllMicroTasks();
Expand Down
Loading