You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue aims to implement unit tests for the “check” method of the PermissionsService class, using Jest with coverage reporting generation. The method is central to defining authorization rules and covers several permission validation scenarios. Due to its complexity, it is essential to test all conditions and flows to ensure the robustness of the system.
🎤 Why is this feature needed ?
The “check” method determines access based on multiple parameters and rules, such as checking limits (number of channels, posts per month, webhooks) and special permissions (ADMIN, SUPERADMIN, etc.).
Lack of testing can cause failures in validating permissions, leading to security problems and the introduction of bugs in future changes or refactorings.
Covering logic flows with unit tests will allow for early detection of regressions and ensure that future changes do not compromise the integrity of the system.
Implementation with Jest integrating a code coverage threshold (through CI) will ensure a minimum level of quality and reliability in the code.
Implementation with Jest integrating a code coverage threshold (through CI) will ensure a minimum level of quality and reliability in the code.
✌️ How do you aim to achieve this?
Create scenarios where the list of requested permissions is empty or when the STRIPE_PUBLISHABLE_KEY variable is not defined, to validate the initial flow of the method.
Simulate cases for each condition evaluated:
CHANNEL: Check the channel count and whether validation logic (using options and the integration signature) is applied correctly.
WEBHOOKS: Simulate conditions where the total number of webhooks is less than the limit defined in the options.
POSTS_PER_MONTH: Test the post count based on a base date and comparison with the monthly limit.
TEAM_MEMBERS, ADMIN, COMMUNITY_FEATURES, FEATURED_BY_GITROOM, AI and IMPORT_FROM_CHANNELS: Analyze whether the permission logic is correctly triggered according to specific conditions.
Generate coverage reports:
Configure Jest to run with the coverage flag, ensuring that all “check” method routes are exercised.
🔄️ Additional Information
Implementing these tests not only improves the reliability of the permissions system but also encourages a culture of testing in the project, facilitating early detection of failures and community collaboration for future improvements.
👀 Have you spent some time to check if this feature request has been raised before?
I checked and didn't find similar issue
Are you willing to submit PR?
Yes I am willing to submit a PR!
The text was updated successfully, but these errors were encountered:
🔖 Feature description
This issue aims to implement unit tests for the “check” method of the PermissionsService class, using Jest with coverage reporting generation. The method is central to defining authorization rules and covers several permission validation scenarios. Due to its complexity, it is essential to test all conditions and flows to ensure the robustness of the system.
🎤 Why is this feature needed ?
Implementation with Jest integrating a code coverage threshold (through CI) will ensure a minimum level of quality and reliability in the code.
✌️ How do you aim to achieve this?
Simulate cases for each condition evaluated:
Configure Jest to run with the coverage flag, ensuring that all “check” method routes are exercised.
🔄️ Additional Information
Implementing these tests not only improves the reliability of the permissions system but also encourages a culture of testing in the project, facilitating early detection of failures and community collaboration for future improvements.
👀 Have you spent some time to check if this feature request has been raised before?
Are you willing to submit PR?
Yes I am willing to submit a PR!
The text was updated successfully, but these errors were encountered: