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

Development: Remove angular mock test modules #10274

Merged
merged 8 commits into from
Feb 7, 2025

Conversation

tobias-lippert
Copy link
Contributor

@tobias-lippert tobias-lippert commented Feb 5, 2025

Checklist

General

Client

Motivation and Context

After #10184 and #10267, the shared modules and the mock modules used in tests remain.
This PR deletes the latter ones.

Description

Remove all mock modules and their usages in test files

Steps for Testing

Code Review only.
Make sure all client tests pass.

Testserver States

You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.

Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Test Coverage

unchanged

Summary by CodeRabbit

Summary by CodeRabbit

  • Tests

    • Streamlined test configurations by removing redundant mock dependencies, enhancing maintainability and efficiency without impacting the application’s user-facing functionality.
  • Chores

    • Cleaned up internal testing modules by removing unused mock components and directives for a more reliable test environment.
  • Configuration

    • Adjusted coverage threshold settings in the testing configuration for improved criteria during coverage checks.

Copy link

coderabbitai bot commented Feb 5, 2025

Walkthrough

This pull request removes multiple mock module imports from various Angular test configurations. In several test files, imports of modules used for tooltips, dropdowns, collapsible components, and pagination have been eliminated or replaced. Additionally, some tests have seen adjustments in import ordering and provider configuration, and a new import has been added in one case. Several standalone mock module files have been deleted entirely from the helpers directory.

Changes

File(s) Change Summary
src/test/.../system-notification-management.component.spec.ts, src/test/.../exam-import.component.spec.ts, src/test/.../conversation-members.component.spec.ts Removed NgbPaginationMocksModule imports from test setups to simplify dependencies.
src/test/.../code-editor-header.component.spec.ts, src/test/.../course-overview.component.spec.ts, src/test/.../conversation-member-row/conversation-member-row.component.spec.ts, src/test/.../navbar.component.spec.ts Removed NgbDropdownMocksModule; in course-overview, also reordered RxJS imports and updated the NgbDropdown provider using MockDirective(NgbDropdown).
src/test/.../competency-recommendation-detail.component.spec.ts, src/test/.../competency-search.component.spec.ts, src/test/.../course-conversations/dialogs/channels-overview-dialog/channels-overview-dialog.component.spec.ts, src/test/.../tutorial-group-sessions-table.component.spec.ts, src/test/.../admin-import-standardized-competencies.spec.ts, src/test/.../navbar.component.spec.ts Removed NgbCollapseMocksModule from the imports (or providers) to reduce test dependencies.
src/test/.../competency-accordion.component.spec.ts, src/test/.../competency-recommendation-detail.component.spec.ts, src/test/.../course-description-form.component.spec.ts, src/test/.../modeling-exam-submission.component.spec.ts, src/test/.../quiz-exam-submission.component.spec.ts, src/test/.../git-diff-report.component.spec.ts, src/test/.../conversation-thread-sidebar.component.spec.ts, src/test/.../build-plan-editor.component.spec.ts, src/test/.../knowledge-area-edit.component.spec.ts, src/test/.../standardized-competency-edit.spec.ts, src/test/.../course-wide-search.component.spec.ts, src/test/.../tutorial-group-detail.component.spec.ts, src/test/.../tutorial-groups-table.component.spec.ts, src/test/.../navbar.component.spec.ts, src/test/.../result.component.spec.ts Removed NgbTooltipMocksModule (and in one case its associated directive); in result tests, also added the MissingResultInformation import.
src/test/.../course-overview.component.spec.ts, src/test/.../iris/settings/iris-settings-update-component.spec.ts, src/test/.../result.component.spec.ts Made additional adjustments: reordered import statements (e.g., removals in RxJS and adjustments in ComponentFixture order), updated providers, and applied minor formatting changes.
src/test/.../ngbAlertsMocks.module.ts, src/test/.../ngbCollapseMocks.module.ts, src/test/.../ngbDropdownMocks.module.ts, src/test/.../ngbPaginationMocks.module.ts, src/test/.../ngbTooltipMocks.module.ts Deleted entire mock module files used for alerts, collapse, dropdown, pagination, and tooltips.

Suggested labels

client, chore


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d44336f and a4a4cad.

📒 Files selected for processing (1)
  • src/test/javascript/spec/component/course/course-overview.component.spec.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/javascript/spec/component/course/course-overview.component.spec.ts

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

🧹 Nitpick comments (1)
src/test/javascript/spec/component/competencies/competency-accordion.component.spec.ts (1)

13-60: Consider adding more test coverage.

The current test suite only covers progress calculations. Consider adding tests for:

  • Component initialization
  • Error handling scenarios
  • Edge cases (e.g., empty metrics, undefined competency)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d2d1c5 and 52fad84.

📒 Files selected for processing (32)
  • src/test/javascript/spec/component/admin/system-notification-management/system-notification-management.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/code-editor/code-editor-header.component.spec.ts (2 hunks)
  • src/test/javascript/spec/component/competencies/competency-accordion.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/competencies/generate-competencies/competency-recommendation-detail.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/competencies/generate-competencies/course-description-form.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/competencies/import/competency-search.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/course/course-overview.component.spec.ts (3 hunks)
  • src/test/javascript/spec/component/exam/manage/exam-import.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/exam/participate/exercises/modeling-exam-submission.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/exam/participate/exercises/quiz-exam-submission.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/git-diff-report/git-diff-report.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/iris/settings/iris-settings-update-component.spec.ts (2 hunks)
  • src/test/javascript/spec/component/overview/course-conversations/course-conversations.component.spec.ts (4 hunks)
  • src/test/javascript/spec/component/overview/course-conversations/course-wide-search.component.spec.ts (2 hunks)
  • src/test/javascript/spec/component/overview/course-conversations/dialogs/channels-overview-dialog/channels-overview-dialog.component.spec.ts (2 hunks)
  • src/test/javascript/spec/component/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.spec.ts (2 hunks)
  • src/test/javascript/spec/component/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-members.component.spec.ts (2 hunks)
  • src/test/javascript/spec/component/overview/course-conversations/layout/conversation-thread-sidebar/conversation-thread-sidebar.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/programming-exercise/build-plan-editor.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/shared/navbar.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/shared/result.component.spec.ts (2 hunks)
  • src/test/javascript/spec/component/standardized-competencies/admin-import-standardized-competencies.spec.ts (0 hunks)
  • src/test/javascript/spec/component/standardized-competencies/detail/knowledge-area-edit.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/standardized-competencies/detail/standardized-competency-edit.spec.ts (1 hunks)
  • src/test/javascript/spec/component/tutorial-groups/shared/tutorial-group-detail.component.spec.ts (2 hunks)
  • src/test/javascript/spec/component/tutorial-groups/shared/tutorial-group-sessions-table.component.spec.ts (1 hunks)
  • src/test/javascript/spec/component/tutorial-groups/shared/tutorial-groups-table.component.spec.ts (2 hunks)
  • src/test/javascript/spec/helpers/mocks/directive/ngbAlertsMocks.module.ts (0 hunks)
  • src/test/javascript/spec/helpers/mocks/directive/ngbCollapseMocks.module.ts (0 hunks)
  • src/test/javascript/spec/helpers/mocks/directive/ngbDropdownMocks.module.ts (0 hunks)
  • src/test/javascript/spec/helpers/mocks/directive/ngbPaginationMocks.module.ts (0 hunks)
  • src/test/javascript/spec/helpers/mocks/directive/ngbTooltipMocks.module.ts (0 hunks)
💤 Files with no reviewable changes (6)
  • src/test/javascript/spec/component/standardized-competencies/admin-import-standardized-competencies.spec.ts
  • src/test/javascript/spec/helpers/mocks/directive/ngbCollapseMocks.module.ts
  • src/test/javascript/spec/helpers/mocks/directive/ngbTooltipMocks.module.ts
  • src/test/javascript/spec/helpers/mocks/directive/ngbPaginationMocks.module.ts
  • src/test/javascript/spec/helpers/mocks/directive/ngbAlertsMocks.module.ts
  • src/test/javascript/spec/helpers/mocks/directive/ngbDropdownMocks.module.ts
✅ Files skipped from review due to trivial changes (6)
  • src/test/javascript/spec/component/standardized-competencies/detail/knowledge-area-edit.component.spec.ts
  • src/test/javascript/spec/component/exam/participate/exercises/modeling-exam-submission.component.spec.ts
  • src/test/javascript/spec/component/exam/manage/exam-import.component.spec.ts
  • src/test/javascript/spec/component/tutorial-groups/shared/tutorial-groups-table.component.spec.ts
  • src/test/javascript/spec/component/code-editor/code-editor-header.component.spec.ts
  • src/test/javascript/spec/component/overview/course-conversations/course-conversations.component.spec.ts
🧰 Additional context used
📓 Path-based instructions (1)
`src/test/javascript/spec/**/*.ts`: jest: true; mock: NgMock...

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}}

  • src/test/javascript/spec/component/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-members.component.spec.ts
  • src/test/javascript/spec/component/competencies/import/competency-search.component.spec.ts
  • src/test/javascript/spec/component/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.spec.ts
  • src/test/javascript/spec/component/competencies/generate-competencies/course-description-form.component.spec.ts
  • src/test/javascript/spec/component/competencies/generate-competencies/competency-recommendation-detail.component.spec.ts
  • src/test/javascript/spec/component/git-diff-report/git-diff-report.component.spec.ts
  • src/test/javascript/spec/component/tutorial-groups/shared/tutorial-group-sessions-table.component.spec.ts
  • src/test/javascript/spec/component/standardized-competencies/detail/standardized-competency-edit.spec.ts
  • src/test/javascript/spec/component/overview/course-conversations/layout/conversation-thread-sidebar/conversation-thread-sidebar.component.spec.ts
  • src/test/javascript/spec/component/tutorial-groups/shared/tutorial-group-detail.component.spec.ts
  • src/test/javascript/spec/component/programming-exercise/build-plan-editor.component.spec.ts
  • src/test/javascript/spec/component/competencies/competency-accordion.component.spec.ts
  • src/test/javascript/spec/component/exam/participate/exercises/quiz-exam-submission.component.spec.ts
  • src/test/javascript/spec/component/overview/course-conversations/course-wide-search.component.spec.ts
  • src/test/javascript/spec/component/shared/navbar.component.spec.ts
  • src/test/javascript/spec/component/overview/course-conversations/dialogs/channels-overview-dialog/channels-overview-dialog.component.spec.ts
  • src/test/javascript/spec/component/course/course-overview.component.spec.ts
  • src/test/javascript/spec/component/shared/result.component.spec.ts
  • src/test/javascript/spec/component/admin/system-notification-management/system-notification-management.component.spec.ts
  • src/test/javascript/spec/component/iris/settings/iris-settings-update-component.spec.ts
🪛 Biome (1.9.4)
src/test/javascript/spec/component/iris/settings/iris-settings-update-component.spec.ts

[error] 50-50: This array contains an empty slot.

Unsafe fix: Replace hole with undefined

(lint/suspicious/noSparseArray)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: client-tests
  • GitHub Check: server-tests
  • GitHub Check: Analyse
🔇 Additional comments (21)
src/test/javascript/spec/component/overview/course-conversations/layout/conversation-thread-sidebar/conversation-thread-sidebar.component.spec.ts (1)

19-19: LGTM! Proper removal of unused mock module.

The empty imports array is correct as the component doesn't require tooltip functionality in its tests. The test suite properly uses ng-mocks for component and directive mocking.

src/test/javascript/spec/component/competencies/import/competency-search.component.spec.ts (1)

16-16: LGTM! Proper module configuration.

The imports are correctly configured with only the essential modules (ArtemisTestModule, ArtemisFormsModule) needed for testing the component's form functionality.

src/test/javascript/spec/component/competencies/competency-accordion.component.spec.ts (1)

18-18: LGTM! Proper removal of unused mock module.

The empty imports array is correct as the component doesn't require tooltip functionality in its tests.

src/test/javascript/spec/component/competencies/generate-competencies/course-description-form.component.spec.ts (1)

18-18: LGTM! Proper module configuration.

The imports are correctly configured with only the essential modules (ArtemisTestModule, ReactiveFormsModule) needed for testing the component's form functionality. The test suite makes excellent use of ng-mocks for component and directive mocking.

src/test/javascript/spec/component/admin/system-notification-management/system-notification-management.component.spec.ts (1)

33-33: LGTM! Removal of NgbPaginationMocksModule is safe.

The test suite remains functional as pagination testing only requires event dispatching, which doesn't need the mock module.

src/test/javascript/spec/component/competencies/generate-competencies/competency-recommendation-detail.component.spec.ts (1)

21-21: LGTM! Removal of NgbTooltipMocksModule and NgbCollapseMocksModule is safe.

The test suite remains functional as it focuses on component logic rather than tooltip or collapse behavior.

src/test/javascript/spec/component/standardized-competencies/detail/standardized-competency-edit.spec.ts (1)

43-43: LGTM! Removal of NgbTooltipMocksModule is safe.

The test suite remains functional as it focuses on form logic and CRUD operations rather than tooltip behavior.

src/test/javascript/spec/component/programming-exercise/build-plan-editor.component.spec.ts (1)

35-35: LGTM! Removal of NgbTooltipMocksModule is safe.

The test suite remains functional as it focuses on editor logic and build plan operations rather than tooltip behavior.

src/test/javascript/spec/component/overview/course-conversations/dialogs/channels-overview-dialog/channels-overview-dialog.component.spec.ts (1)

50-50: LGTM! Safe to remove NgbCollapseMocksModule.

The removal of NgbCollapseMocksModule is safe as the test suite uses ng-mocks for component and service mocking, and the test coverage remains comprehensive.

src/test/javascript/spec/component/tutorial-groups/shared/tutorial-group-detail.component.spec.ts (1)

62-63: LGTM! Safe to remove NgbTooltipMocksModule.

The removal of NgbTooltipMocksModule is safe as the test suite uses ng-mocks for component and service mocking. The remaining RouterModule.forRoot([]) import is sufficient for the test requirements.

Also applies to: 115-116

src/test/javascript/spec/component/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-members.component.spec.ts (1)

41-41: LGTM! Safe to remove NgbPaginationMocksModule.

The removal of NgbPaginationMocksModule is safe as:

  1. The test suite uses ng-mocks for component mocking.
  2. Pagination functionality is covered through the ItemCountComponent mock.
  3. The remaining imports (FormsModule, ReactiveFormsModule) are sufficient for form testing.
src/test/javascript/spec/component/tutorial-groups/shared/tutorial-group-sessions-table.component.spec.ts (1)

118-118: LGTM! Safe to remove NgbCollapseMocksModule.

The removal of NgbCollapseMocksModule is safe as the test suite uses ng-mocks for component and service mocking. The remaining ArtemisTestModule import is sufficient for the test requirements.

src/test/javascript/spec/component/git-diff-report/git-diff-report.component.spec.ts (1)

17-17: LGTM! Safe removal of NgbTooltipMocksModule.

The removal of the mock module is appropriate as the test suite doesn't verify any tooltip-related functionality, and ArtemisTestModule provides sufficient testing infrastructure.

src/test/javascript/spec/component/overview/course-conversations/course-wide-search.component.spec.ts (1)

60-60: LGTM! Safe removal of mock module.

The imports are correctly reduced to only the essential modules (FormsModule, ReactiveFormsModule) needed for testing the component's form functionality.

src/test/javascript/spec/component/exam/participate/exercises/quiz-exam-submission.component.spec.ts (1)

52-52: LGTM! Safe removal of imports array.

The empty imports array is appropriate as the tests focus on business logic, with UI components properly mocked using MockComponent and MockDirective.

src/test/javascript/spec/component/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.spec.ts (1)

63-63: LGTM! Appropriate module configuration.

The imports array correctly retains NgbTooltipModule while removing unnecessary mock modules, as the component requires tooltip functionality but not dropdown behavior.

src/test/javascript/spec/component/shared/result.component.spec.ts (2)

4-4: LGTM!

The addition of MissingResultInformation import is necessary as it's used in the test cases for verifying missing result information messages.


88-88: LGTM!

The removal of NgbTooltipMocksModule from imports is appropriate as the tooltip functionality is still covered through MockDirective(TranslateDirective) in the declarations array.

src/test/javascript/spec/component/course/course-overview.component.spec.ts (2)

3-4: LGTM!

The import order changes are minor refactoring improvements that don't affect functionality.


166-166: LGTM!

The replacement of NgbDropdownMocksModule with MockDirective(NgbDropdown) is a good improvement as it:

  • Reduces dependency on mock modules
  • Uses ng-mocks' MockDirective which is more maintainable
  • Maintains test coverage

Also applies to: 202-202

src/test/javascript/spec/component/shared/navbar.component.spec.ts (1)

95-95: LGTM!

The removal of NgbTooltipMocksModule, NgbCollapseMocksModule, and NgbDropdownMocksModule from imports is appropriate as the component's functionality is still properly tested through other mock declarations and providers.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 6, 2025
cremertim
cremertim previously approved these changes Feb 6, 2025
Copy link
Contributor

@cremertim cremertim left a comment

Choose a reason for hiding this comment

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

Code changes lgtm

xHadie
xHadie previously approved these changes Feb 6, 2025
Copy link

@xHadie xHadie left a comment

Choose a reason for hiding this comment

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

Code changes look good to me!

coolchock
coolchock previously approved these changes Feb 6, 2025
Copy link
Contributor

@coolchock coolchock left a comment

Choose a reason for hiding this comment

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

code LGTM

@krusche krusche merged commit d6a73b6 into develop Feb 7, 2025
20 of 24 checks passed
@krusche krusche deleted the chore/remove-test-modules branch February 7, 2025 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

5 participants