r3bl-org/r3bl-open-core

Add tests for existing functionality

Opened this issue · 2 comments

@nazmulidris
i am new to base source, could you please address which are functionality that need to add test.
i mean i should start somewhere, to get familiar with the source code

willing to help

@0xkelvin Thank you. Here is a good place to get started to get a handle on terminals and TUIs: https://github.com/r3bl-org/onboarding

In the current tuify codebase we have tests in the following files:

  1. https://github.com/r3bl-org/r3bl_rs_utils/blob/main/tuify/src/components/select_component.rs#L213
  2. https://github.com/r3bl-org/r3bl_rs_utils/blob/main/tuify/src/scroll.rs#L128

There need to more tests to check things that a user would perform, such as try and select a single item. There's the happy path. Where they have a few items and enough display viewport size to see them all without scrolling. Then they make their selection or not, and we are done.

  • In these cases the tests can check whether moving up and down w/ the cursor is working.
  • Whether things are rendered correctly as the focus state changes.
  • And finally if the selection actually selects the right thing.

You can see in some tests the following trait is mocked https://github.com/r3bl-org/r3bl_rs_utils/blob/main/tuify/src/components/select_component.rs#L26 so that you can check what its contents are (very similar to ReactJS snapshot tests). In these cases, it is important to override the color support, since we run all tests in CI/CD and they don't all support color output. This is done in one of the tests listed above.

Here are all the paths that I've been manually testing:
https://github.com/r3bl-org/r3bl_rs_utils/blob/main/tuify/examples/main_interactive.rs#L53

It would be great to automate those testing paths.

PLMK if you have any questions 👍🏽 . And we have a discord server if you would like to chat (more sync than async like issues) about the issue or PR.