Skip to content
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

Test: chatdisabledProcessor #188

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

deeola
Copy link
Contributor

@deeola deeola commented Oct 10, 2024

Description

Unit test for ChatDisabledProcessor

Closes #(issue)

#169

Please select the relevant option(s).

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (changes to docs/code comments)

What is the proposed approach?

Tested for the following

  • Do nothing is block.chatDisabled is null
  • Call setTextAreaDisabled with the boolean value if block.chatDisabled is a boolean
  • Call setTextAreaDisabled with the return value of a function if block.chatDisabled is a function
  • Await the promise if block.chatDisabled is a function that returns a promise
  • Call setTextAreaDisabled with null if block.chatDisabled is a function returning null
  • Handle errors when block.chatDisabled function throws an error
  • Handle promise rejection if block.chatDisabled function returns a rejected promise
  • Handle unexpected data type for block.chatDisabled (e.g., an object)

Checklist:

  • The commit message follows our adopted guidelines
  • Testing has been done for the change(s) added (for bug fixes/features)
  • Relevant comments/docs have been added/updated (for bug fixes/features)

@@ -19,7 +19,7 @@ export type Block = {
((params: Params) => Promise<{items: Array<string>, max?: number, min?: number, sendOutput?: boolean, reusable?: boolean}>);
component?: JSX.Element | void | ((params: Params) => JSX.Element | void) |
((params: Params) => Promise<JSX.Element | void>);
chatDisabled?: boolean | ((params: Params) => boolean) | ((params: Params) => Promise<boolean>);
chatDisabled?: boolean | ((params: Params) => boolean) | ((params: Params) => Promise<boolean>) | null;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason this was added? For chatDisabled, it should only take in a boolean value or a function that returns a boolean value.

Copy link
Owner

@tjtanjin tjtanjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't expect block.chatDisabled to be null, so the Block type shouldn't be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants