-
Notifications
You must be signed in to change notification settings - Fork 94
Button disabler in typescript #2996
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
Conversation
…d defaultTheme for intital theme
…chatState inside the context and inside ThemeProvider
…ault value is defined in defaultTheme
…Picker, enableAttachments, enableUserInput and enableAnimations from WebchatProps and pass it inside theme
…atchments and emojiPicker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
A refactor to use TypeScript for the ButtonDisabler class and update tests to use Testing Library instead of react-test-renderer. Key changes include:
- Conversion of ButtonDisabler and related components to TypeScript with more explicit typings.
- Updates to test files to use Testing Library and a new helper (renderWithBotonicProviders) for wrapping webchat components.
- Minor adjustments in utility and configuration files (Jest setup and config).
Reviewed Changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
packages/botonic-react/tests/webchat/buttons-disabler.test.jsx | Converted snapshot tests to Testing Library based tests and added attribute checks for button props. |
packages/botonic-react/tests/helpers/render-webchat-with-providers.jsx | Added a new helper to render components with required context providers. |
packages/botonic-react/src/components/index-types.ts | Updated type for disabledstyle to support a record or string instead of a boolean. |
packages/botonic-react/src/components/buttons-disabler.ts | Added explicit type definitions for functions and parameters; removed unused parameters in getUpdatedMessage. |
packages/botonic-react/src/components/button/index.tsx | Adjusted Button to use the updated construction of node props and removed usage of resolveDisabling. |
packages/botonic-react/jest.setup.js & jest.config.js | Added testing-library setup configuration. |
packages/botonic-core/src/utils.ts | Updated comment regarding the isBrowser check in Jest. |
Files not reviewed (2)
- packages/botonic-react/package.json: Language not supported
- packages/botonic-react/tests/webchat/snapshots/buttons-disabler.test.jsx.snap: Language not supported
Comments suppressed due to low confidence (1)
packages/botonic-react/tests/helpers/render-webchat-with-providers.jsx:22
- The useWebchat hook is called before the WebchatContext.Provider is defined; this may cause unexpected behavior if the hook depends on a provided context. Consider obtaining the context value from above or providing a default context to avoid potential issues.
const webchatContext = useWebchat()
Description
Use typescript in ButtonDisabler class
First commit only change extension to .ts in the other commit you can view the real changes.
Update tests
buttons-diabler.test.jsx
using@testing-library/react
renderWithBotonicProviders
to render a webchat component inside the providers for testingTesting
The pull request...