Skip to content

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

Merged
merged 22 commits into from
Apr 16, 2025
Merged

Button disabler in typescript #2996

merged 22 commits into from
Apr 16, 2025

Conversation

Iru89
Copy link
Contributor

@Iru89 Iru89 commented Mar 25, 2025

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
  • create renderWithBotonicProviders to render a webchat component inside the providers for testing

Testing

The pull request...

  • has unit tests
  • has integration tests
  • doesn't need tests because... [provide a description]

@pull-request-size pull-request-size bot added size/L and removed size/M labels Mar 31, 2025
@Iru89 Iru89 marked this pull request as ready for review March 31, 2025 14:13
@Iru89 Iru89 requested a review from asastre March 31, 2025 14:13
Copy link
Contributor

@Copilot Copilot AI left a 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()

Base automatically changed from refactor-theme-button-style to master-lts April 16, 2025 09:51
@Iru89 Iru89 merged commit f6ed4c9 into master-lts Apr 16, 2025
3 of 4 checks passed
@Iru89 Iru89 deleted the button-disabler-in-typescript branch April 16, 2025 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants