react-chatbotify icon indicating copy to clipboard operation
react-chatbotify copied to clipboard

[Task] Add unit test cases for useSubmitInputInternal hook

Open tjtanjin opened this issue 1 year ago • 7 comments

Task Description: Currently, we run unit tests using jest which can be found here.

However, the test cases are not yet comprehensive enough and work can be done to cover more grounds. Specifically for this issue, we hope to add test cases for the useSubmitInputInternal hook.

Deliverable(s): New unit test cases that cover the testing of the useSubmitInputInternal hook.

Additional Context:

  • Hooks API can be found here
  • Existing unit test for hooks can be found here which may serve as a good source for reference.

tjtanjin avatar Oct 06 '24 07:10 tjtanjin

Task Description: Currently, we run unit tests using jest which can be found here.

However, the test cases are not yet comprehensive enough and work can be done to cover more grounds. Specifically for this issue, we hope to add test cases for the useSubmitInputInternal hook.

Deliverable(s): New unit test cases that cover the testing of the useSubmitInputInternal hook.

Additional Context:

  • Hooks API can be found here
  • Existing unit test for hooks can be found here which may serve as a good source for reference.

I can try this. Please assign.

anjumnnit avatar Oct 17 '24 15:10 anjumnnit

Task Description: Currently, we run unit tests using jest which can be found here.

However, the test cases are not yet comprehensive enough and work can be done to cover more grounds. Specifically for this issue, we hope to add test cases for the useSubmitInputInternal hook.

Deliverable(s): New unit test cases that cover the testing of the useSubmitInputInternal hook.

Additional Context:

  • Hooks API can be found here
  • Existing unit test for hooks can be found here which may serve as a good source for reference.

I can try this. Please assign.

Go for it!

tjtanjin avatar Oct 18 '24 04:10 tjtanjin

I worked on it but still facing some issue. you can assign it to someone else thankyou.

anjumnnit avatar Oct 24 '24 10:10 anjumnnit

@tjtanjin, hello,

I'd like to work on this one, if that's ok!

mashazyu avatar Oct 29 '24 16:10 mashazyu

@tjtanjin, hello,

I'd like to work on this one, if that's ok!

Go for it!

tjtanjin avatar Oct 29 '24 17:10 tjtanjin

@tjtanjin

I pushed some initial tests for the hook. While I was working on the tests I realized I have a question that I want to clarify before I move any further - how far should I go with the tests? I see that this hook uses values and triggers a lot of other contexts and hooks. So should I write tests for all/some of those calls as well?

Below is the list of those

import { usePathsInternal } from "./usePathsInternal";
import { useMessagesInternal } from "./useMessagesInternal";
import { useRcbEventInternal } from "./useRcbEventInternal";
import { useVoiceInternal } from "./useVoiceInternal";
import { useTextAreaInternal } from "./useTextAreaInternal";
import { useChatWindowInternal } from "./useChatWindowInternal";
import { useToastsInternal } from "./useToastsInternal";
import { useBotStatesContext } from "../../context/BotStatesContext";
import { useBotRefsContext } from "../../context/BotRefsContext";
import { useSettingsContext } from "../../context/SettingsContext";

mashazyu avatar Oct 30 '24 11:10 mashazyu

@tjtanjin

I pushed some initial tests for the hook. While I was working on the tests I realized I have a question that I want to clarify before I move any further - how far should I go with the tests? I see that this hook uses values and triggers a lot of other contexts and hooks. So should I write tests for all/some of those calls as well?

Below is the list of those

import { usePathsInternal } from "./usePathsInternal";
import { useMessagesInternal } from "./useMessagesInternal";
import { useRcbEventInternal } from "./useRcbEventInternal";
import { useVoiceInternal } from "./useVoiceInternal";
import { useTextAreaInternal } from "./useTextAreaInternal";
import { useChatWindowInternal } from "./useChatWindowInternal";
import { useToastsInternal } from "./useToastsInternal";
import { useBotStatesContext } from "../../context/BotStatesContext";
import { useBotRefsContext } from "../../context/BotRefsContext";
import { useSettingsContext } from "../../context/SettingsContext";

Hey @mashazyu! The tests should be scoped to just the logic within the hook itself. For other contexts and hooks that it relies on, those should be mocked (testing for these other parts are done within their own test cases).

tjtanjin avatar Oct 30 '24 19:10 tjtanjin

I'd love to contribute to this issue by writing unit tests for the useSubmitInputInternal hook. I’ll mock the dependent hooks and contexts as suggested, and focus the tests on the internal logic — including input submission, message handling, and edge cases.

Anuj092 avatar Aug 07 '25 17:08 Anuj092

Closing this stale issue, will re-create a fresh one.

tjtanjin avatar Sep 26 '25 18:09 tjtanjin