dec0dOS / zero-ui

ZeroUI - ZeroTier Controller Web UI - is a web user interface for a self-hosted ZeroTier network controller.
GNU General Public License v3.0
912 stars 146 forks source link

Test/front end tests #158

Open davidlag0 opened 1 year ago

davidlag0 commented 1 year ago

Pull Request type

Please check the type of change your PR introduces:

What is the current behavior?

Issue Number: #135

What is the new behavior?

Does this introduce a breaking change?

Other information

Regarding Bar.jsx, I will need help understanding how lines 96, 102, and 137 should run. I was not able to find such cases so I could not build tests to cover these specific lines. Testing is mostly done from the perspective of the user and a bit more deeply for utility functions. If a code path in a frontend component cannot be reached, potential refactoring might be required.

dec0dOS commented 1 year ago

Thanks for your PR, @davidlag0!

Regarding Bar.jsx, I will need help understanding how lines 96, 102, and 137 should run

Could you write down your question in detail, please? Could not find figure out what is the problem with these lines.

davidlag0 commented 1 year ago

Thanks for your PR, @davidlag0!

Regarding Bar.jsx, I will need help understanding how lines 96, 102, and 137 should run

Could you write down your question in detail, please? Could not find figure out what is the problem with these lines.

Yes, where should I click in the UI to be able to run the code on lines 96, 102 and 137? To run all the other code, for example, I simulate a logged in user and the click on the menu to show the "Log out" choice then click on it, etc. I haven't found how I'm able to use the UI to reach the code paths that would include lines 96, 102 and 137. If there's a way and you can tell me, I will simply write tests catered to these lines. If there is no way to have these lines executed by using the UI, often, it is a sign that refactoring is required, potentially to remove some code that cannot be reached.

Thanks!

dec0dOS commented 1 year ago

This code path couldn't be reached now, as it should be used for internal pages that are currently absent: https://github.com/dec0dOS/zero-ui/blob/8785b94392e5de87b21fa93c81752ef67acc10f1/frontend/src/components/Bar/Bar.jsx#L45-L49

The current PR version looks good to me.