-
Notifications
You must be signed in to change notification settings - Fork 550
feat(instantsearch.js): introduce chat widget #6705
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
Merged
Merged
Changes from 109 commits
Commits
Show all changes
115 commits
Select commit
Hold shift + click to select a range
40636a0
feat(ui-components): introduce chat components
FabienMotte 6f1ed20
chore: add passphrase input
FabienMotte 0b70363
wip
Haroenv 78ed732
toggle and header part of satellite
Haroenv 62880e9
revert js example
shaejaz 9f83bde
revert react example
shaejaz 13b1e28
remove todo
shaejaz 556c1d0
remove toggle button duplicate
shaejaz 5d2e92b
add tests
shaejaz 6ceffff
update bundlesize
shaejaz dd12b04
fix lint
shaejaz b095c41
Merge branch 'master' into feat/chat-components
shaejaz 040c035
markdown
Haroenv 8adc9ef
add chat component
shaejaz 4b2531e
update chat message
shaejaz deb8c8a
fix polyfill errors
shaejaz 5ca5ec2
update lock file
shaejaz 000f255
add chat test
shaejaz adf7f8f
address comments
shaejaz 95a463e
address comments
shaejaz 032cd1d
add base lib in is.js
shaejaz c978854
add hook in react core
shaejaz 51f350f
add react widget
shaejaz c2df1ac
move transport handling to hook
shaejaz 205ab67
update types
shaejaz 2c7406e
export it anyway
Haroenv 8b26037
add chat component props
shaejaz 88cf87d
add refine button
shaejaz 69ab089
address comment
shaejaz 5cc91f7
add tests
shaejaz 2609211
update tools usage
shaejaz 09e8b51
fix ci
shaejaz e5e5259
fix type error
shaejaz e71e483
address comments
shaejaz 9041a1a
Merge branch 'master' into feat/react-chat
shaejaz 2229762
fix is version
shaejaz bfc6b25
just one zod
Haroenv 1dd7a0a
add more tests
shaejaz 729f629
use user provided search index tool
shaejaz 678e292
init
shaejaz 52ea485
remove stick to bottom hook
shaejaz 989b274
move ui to ui components
shaejaz 93d7756
add chat components
shaejaz f5b06d3
fix widget types
shaejaz 3fea3b3
forward props
shaejaz e82095a
wip: use ai dependency in connector
Haroenv e219a32
move usechat to react core
shaejaz c136118
remove is components and widgets
shaejaz ad39f22
remove unecessary react widgets
shaejaz 84b919c
fix test
shaejaz 3b1b853
deps
Haroenv 527a280
revert rollup alias
shaejaz 38c0d1c
init
shaejaz 373ce70
use carousel
shaejaz a39aece
add tools prop
shaejaz 3473921
add carousel default tool
shaejaz bfc6910
add transport to props
shaejaz d79465c
feat(react-instantsearch-ui): implement chat components design
FabienMotte 5cd47c9
chore: review considered
FabienMotte 72375c6
chore: review considered
FabienMotte 5da6059
remove
FabienMotte 692b1d0
chore: review considered
FabienMotte 3ddfcde
chore: review considered
FabienMotte 37ecdbd
chore: revert lock
FabienMotte 1b4c24f
chore: clean types
FabienMotte a493c5d
chore: fix types
FabienMotte 33da4d5
chore: clean comments
FabienMotte e83ff45
chore: fix conflicts
FabienMotte 002ce28
feat: add clear button
FabienMotte 69eecf6
feat: add default chat prompt disclaimer
FabienMotte 6d392a5
chore: revert
FabienMotte 3580993
chore: use polyfills
FabienMotte d7fc569
chore: revert
FabienMotte c59e143
chore: revert
FabienMotte 20d493f
feat: add header/prompt gradients
FabienMotte 8ef5bff
fix: chat prompt gradient z-index
FabienMotte 39dfe62
refactor: move `use-stick-to-bottom` to Chat widget
FabienMotte f17db28
chore: add `useStickToBottom` hook instead of lib
FabienMotte 87851d2
fix: mobile fixes
FabienMotte 37656d9
chore: update bundlesizes
FabienMotte daf1409
Merge master into feat/chat-design
FabienMotte fbafb54
test: fix
FabienMotte 85332c0
test: fix lint
FabienMotte 1808886
init
shaejaz b7da559
don't rerender in connector
shaejaz f6b3d06
add tools support
shaejaz cd70c1d
move open and input to connector
shaejaz 00a3b18
fix vue build
shaejaz d5ec6c4
fix build fr
shaejaz 49e4d4f
fine-tune connector implementation
dhayab 17c060e
add connector unit tests
dhayab 0bd250f
add connector cts tests
dhayab 19a0f02
fine-tune widget implementation
dhayab 3f7fe7f
add widget unit and cts tests
dhayab 1b0e11a
support maximized and clear in widget
dhayab 43716b2
test: fix
FabienMotte 14bcc15
Merge remote-tracking branch 'origin/feat/chat-design' into feat/js-chat
dhayab 59f864d
update widget test
dhayab 30b75dc
bump bundlesize
dhayab bfd906b
dont export chat in umd js bundle
dhayab 9842b33
silence issue with invalid ref in preact
dhayab bbda654
fix lint issues
dhayab b9443a4
more fixes?
dhayab 3ca11da
take 3
dhayab 209fd1c
Merge remote-tracking branch 'origin/master' into feat/js-chat
dhayab 8b37701
post-merge fixes
dhayab 3f656f1
delete remnant files
dhayab 1ba3d74
additional post-merge fixes
dhayab 894af6c
bump bundlesize
dhayab e384874
readjust bundlesize
dhayab 85fae59
Merge remote-tracking branch 'origin/master' into feat/js-chat
dhayab 5dc4944
ensure no dependency on ai in algolia-experiences
dhayab 3c26b90
ensure no dependency on ai in js storybook
dhayab 11cd5a2
ensure no dependency on ai in vue-instantsearch
dhayab 3c25444
apply suggestions
dhayab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
packages/instantsearch.js/src/connectors/chat/__tests__/connectChat-test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import { createSearchClient } from '@instantsearch/mocks'; | ||
| import algoliasearchHelper from 'algoliasearch-helper'; | ||
|
|
||
| import { | ||
| createInitOptions, | ||
| createRenderOptions, | ||
| } from '../../../../test/createWidget'; | ||
| import connectChat from '../connectChat'; | ||
|
|
||
| describe('connectChat', () => { | ||
| it('throws without render function', () => { | ||
| expect(() => { | ||
| // @ts-expect-error | ||
| connectChat()({}); | ||
| }).toThrowErrorMatchingInlineSnapshot(` | ||
| "The render function is not valid (received type Undefined). | ||
|
|
||
| See documentation: https://www.algolia.com/doc/api-reference/widgets/chat/js/#connector" | ||
| `); | ||
| }); | ||
|
|
||
| it('is a widget', () => { | ||
| const render = jest.fn(); | ||
| const unmount = jest.fn(); | ||
|
|
||
| const customChat = connectChat(render, unmount); | ||
| const widget = customChat({}); | ||
|
|
||
| expect(widget).toEqual( | ||
| expect.objectContaining({ | ||
| $$type: 'ais.chat', | ||
| init: expect.any(Function), | ||
| render: expect.any(Function), | ||
| dispose: expect.any(Function), | ||
| }) | ||
| ); | ||
| }); | ||
|
|
||
| it('Renders during init and render', () => { | ||
| const renderFn = jest.fn(); | ||
| const makeWidget = connectChat(renderFn); | ||
| const widget = makeWidget({ agentId: 'agentId' }); | ||
|
|
||
| // test if widget is not rendered yet at this point | ||
| expect(renderFn).toHaveBeenCalledTimes(0); | ||
|
|
||
| const helper = algoliasearchHelper(createSearchClient(), '', {}); | ||
| helper.search = jest.fn(); | ||
|
|
||
| widget.init(createInitOptions({ helper, state: helper.state })); | ||
|
|
||
| expect(renderFn).toHaveBeenCalledTimes(1); | ||
| expect(renderFn).toHaveBeenLastCalledWith( | ||
| expect.objectContaining({ widgetParams: { agentId: 'agentId' } }), | ||
| true | ||
| ); | ||
|
|
||
| const renderOptions = createRenderOptions({ helper }); | ||
| widget.render(renderOptions); | ||
|
|
||
| expect(renderFn).toHaveBeenCalledTimes(2); | ||
| expect(renderFn).toHaveBeenLastCalledWith( | ||
| expect.objectContaining({ widgetParams: { agentId: 'agentId' } }), | ||
| false | ||
| ); | ||
| }); | ||
|
|
||
| describe('dispose', () => { | ||
| it('calls the unmount function', () => { | ||
| const unmountFn = jest.fn(); | ||
| const makeWidget = connectChat(() => {}, unmountFn); | ||
| const widget = makeWidget({ agentId: 'agentId' }); | ||
|
|
||
| expect(unmountFn).toHaveBeenCalledTimes(0); | ||
|
|
||
| widget.dispose(); | ||
| expect(unmountFn).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| it('does not throw without the unmount function', () => { | ||
| const makeWidget = connectChat(() => {}); | ||
| const widget = makeWidget({ agentId: 'agentId' }); | ||
|
|
||
| expect(() => widget.dispose()).not.toThrow(); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.