Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General: Improve user administration #9533

Merged
merged 2 commits into from
Oct 24, 2024
Merged

Conversation

krusche
Copy link
Member

@krusche krusche commented Oct 20, 2024

Checklist

General

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data (e.g. using paging).
  • I strictly followed the principle of data economy for all client-server REST calls.
  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I documented the TypeScript code using JSDoc style.
  • I translated all newly inserted strings into English and German.

Motivation and Context

  • Allow admins to create internal users
  • Improve the user experience with the search

Steps for Testing

Prerequisites:

  • 1 Admin
  1. Navigate to server administration --> user management
  2. Create a new internal and a new external user
  3. Edit an existing internal and external user (make sure you cannot change the internal flag)
  4. Search for a few users including clicking on Search, Hitting Enter, clicking somewhere outside the search and using "Tab" to navigate out of the search field. In all cases the user list should quickly update

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Performance Review

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced user management form with dynamic labels for creating or editing users.
    • Improved user search functionality with responsive input handling and validation feedback.
    • Added radio button options for filtering users by roles, origins, and statuses.
  • Bug Fixes

    • Expanded email validation for better error handling in user forms.
    • Simplified logic for displaying search error messages.
  • Documentation

    • Updated localization strings for clarity regarding user editing and password management.

@krusche krusche requested a review from a team as a code owner October 20, 2024 11:12
@github-actions github-actions bot added the client Pull requests that update TypeScript code. (Added Automatically!) label Oct 20, 2024
@krusche krusche linked an issue Oct 20, 2024 that may be closed by this pull request
@krusche krusche added this to the 7.6.2 milestone Oct 20, 2024
Copy link

coderabbitai bot commented Oct 20, 2024

Walkthrough

The changes in this pull request involve updates to the user management components in an Angular application. Modifications include improved conditional rendering for creating and editing users, adjustments to form control initialization, and enhancements to user search functionality. The routing configuration has been refined to clarify the distinction between creating and editing users. Localization files have also been updated to reflect these changes, ensuring that user-facing strings are clear and specific. Overall, the updates focus on enhancing user experience and simplifying the management of user data.

Changes

File Change Summary
src/main/webapp/app/admin/user-management/user-management-update.component.html Updated conditional rendering for user creation/editing, removed two-way data binding for specific fields, and expanded error handling for the email input field.
src/main/webapp/app/admin/user-management/user-management-update.component.ts Removed CourseManagementService, updated form control initialization for activatedInput and internalInput with conditional logic based on user.id.
src/main/webapp/app/admin/user-management/user-management.component.html Changed search input event from (focusout) to (blur), added (keydown) event handler, and simplified error message logic. Enhanced modal structure for filtering users with additional options.
src/main/webapp/app/admin/user-management/user-management.component.ts Adjusted imports, updated searchControl properties, added searchInvalid property, modified loadAll method logic, and introduced onKeydown method for handling Enter key events.
src/main/webapp/app/admin/user-management/user-management.route.ts Modified routing configuration to clarify route titles for creating and editing users, preventing resolver caching for the :login parameter.
src/main/webapp/i18n/de/user-management.json Renamed "createOrEditLabel" to "editLabel" and expanded "passwordTooltip" for clarity.
src/main/webapp/i18n/en/user-management.json Changed "createOrEditLabel" to "editLabel", updated "passwordTooltip" for clarity, and removed duplicate "deleted" key from the JSON structure.

Possibly related PRs

Suggested labels

tests, ready for review, user interface, bugfix

Suggested reviewers

  • JohannesStoehr
  • SimonEntholzer
  • anian03
  • pzdr7

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (13)
src/main/webapp/app/admin/user-management/user-management.route.ts (2)

54-54: Approved: Improved clarity in route title.

The change from 'createOrEditLabel' to 'editLabel' for the edit route's pageTitle enhances clarity and aligns with the PR objective of refining the user experience. This distinction between creating and editing a user is a good improvement.

Consider updating the corresponding localization files to ensure the new 'editLabel' key is properly translated in all supported languages.


Line range hint 1-62: Approved: Well-structured routing configuration with good practices.

The overall routing configuration is well-structured and follows Angular best practices. It effectively prevents resolver caching, supports lazy loading, and promotes code reuse. The nested route structure for user management is clear and logical.

For consistency, consider using PascalCase for component names in the component properties, aligning with the TypeScript naming convention for classes. For example:

component: UserManagementUpdateComponent

This change would improve adherence to the coding guideline for PascalCase types (types:PascalCase).

src/main/webapp/i18n/en/user-management.json (1)

95-95: Approve with minor suggestion: Enhanced password tooltip.

The updated password tooltip provides clearer guidance on password change restrictions, which aligns well with the PR's objectives. This improvement will help administrators understand the limitations for different user types.

Consider removing the comma after "Notice" for better grammatical correctness:

-            "passwordTooltip": "This setting can only be changed for new users. Notice, that you can only change passwords for internal users.",
+            "passwordTooltip": "This setting can only be changed for new users. Notice that you can only change passwords for internal users.",
src/main/webapp/i18n/de/user-management.json (1)

96-96: LGTM with a minor suggestion: Clear explanation of password change limitations

The updated tooltip provides valuable information about password change limitations, using the required informal "du" form and gender-neutral language. This aligns well with the PR objectives and improves user administration clarity.

A minor suggestion to enhance clarity:

Consider rephrasing slightly for better flow:

- "Du kannst diese Einstellung nur für neue Nutzer:innen ändern. Bitte beachte, dass du nur Passwörter für interne Nutzer:innen ändern kannst."
+ "Du kannst Passwörter nur für neue, interne Nutzer:innen ändern. Für bestehende Nutzer:innen ist diese Einstellung nicht verfügbar."

This rephrasing combines the two sentences, making the limitation more explicit and easier to understand at a glance.

src/main/webapp/app/admin/user-management/user-management-update.component.ts (2)

236-236: LGTM: Improved form control initialization for internalInput with a minor suggestion.

The change to initialize internalInput with { value: this.user.internal, disabled: true } is a good practice. It correctly sets the initial value and disabled state of the form control.

Consider updating the comment to be more specific:

internalInput: [{ value: this.user.internal, disabled: true }], // Initially disabled, will be conditionally enabled/disabled based on user.id

This provides clearer context for the subsequent logic.


238-243: LGTM: Good implementation of conditional logic for internalInput, with a minor formatting issue.

The added conditional logic for enabling/disabling the internalInput form control based on this.user.id is well-implemented. It correctly differentiates between new and existing users, allowing only new users to set the internal flag.

There's a minor formatting inconsistency:

    if (this.user.id !== undefined) {
        this.editForm.get('internalInput')?.disable(); // Artemis does not support to edit the internal flag for existing users
    } else {
        this.editForm.get('internalInput')?.enable(); // New users can either be internal or external
    }

The indentation appears to be 4 spaces, while the rest of the file uses 2 spaces. Please adjust to maintain consistency with the file's formatting style.

src/main/webapp/app/admin/user-management/user-management-update.component.html (3)

90-90: LGTM: Simplified form control binding

The removal of [(ngModel)] in favor of using only formControlName for the internal checkbox aligns with best practices for reactive forms in Angular. This change simplifies the form control binding and improves consistency.

For even better consistency, consider updating the name attribute to match the formControlName:

- <input class="form-check-input" type="checkbox" id="internal" name="internal" formControlName="internalInput" />
+ <input class="form-check-input" type="checkbox" id="internal" name="internalInput" formControlName="internalInput" />

Line range hint 222-257: Remove redundant [(ngModel)] binding and LGTM on improved error handling

The email input field still contains both [(ngModel)] and formControlName bindings. To avoid potential conflicts and align with best practices for reactive forms, remove the [(ngModel)] binding:

- <input
-     id="email"
-     type="email"
-     class="form-control"
-     name="email"
-     [(ngModel)]="user.email"
-     formControlName="emailInput"
-     [minlength]="EMAIL_MIN_LENGTH"
-     required
-     [maxlength]="EMAIL_MAX_LENGTH"
-     email
- />
+ <input
+     id="email"
+     type="email"
+     class="form-control"
+     name="emailInput"
+     formControlName="emailInput"
+     [minlength]="EMAIL_MIN_LENGTH"
+     required
+     [maxlength]="EMAIL_MAX_LENGTH"
+     email
+ />

The expanded error handling for the email field is a great improvement. It now provides more specific feedback for various validation scenarios, enhancing the user experience.


Line range hint 1-294: Suggestion: Comprehensive update for form control consistency

While the changes made in this file improve certain aspects of the user management form, there are inconsistencies in how form controls are handled throughout the template. To ensure robust form validation and submission, consider performing a comprehensive update of all form controls:

  1. Use formControlName consistently for all form inputs, removing [(ngModel)] bindings.
  2. Update name attributes to match their corresponding formControlName values.
  3. Ensure all form controls are properly defined in the component's form group.
  4. Review and update error handling for all form fields to match the improved email field error handling.

This comprehensive update will align the entire template with Angular's reactive forms best practices and improve overall form consistency and maintainability.

src/main/webapp/app/admin/user-management/user-management.component.ts (2)

444-450: Improved search validation logic

The changes to the loadAll method enhance the search functionality by validating the search term length. This can help reduce unnecessary API calls and provide better user feedback.

Consider extracting the magic number '3' into a named constant for better maintainability:

+const MIN_SEARCH_LENGTH = 3;

 loadAll() {
   this.searchTerm = this.searchControl.value;
-  if (this.searchTerm.length >= 3 || this.searchTerm.length === 0) {
+  if (this.searchTerm.length >= MIN_SEARCH_LENGTH || this.searchTerm.length === 0) {
     this.searchInvalid = false;
     this.search.next();
   } else {
     this.searchInvalid = true;
   }
 }

529-534: LGTM: New method for handling Enter key press

The addition of the onKeydown method improves user experience by allowing search initiation via the Enter key. The implementation follows Angular best practices for event handling.

Consider using the KeyboardEvent.key enum for better type safety:

- if (event.key === 'Enter') {
+ if (event.key === KeyboardEvent.key.Enter) {
src/main/webapp/app/admin/user-management/user-management.component.html (2)

30-31: Improved input field responsiveness

The changes to the search input field enhance user interaction:

  1. Changing from (focusout) to (blur) for triggering loadAll() is a good choice for consistency.
  2. Adding the (keydown) event with onKeydown($event) allows for more responsive interactions.

Consider implementing debounce functionality for the onKeydown event to optimize performance, especially if loadAll() is resource-intensive:

import { debounceTime, distinctUntilChanged } from 'rxjs/operators';

@Component({...})
export class UserManagementComponent {
  searchTerms = new Subject<string>();

  ngOnInit() {
    this.searchTerms.pipe(
      debounceTime(300),
      distinctUntilChanged()
    ).subscribe(() => this.loadAll());
  }

  onKeydown(event: any) {
    this.searchTerms.next(event.target.value);
  }
}

Line range hint 248-443: Enhanced filter modal with improved user experience

The changes to the filter modal significantly improve user interaction and filter management:

  1. Consistent structure across different filter types (roles, origins, registration numbers, and statuses).
  2. Addition of radio buttons for selecting all, none, or specific items in each category.
  3. Clear labeling and help icons for better user guidance.

These enhancements make the filtering process more intuitive and efficient.

To further improve accessibility, consider adding aria-label attributes to the radio buttons and checkboxes. For example:

<input
  class="form-check-input"
  type="radio"
  (click)="selectAllRoles()"
  [checked]="this.filters.authorityFilter.size === this.authorityFilters.length && !this.filters.noAuthority"
  aria-label="{{ 'artemisApp.userManagement.filter.all' | artemisTranslate }}"
/>

This change will make it easier for screen readers to understand the purpose of each input element.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f3a48ad and 2c56d42.

📒 Files selected for processing (7)
  • src/main/webapp/app/admin/user-management/user-management-update.component.html (3 hunks)
  • src/main/webapp/app/admin/user-management/user-management-update.component.ts (1 hunks)
  • src/main/webapp/app/admin/user-management/user-management.component.html (1 hunks)
  • src/main/webapp/app/admin/user-management/user-management.component.ts (5 hunks)
  • src/main/webapp/app/admin/user-management/user-management.route.ts (1 hunks)
  • src/main/webapp/i18n/de/user-management.json (2 hunks)
  • src/main/webapp/i18n/en/user-management.json (2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
src/main/webapp/app/admin/user-management/user-management-update.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/app/admin/user-management/user-management-update.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/app/admin/user-management/user-management.component.html (1)

Pattern src/main/webapp/**/*.html: @if and @for are new and valid Angular syntax replacing *ngIf and *ngFor. They should always be used over the old style.

src/main/webapp/app/admin/user-management/user-management.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/app/admin/user-management/user-management.route.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/i18n/de/user-management.json (1)

Pattern src/main/webapp/i18n/de/**/*.json: German language translations should be informal (dutzen) and should never be formal (sietzen). So the user should always be addressed with "du/dein" and never with "sie/ihr".

🔇 Additional comments (12)
src/main/webapp/i18n/en/user-management.json (2)

67-67: LGTM: Improved clarity for user editing.

The addition of a specific "editLabel" for editing users enhances the user interface clarity and aligns well with the updated routing configuration. This change supports the PR's objective of improving user administration capabilities.


Line range hint 1-110: Summary: Focused improvements to user management localization.

The changes in this file are well-aligned with the PR objectives. They enhance clarity for user editing and provide more detailed information about password change restrictions. These modifications contribute to improving the user administration experience without introducing any unintended side effects.

src/main/webapp/i18n/de/user-management.json (1)

67-67: LGTM: Appropriate label for editing users

The new label "Nutzer:in bearbeiten" (Edit user) is clear and concise. It uses gender-neutral language, which is good practice. This change aligns with the PR objective of refining the user experience and distinguishing between creating and editing users.

src/main/webapp/app/admin/user-management/user-management-update.component.ts (1)

233-233: LGTM: Improved form control initialization for activatedInput.

The change to initialize activatedInput with { value: this.user.activated } is a good practice. It correctly sets the initial value of the form control to the user's current activation status, which is important for maintaining state when editing existing users.

src/main/webapp/app/admin/user-management/user-management-update.component.html (1)

4-8: LGTM: Improved conditional rendering for header

The use of @if and @else directives for conditional rendering aligns with the coding guideline to use new Angular syntax. This change effectively differentiates between creating a new user and editing an existing user, enhancing the user experience.

src/main/webapp/app/admin/user-management/user-management.component.ts (4)

105-105: LGTM: New property for search validation

The addition of the searchInvalid property follows the correct naming convention and appears to be used for form validation in the search functionality.


455-459: LGTM: Improved parameter naming in trackIdentity

The change from index to _index in the trackIdentity method parameter is a good practice. It clearly indicates that the parameter is intentionally unused, which can help prevent linter warnings and improve code clarity.


Line range hint 1-534: Overall assessment: Improvements to user management functionality

The changes in this file enhance the user management component by improving search functionality, error handling, and user experience. The modifications generally adhere to Angular best practices and the provided coding guidelines. A few minor suggestions have been made for further improvements, but overall, the changes are well-implemented and contribute positively to the component's functionality.


10-11: Verify the impact of removing debounceTime

The removal of debounceTime from RxJS imports might affect the search behavior. While this can make the search more responsive, it could potentially increase the number of API calls.

Please confirm that this change doesn't lead to excessive API calls during user search. Consider running the following command to check for any remaining usage of debounceTime:

✅ Verification successful

Further Verification Required

The removal of debounceTime did not return any usages in the user-management component. Please manually verify that this change does not lead to excessive API calls during user searches.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

rg 'debounceTime' src/main/webapp/app/admin/user-management/

Length of output: 60

src/main/webapp/app/admin/user-management/user-management.component.html (3)

Line range hint 444-450: Improved modal footer with clear actions

The changes to the modal footer enhance user interaction:

  1. Addition of a "Close" button for dismissing the modal without applying changes.
  2. Styling the "Apply" button as the primary action, making it visually distinct.
  3. Consistent use of translation keys for internationalization.

These improvements provide users with clear options for completing their interaction with the filter modal.


Line range hint 1-450: Excellent use of new Angular syntax and well-structured template

The overall structure and syntax of the template are commendable:

  1. Consistent use of the new Angular control flow syntax (@if and @for directives) throughout the template, aligning with the provided coding guidelines.
  2. Well-organized and logical structure, making the template easy to read and maintain.
  3. Clear separation of concerns between different sections of the user management interface.

The template demonstrates good practices in Angular development and adheres to modern standards.


Line range hint 36-40: Simplified error message display logic

The condition for displaying the search error message has been streamlined, now directly using the searchInvalid variable. This change improves readability and maintainability of the template.

Please ensure that the component's TypeScript file correctly manages the searchInvalid state. Run the following script to verify the implementation:

✅ Verification successful

Verification of searchInvalid Implementation

The searchInvalid variable is correctly managed within the user-management.component.ts file, ensuring that the error message display functions as intended.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of searchInvalid in the component file

# Test: Search for the searchInvalid property and its usage
rg -A 10 'searchInvalid' src/main/webapp/app/admin/user-management/user-management.component.ts

Length of output: 811

@github-actions github-actions bot added the tests label Oct 20, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
src/test/javascript/spec/component/admin/user-management.component.spec.ts (1)

247-256: LGTM: Improved test setup and expectations

The changes to the 'initFilters' test case are good improvements:

  1. The mock setup for userService.query is more comprehensive.
  2. The new expectation ensures that initFilters doesn't trigger any unnecessary queries, aligning with the PR objectives of improving efficiency.

Consider adding a comment explaining why userService.query is expected to be called 0 times after initialization. This would improve the test's readability and make the intention clearer for future developers.

Also applies to: 264-264

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2c56d42 and 103e4cd.

📒 Files selected for processing (1)
  • src/test/javascript/spec/component/admin/user-management.component.spec.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/test/javascript/spec/component/admin/user-management.component.spec.ts (1)

Pattern src/test/javascript/spec/**/*.ts: jest: true; mock: NgMocks; bad_practices: avoid_full_module_import; perf_improvements: mock_irrelevant_deps; service_testing: mock_http_for_logic; no_schema: avoid_NO_ERRORS_SCHEMA; expectation_specificity: true; solutions: {boolean: toBeTrue/False, reference: toBe, existence: toBeNull/NotNull, undefined: toBeUndefined, class_obj: toContainEntries/toEqual, spy_calls: {not_called: not.toHaveBeenCalled, once: toHaveBeenCalledOnce, with_value: toHaveBeenCalledWith|toHaveBeenCalledExactlyOnceWith}}

🔇 Additional comments (4)
src/test/javascript/spec/component/admin/user-management.component.spec.ts (4)

17-17: LGTM: ReactiveFormsModule import added

The addition of ReactiveFormsModule import is appropriate, as it suggests that the component now uses reactive forms. This aligns with the PR objectives of improving user administration capabilities.


171-171: Verify the increased number of query calls

The expectation for userService.query calls has been changed from toHaveBeenCalledOnce() to toHaveBeenCalledTimes(2). While this aligns with the improvements mentioned in the AI-generated summary, it's important to ensure that this change is intentional and doesn't introduce unnecessary API calls.

Could you please confirm if the increased number of query calls is expected behavior? If so, consider adding a comment explaining why two calls are now necessary.


Line range hint 1-586: Verify test coverage for user search functionality

The test case for validating user search functionality has been removed. While this aligns with the mentioned enhancements to user search functionality, it's crucial to ensure that this functionality is still being tested, possibly in a different way or location.

Could you please confirm that the user search functionality is adequately tested elsewhere? If not, consider adding new test cases to maintain proper test coverage.


Line range hint 1-586: LGTM: Comprehensive test suite with good coverage

The overall structure and coverage of the test suite for UserManagementComponent are impressive. The modifications align well with the PR objectives and the AI-generated summary, reflecting the changes made to the component.

As a final step, please verify that all new features, edge cases, and potential error scenarios introduced by the changes to the user administration capabilities are adequately covered by the test suite. This will ensure the robustness and reliability of the component.

@Malekos74 Malekos74 added deployment-error Added by deployment workflows if an error occured and removed deployment-error Added by deployment workflows if an error occured labels Oct 21, 2024
const spy = jest.spyOn(comp, 'initFilters');
const initSpy = jest.spyOn(profileService, 'getProfileInfo').mockReturnValue(of(new ProfileInfo()));

comp.ngOnInit();

expect(spy).toHaveBeenCalledOnce();
expect(initSpy).toHaveBeenCalledOnce();
expect(userService.query).toHaveBeenCalledTimes(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
expect(userService.query).toHaveBeenCalledTimes(0);
expect(userService.query).not.toHaveBeenCalled();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) ready for review tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Create User dialog has disabled Internal User setting
3 participants