Skip to content

Conversation

@arshalik1111-design
Copy link
Collaborator

@arshalik1111-design arshalik1111-design commented Dec 10, 2025

Summary This PR increases test coverage for user_groups.js by adding unit tests for group structure queries and membership flags (e.g., is_setting_group_empty, is_user_in_setting_group).
Technical Details

  • Restored System Groups: I explicitly restored standard system groups (Admins, Moderators, etc.) in user_groups.test.cjs. This ensures backward compatibility with existing legacy tests that rely on these groups being present in the global scope.

  • New Tests: Added the structure_and_flags test block to verify logic for checking empty groups and user membership.

  • Scope Note: I originally intended to test format_group_list (display settings). However, I have omitted those specific tests in this PR because the function requires complex user_settings locale initialization that conflicted with the legacy test runner. I prioritized robust logic coverage for structure and flags.

Manual Testing

  • Ran ./tools/test-js-with-node user_groups locally.

  • Verified 100% pass rate (All checks green).

Fixes Fixes #33208

Visuals
There are no UI/Visual changes.

Self-review checklist
  • Self-reviewed the changes for clarity and maintainability (variable names, code reuse, readability, etc.).

Communicate decisions, questions, and potential concerns

  • Explains differences from previous plans (e.g., issue description).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.

Individual commits are ready for review (see commit discipline)

  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following

  • Visual appearance of the changes.
  • Responsiveness and internationalization.
  • Strings and tooltips.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

@alya
Copy link
Contributor

alya commented Dec 16, 2025

Thanks! Please go through our guide on submitting a pull request to learn how to present your proposed changes to Zulip, so that your work can be reviewed.

@alya alya added the not ready Needs work to be ready for maintainer review. label Dec 16, 2025
@arshalik1111-design arshalik1111-design marked this pull request as draft December 16, 2025 08:09
@arshalik1111-design arshalik1111-design force-pushed the add-user-groups-tests branch 4 times, most recently from 6b4aeb6 to e68a7de Compare December 16, 2025 09:08
@arshalik1111-design arshalik1111-design marked this pull request as ready for review December 16, 2025 09:41
@arshalik1111-design
Copy link
Collaborator Author

Ready for review!

I have squashed the commits into a single atomic commit (tests: Add unit tests for user_groups structure and flags) and added Fixes #33208 to the commit message.

As noted in the description, I focused this PR on testing the structure and flags logic to ensure stability, while omitting the display formatter tests to avoid dependencies on the legacy locale setup. All tests are passing.

@alya
Copy link
Contributor

alya commented Dec 16, 2025

Please fill out the self-review checklist, which is for some reason missing from the PR description.

Your commit message still isn't formatted correctly.

@alya
Copy link
Contributor

alya commented Dec 16, 2025

You can ping @shubham-padia for maintainer review when ready.

@arshalik1111-design arshalik1111-design marked this pull request as draft December 17, 2025 02:52
…etting

Add comprehensive unit tests for user_groups.js, covering:
- Group lifecycle (add_user_group, remove_user_group)
- Member and subgroup management
- Property updates (update_user_group_properties)
- Getters, queries, and helper functions (is_empty_group, misc_helpers)
- Structure and flags logic

Fixes zulip#33208
@arshalik1111-design arshalik1111-design marked this pull request as ready for review December 17, 2025 11:51
@arshalik1111-design
Copy link
Collaborator Author

@shubham-padia This is ready for maintainer review.

@shubham-padia shubham-padia self-assigned this Dec 22, 2025
Copy link
Member

@shubham-padia shubham-padia left a comment

Choose a reason for hiding this comment

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

I left a comment on the first test, but my recommendation here is to split each new test in a new commit, then go through each commit yourself one-by-one, study the code your test is testing against and make sure all testable scenarios are covered in that test.

Go through the original code slowly, see all the possible scenarios and then add comprehensive tests for it.

),
true,
);
});
Copy link
Member

Choose a reason for hiding this comment

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

For this test, we need to check allowed_system_groups, realm_waiting_period_threshold and all scenarios of for_new_settings_ui (it being both true and false for different if blocks.

@shubham-padia
Copy link
Member

@arshalik1111-design If you're forfeiting the issue, closing the PR is fine. If you plan to make the changes, please don't close and open a different PR. You can force push any changes you want to this PR itself.

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

Labels

not ready Needs work to be ready for maintainer review. size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restore complete node test coverage on user_groups.ts

4 participants