Skip to content

fix: address review findings and add tests for spp_cel_registry_search#105

Open
gonzalesedwin1123 wants to merge 3 commits into19.0from
feat/spp-cel-registry-search-stable-release
Open

fix: address review findings and add tests for spp_cel_registry_search#105
gonzalesedwin1123 wants to merge 3 commits into19.0from
feat/spp-cel-registry-search-stable-release

Conversation

@gonzalesedwin1123
Copy link
Member

Summary

Comprehensive review and fixes for spp_cel_registry_search in preparation for stable release. The module was analyzed by staff engineer and UX expert reviewers, and all findings were addressed.

Manifest & Configuration

  • Change auto_install: TrueFalse — this is a feature module, not a bridge/glue module. With auto_install: True, it silently installed in every deployment via spp_programs
  • Change category: "OpenSPP/Core""OpenSPP" — consistent with sibling CEL modules

UX & Accessibility Fixes

  • Remove duplicate static class attribute on result buttons (dead code alongside t-attf-class)
  • Add fa-ban icon to "Disabled" badge for colorblind accessibility
  • Remove incorrect role="status" from static empty state div (was triggering unnecessary screen reader announcements)
  • Replace r.monthly_income < 2500 example with r.registration_date > "2024-01-01"monthly_income is not a base field
  • Fix invisible hover effect on result items (hover color was identical to page background)

Bug Fixes

  • Fix error state showing misleading "0 Result(s) Found" — now resets hasSearched so the user sees the empty state instead of a false "no results" message
  • Improve catch error message from "Please check your expression" to "Please try again or check your expression" — the error may be a server/network issue, not the expression

Documentation

  • Update DESCRIPTION.md to remove stale auto-install reference
  • Regenerate README.rst and static/description/index.html

Tests

  • Add 12 tests covering security groups, client action, menu configuration, and role-based visibility
  • All tests pass, all pre-commit hooks pass

Test plan

  • ./scripts/test_single_module.sh spp_cel_registry_search — 12/12 pass
  • All pre-commit hooks pass (ruff, prettier, eslint, pylint, security checks)
  • QA manual verification of the search portal UI
  • QA to clear module for development_status upgrade to Production/Stable

- Change auto_install to False (feature, not bridge module)
- Change category from OpenSPP/Core to OpenSPP (consistent with siblings)
- Remove duplicate static class attribute on result buttons
- Add icon to Disabled badge for accessibility (colorblind users)
- Remove incorrect role="status" from static empty state
- Replace non-universal example expression (r.monthly_income)
- Fix error state showing misleading "0 results" instead of resetting
- Improve catch error message to not blame expression for server errors
- Fix invisible hover effect (same color as page background)
- Update DESCRIPTION.md and regenerate README.rst
- Add 12 tests covering security groups, client action, menu, visibility
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on stabilizing the spp_cel_registry_search module by integrating feedback from staff engineers and UX experts. The changes encompass critical configuration adjustments, significant user experience and accessibility improvements, and resolutions for identified bugs. Furthermore, the module's documentation has been updated, and extensive test coverage has been introduced to enhance reliability and ensure proper functionality across various user interactions and roles.

Highlights

  • Manifest & Configuration Updates: The auto_install setting was changed from True to False to prevent silent installation, and the module category was updated to 'OpenSPP' for consistency with other CEL modules.
  • UX & Accessibility Enhancements: Several user experience and accessibility issues were addressed, including removing duplicate CSS classes, adding a fa-ban icon to the 'Disabled' badge for colorblind users, removing an incorrect role="status" attribute, updating an example CEL expression, and fixing an invisible hover effect on result items.
  • Bug Fixes: The error state now correctly resets hasSearched to prevent misleading '0 Result(s) Found' messages, and the search error message was improved to suggest trying again or checking the expression.
  • Documentation Refresh: The README.rst, DESCRIPTION.md, and static/description/index.html files were updated to remove stale information, specifically regarding auto-installation and the monthly_income field.
  • Comprehensive Test Coverage: Twelve new tests were added to validate security groups, client action configuration, menu visibility, and role-based permissions, ensuring the module's stability and correct behavior.
Changelog
  • spp_cel_registry_search/README.rst
    • Removed references to 'income' from the search capabilities description.
    • Removed the statement about auto-installation when spp_cel_widget is present.
  • spp_cel_registry_search/manifest.py
    • Updated the module category from 'OpenSPP/Core' to 'OpenSPP'.
    • Changed auto_install from True to False.
  • spp_cel_registry_search/readme/DESCRIPTION.md
    • Removed references to 'income' from the search capabilities description.
    • Removed the statement about auto-installation when spp_cel_widget is present.
  • spp_cel_registry_search/static/description/index.html
    • Removed references to 'income' from the search capabilities description.
    • Removed the statement about auto-installation when spp_cel_widget is present.
  • spp_cel_registry_search/static/src/css/cel_search_portal.css
    • Adjusted the hover background color for list group items to improve visibility.
  • spp_cel_registry_search/static/src/js/cel_search_portal.js
    • Reset hasSearched to false when a search error occurs to correctly display the empty state.
    • Modified the search error message to suggest trying again or checking the expression.
  • spp_cel_registry_search/static/src/xml/cel_search_portal.xml
    • Removed a redundant class attribute from result buttons.
    • Added a fa-ban icon to the 'Disabled' badge for improved accessibility.
    • Removed the role="status" attribute from the empty state div to prevent unnecessary screen reader announcements.
    • Updated the example CEL expression from r.monthly_income < 2500 to r.registration_date > "2024-01-01".
  • spp_cel_registry_search/tests/init.py
    • Imported the new test_cel_registry_search module.
  • spp_cel_registry_search/tests/test_cel_registry_search.py
    • Added a new test file containing comprehensive tests for security groups, client action configuration, and menu item visibility based on user roles.
Activity
  • Review findings from staff engineers and UX experts were addressed and implemented.
  • All automated tests for the module passed successfully.
  • All pre-commit hooks passed without issues.
  • A test plan for manual QA verification and development status upgrade has been outlined for future steps.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request provides a comprehensive set of fixes and improvements for the spp_cel_registry_search module, including configuration changes, UX and accessibility enhancements, bug fixes, and documentation updates. A significant and valuable addition is the new test suite, which covers security, actions, and menu visibility, greatly improving the module's robustness. The changes are well-implemented and align with the descriptions. I've added a few suggestions to further improve code maintainability and test coverage.

Comment on lines +140 to 142
this.state.hasSearched = false;
this.state.results = [];
this.state.totalCount = 0;

Choose a reason for hiding this comment

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

medium

There's an opportunity to reduce code duplication. The state reset logic on these lines is identical to the one in the if (result.error) block (lines 120-122). Consider extracting this logic into a private helper method to improve maintainability, for example:

_resetErrorState() {
    this.state.hasSearched = false;
    this.state.results = [];
    this.state.totalCount = 0;
}

You could then call this._resetErrorState() in both error handling blocks.

Comment on lines +102 to +119
def test_menu_visible_to_cel_search_user(self):
"""A user with group_cel_search_user should see the menu."""
user = self.env["res.users"].create(
{
"name": "Test CEL Search User",
"login": "test_cel_search_user",
"group_ids": [
Command.link(self.env.ref("base.group_user").id),
Command.link(self.group_cel_search_user.id),
],
}
)
visible_menus = self.env["ir.ui.menu"].with_user(user).search([])
self.assertIn(
self.menu,
visible_menus,
"Menu should be visible to CEL Search users",
)

Choose a reason for hiding this comment

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

medium

The user creation logic is duplicated across test_menu_visible_to_cel_search_user, test_menu_visible_to_registry_officer, and test_base_user_does_not_have_cel_search_group. To improve maintainability and reduce boilerplate, consider creating a private helper method to create test users with specific groups. For example:

def _create_user(self, name, login, extra_groups=None):
    """Helper to create a test user."""
    group_ids = [Command.link(self.env.ref("base.group_user").id)]
    if extra_groups:
        group_ids.extend([Command.link(g.id) for g in extra_groups])
    return self.env["res.users"].create({
        "name": name,
        "login": login,
        "group_ids": group_ids,
    })

This would simplify your test setup significantly.

Comment on lines +156 to +159
self.assertFalse(
user.has_group("spp_cel_registry_search.group_cel_search_user"),
"Base user should not have CEL Search group",
)

Choose a reason for hiding this comment

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

medium

This test correctly verifies that a base user doesn't have the group_cel_search_user group. To make the test more comprehensive and directly test the security of the menu item, consider also asserting that the 'Advanced Search' menu is not visible to this user.

Suggested change
self.assertFalse(
user.has_group("spp_cel_registry_search.group_cel_search_user"),
"Base user should not have CEL Search group",
)
self.assertFalse(
user.has_group("spp_cel_registry_search.group_cel_search_user"),
"Base user should not have CEL Search group",
)
# Also verify that the menu is not visible
visible_menus = self.env["ir.ui.menu"].with_user(user).search([])
self.assertNotIn(
self.menu,
visible_menus,
"Menu should not be visible to a base user",
)

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.16%. Comparing base (9c2376e) to head (51b8bee).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             19.0     #105      +/-   ##
==========================================
- Coverage   71.17%   71.16%   -0.01%     
==========================================
  Files         704      705       +1     
  Lines       38554    38555       +1     
==========================================
  Hits        27439    27439              
- Misses      11115    11116       +1     
Flag Coverage Δ
spp_base_common 90.26% <ø> (ø)
spp_cel_registry_search 0.00% <ø> (?)
spp_programs 45.51% <ø> (ø)
spp_security 66.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
spp_cel_registry_search/__manifest__.py 0.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gonzalesedwin1123 gonzalesedwin1123 marked this pull request as ready for review March 13, 2026 05:09
The #### headings created level-4 RST titles that skipped level 3,
causing oca-gen-addon-readme to fail with "Inconsistent title style".
Convert subsection headings to bold text instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant