Skip to content

Commit

Permalink
Merge branch 'master' into feat/import-process
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv authored Nov 24, 2022
2 parents b90acf1 + f651009 commit d4dda1e
Show file tree
Hide file tree
Showing 16 changed files with 162 additions and 1,415 deletions.
2 changes: 1 addition & 1 deletion examples/js/calendar-widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"instantsearch.js": "4.49.1"
},
"devDependencies": {
"@babel/core": "7.12.0",
"@babel/core": "7.15.0",
"@parcel/packager-raw-url": "2.8.0",
"@parcel/transformer-webmanifest": "2.8.0",
"parcel": "2.8.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/js/e-commerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"instantsearch.js": "4.49.1"
},
"devDependencies": {
"@babel/core": "7.12.0",
"@babel/core": "7.15.0",
"@parcel/packager-raw-url": "2.8.0",
"@parcel/transformer-webmanifest": "2.8.0",
"parcel": "2.8.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/js/media/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"instantsearch.js": "4.49.1"
},
"devDependencies": {
"@babel/core": "7.12.0",
"@babel/core": "7.15.0",
"@parcel/packager-raw-url": "2.8.0",
"@parcel/transformer-webmanifest": "2.8.0",
"parcel": "2.8.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/js/tourism/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"instantsearch.js": "4.49.1"
},
"devDependencies": {
"@babel/core": "7.12.0",
"@babel/core": "7.15.0",
"@parcel/packager-raw-url": "2.8.0",
"@parcel/transformer-webmanifest": "2.8.0",
"parcel": "2.8.0"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"devDependencies": {
"@babel/cli": "7.8.4",
"@babel/core": "7.12.0",
"@babel/core": "7.15.0",
"@babel/plugin-proposal-class-properties": "7.8.3",
"@babel/plugin-transform-react-constant-elements": "7.9.0",
"@babel/preset-env": "7.9.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import connectAnswers from '../connectAnswers';

const defaultRenderDebounceTime = 10;
const defaultSearchDebounceTime = 10;
const waitForDebounceTime =
defaultRenderDebounceTime + defaultSearchDebounceTime + 80;

describe('connectAnswers', () => {
describe('Usage', () => {
Expand Down Expand Up @@ -236,7 +238,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/answers/js/
false
);

await wait(30); // 10(render debounce) + 10(search debounce) + 10(just to make sure)
await wait(waitForDebounceTime);

// render with hits
const expectedHits = [{ title: '', objectID: 'a', __position: 1 }];
Expand Down Expand Up @@ -299,8 +301,8 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/answers/js/
// no debounce for rendering loader
expect(renderFn).toHaveBeenCalledTimes(3);

// wait for debounce
await wait(30);
await wait(waitForDebounceTime);

const expectedHits = [{ title: '', objectID: 'a', __position: 1 }];
expect(renderFn).toHaveBeenCalledTimes(4);
expect(renderFn).toHaveBeenNthCalledWith(
Expand All @@ -312,8 +314,8 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/answers/js/
false
);

// wait
await wait(30);
await wait(waitForDebounceTime);

// but no more rendering
expect(renderFn).toHaveBeenCalledTimes(4);
});
Expand Down Expand Up @@ -421,7 +423,8 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/answers/js/
},
});

await wait(30);
await wait(waitForDebounceTime);

const expectedHits = [{ title: '', objectID: 'a', __position: 1 }];
expect(
widget.getWidgetRenderState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ beforeEach(() => {
window.history.pushState({}, '', '/');
});

const writeDelay = 10;
const writeWait = 10 * writeDelay;

test('correct URL for widgets', async () => {
const writeDelay = 10;
const router = historyRouter({ writeDelay });

const indexName = 'indexName';
Expand All @@ -40,15 +42,14 @@ test('correct URL for widgets', async () => {
// on main index
search.renderState[indexName].pagination!.refine(39);

await wait(20);
await wait(writeWait);

expect(window.location.search).toBe(
`?${encodeURI('indexName[page]=40&indexName[query]=test')}`
);
});

test('correct URL for widgets in indices with repeated indexId', async () => {
const writeDelay = 10;
const router = historyRouter({ writeDelay });

const indexName = 'indexName';
Expand All @@ -74,7 +75,7 @@ test('correct URL for widgets in indices with repeated indexId', async () => {
// on main index
search.renderState[indexName].pagination!.refine(39);

await wait(20);
await wait(writeWait);

expect(window.location.search).toBe(
`?${encodeURI('indexName[page]=40&indexName[query]=test')}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type InstantSearch from '../../InstantSearch';
/* eslint no-lone-blocks: "off" */

const writeDelay = 10;
const writeWait = 1.5 * writeDelay;
const writeWait = 10 * writeDelay;

const addWidgetsAndStart = (search: InstantSearch) => {
search.addWidgets([connectSearchBox(() => {})({})]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { connectPagination, connectSearchBox } from '../../../connectors';
/* eslint no-lone-blocks: "off" */

const writeDelay = 10;
const writeWait = 1.5 * writeDelay;
const writeWait = 10 * writeDelay;

test('does not write the same URL twice', async () => {
// -- Flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { connectSearchBox } from '../../../connectors';
/* eslint no-lone-blocks: "off" */

const writeDelay = 10;
const writeWait = 1.5 * writeDelay;
const writeWait = 10 * writeDelay;

describe('routing with external influence', () => {
test('keeps on working when the URL is updated by another program', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { connectSearchBox } from '../../../connectors';
/* eslint no-lone-blocks: "off" */

const writeDelay = 10;
const writeWait = 1.5 * writeDelay;
const writeWait = 10 * writeDelay;

describe('routing with no navigation', () => {
test('cleans the URL when InstantSearch is disposed within the same page', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { connectSearchBox } from '../../../connectors';
/* eslint no-lone-blocks: "off" */

const writeDelay = 10;
const writeWait = 1.5 * writeDelay;
const writeWait = 10 * writeDelay;

describe('routing with debounced third-party client-side router', () => {
test('does not clean the URL after navigating', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { connectSearchBox } from '../../../connectors';
/* eslint no-lone-blocks: "off" */

const writeDelay = 10;
const writeWait = 1.5 * writeDelay;
const writeWait = 10 * writeDelay;

describe('routing using `replaceState`', () => {
// We can't assert whether another router did update the URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { connectSearchBox } from '../../../connectors';
/* eslint no-lone-blocks: "off" */

const writeDelay = 10;
const writeWait = 1.5 * writeDelay;
const writeWait = 10 * writeDelay;

describe('routing with third-party client-side router', () => {
test('does not clean the URL after navigating', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/answers/js/
);
expect(answersContainer.querySelector('.root')).toHaveClass('empty');

await wait(30);
await wait(100);

// debounced render
expect(answersContainer.querySelector('.root')).not.toHaveClass('empty');
Expand Down
Loading

0 comments on commit d4dda1e

Please sign in to comment.