Skip to content

Commit

Permalink
Merge branch 'master' into wip/dispose-is-gone
Browse files Browse the repository at this point in the history
  • Loading branch information
dhayab authored Oct 5, 2023
2 parents 58ddb2a + 85eac81 commit 8ea7e44
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 28 deletions.
4 changes: 2 additions & 2 deletions packages/instantsearch.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
],
"dependencies": {
"@algolia/events": "^4.0.1",
"@algolia/ui-components-highlight-vdom": "^1.2.1",
"@algolia/ui-components-shared": "^1.2.1",
"@algolia/ui-components-highlight-vdom": "^1.2.2",
"@algolia/ui-components-shared": "^1.2.2",
"@types/dom-speech-recognition": "^0.0.1",
"@types/google.maps": "^3.45.3",
"@types/hogan.js": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ describe('insights', () => {
}

const getUserToken = () =>
(instantSearchInstance.helper!.state as PlainSearchParameters).userToken;
(instantSearchInstance.mainHelper!.state as PlainSearchParameters)
.userToken;

return {
analytics,
Expand Down Expand Up @@ -94,10 +95,11 @@ describe('insights', () => {
});
instantSearchInstance.start();

const helper = instantSearchInstance.helper!;
const helper = instantSearchInstance.mainHelper!;

const getUserToken = () =>
(instantSearchInstance.helper!.state as PlainSearchParameters).userToken;
(instantSearchInstance.mainHelper!.state as PlainSearchParameters)
.userToken;

return {
analytics,
Expand Down Expand Up @@ -473,17 +475,17 @@ See documentation: https://www.algolia.com/doc/guides/building-search-ui/going-f
insightsClient,
})
);
expect(instantSearchInstance.helper!.state.clickAnalytics).toBe(true);
expect(instantSearchInstance.mainHelper!.state.clickAnalytics).toBe(true);
});

it("doesn't reset page", () => {
const { insightsClient, instantSearchInstance } = createTestEnvironment();
const middleware = createInsightsMiddleware({
insightsClient,
})({ instantSearchInstance });
instantSearchInstance.helper!.setPage(100);
instantSearchInstance.mainHelper!.setPage(100);
middleware.subscribe();
expect(instantSearchInstance.helper!.state.page).toBe(100);
expect(instantSearchInstance.mainHelper!.state.page).toBe(100);
});

it('adds user agent', () => {
Expand Down Expand Up @@ -670,15 +672,15 @@ See documentation: https://www.algolia.com/doc/guides/building-search-ui/going-f

insightsClient('setUserToken', 'abc');
instantSearchInstance.start();
instantSearchInstance.helper!.setPage(100);
instantSearchInstance.mainHelper!.setPage(100);

instantSearchInstance.use(
createInsightsMiddleware({
insightsClient,
})
);

expect(instantSearchInstance.helper!.state.page).toBe(100);
expect(instantSearchInstance.mainHelper!.state.page).toBe(100);
expect(getUserToken()).toEqual('abc');
});

Expand All @@ -702,7 +704,7 @@ See documentation: https://www.algolia.com/doc/guides/building-search-ui/going-f
createTestEnvironment({ started: false });

instantSearchInstance.start();
instantSearchInstance.helper!.setPage(100);
instantSearchInstance.mainHelper!.setPage(100);

instantSearchInstance.use(
createInsightsMiddleware({
Expand All @@ -714,7 +716,7 @@ See documentation: https://www.algolia.com/doc/guides/building-search-ui/going-f

await wait(0);

expect(instantSearchInstance.helper!.state.page).toEqual(100);
expect(instantSearchInstance.mainHelper!.state.page).toEqual(100);
expect(getUserToken()).toEqual('def');
});

Expand Down Expand Up @@ -774,7 +776,8 @@ See documentation: https://www.algolia.com/doc/guides/building-search-ui/going-f
await wait(0);

expect(
(instantSearchInstance.helper!.state as PlainSearchParameters).userToken
(instantSearchInstance.mainHelper!.state as PlainSearchParameters)
.userToken
).toEqual('def');
});

Expand Down Expand Up @@ -1183,7 +1186,7 @@ See documentation: https://www.algolia.com/doc/guides/building-search-ui/going-f

instantSearchInstance
.helper!.setState({
...instantSearchInstance.helper!.state,
...instantSearchInstance.mainHelper!.state,
query: 'test',
})
.search();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export function createInsightsMiddleware<
started() {
insightsClient('addAlgoliaAgent', 'insights-middleware');

helper = instantSearchInstance.helper!;
helper = instantSearchInstance.mainHelper!;

initialParameters = {
userToken: (helper.state as PlainSearchParameters).userToken,
Expand Down
5 changes: 4 additions & 1 deletion packages/instantsearch.js/src/widgets/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,10 @@ const index = (widgetParams: IndexWidgetParams): IndexWidget => {
};

derivedHelper = mainHelper.derive(() =>
mergeSearchParameters(...resolveSearchParameters(this))
mergeSearchParameters(
mainHelper.state,
...resolveSearchParameters(this)
)
);

const indexInitialResults =
Expand Down
4 changes: 2 additions & 2 deletions tests/common/widgets/current-refinements/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function createOptionsTests(
<span
class="ais-CurrentRefinements-categoryLabel"
>
Apple
Samsung
</span>
<button
class="ais-CurrentRefinements-delete"
Expand All @@ -146,7 +146,7 @@ export function createOptionsTests(
<span
class="ais-CurrentRefinements-categoryLabel"
>
Samsung
Apple
</span>
<button
class="ais-CurrentRefinements-delete"
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,18 @@
"@algolia/logger-common" "4.14.3"
"@algolia/requester-common" "4.14.3"

"@algolia/ui-components-highlight-vdom@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@algolia/ui-components-highlight-vdom/-/ui-components-highlight-vdom-1.2.1.tgz#c430c9f090ef8c68477ef4b685324ed231ce0c13"
integrity sha512-IlYgIaCUEkz9ezNbwugwKv991oOHhveyq6nzL0F1jDzg1p3q5Yj/vO4KpNG910r2dwGCG3nEm5GtChcLnarhFA==
"@algolia/ui-components-highlight-vdom@^1.2.2":
version "1.2.2"
resolved "https://registry.npmjs.org/@algolia/ui-components-highlight-vdom/-/ui-components-highlight-vdom-1.2.2.tgz#913ac447e41afc79dcbd95ca37531bbfbdb81cfe"
integrity sha512-/+7jh7cd5rR2yQC7ME4SDcnAMiD1Ofn5Qq+E7afTJx9XSMOHkLR77/o6YcuJ60TfD1S+9lr7yjBLACon8gOuzQ==
dependencies:
"@algolia/ui-components-shared" "1.2.1"
"@algolia/ui-components-shared" "1.2.2"
"@babel/runtime" "^7.0.0"

"@algolia/ui-components-shared@1.2.1", "@algolia/ui-components-shared@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@algolia/ui-components-shared/-/ui-components-shared-1.2.1.tgz#62e3a04fc11623f149312942cd764d4528dd994c"
integrity sha512-a7mYHf/GVQfhAx/HRiMveKkFvHspQv/REdG+C/FIOosiSmNZxX7QebDwJkrGSmDWdXO12D0Qv1xn3AytFcEDlQ==
"@algolia/ui-components-shared@1.2.2", "@algolia/ui-components-shared@^1.2.2":
version "1.2.2"
resolved "https://registry.npmjs.org/@algolia/ui-components-shared/-/ui-components-shared-1.2.2.tgz#ec49246e2de7d0461cdeadf2e7742d2f2c7c0bd9"
integrity sha512-FYwEG5sbr8p4V8mqP0iUaKgmWfcrMXRXwp7e6iBuB65P/7QyL8pT4I6/iGb85Q5mNH+UtYYSmLZhKjEblllKEQ==

"@ampproject/remapping@^2.2.0":
version "2.2.1"
Expand Down Expand Up @@ -11663,7 +11663,7 @@ cliui@^6.0.0:
wrap-ansi "^6.2.0"

cliui@^7.0.2:
version "7.1.0"
version "7.0.4"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f"
integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==
dependencies:
Expand Down

0 comments on commit 8ea7e44

Please sign in to comment.