Skip to content

feat: Increase test coverage for core utilities and components#36

Open
jricardo27 wants to merge 1 commit into
mainfrom
increase-test-coverage-1
Open

feat: Increase test coverage for core utilities and components#36
jricardo27 wants to merge 1 commit into
mainfrom
increase-test-coverage-1

Conversation

@jricardo27

Copy link
Copy Markdown
Owner

This commit introduces new unit tests for several key areas of the application, significantly improving overall test coverage from ~1.4% to ~10.16% lines.

New tests were added for:

  • src/utils/formatFeature.ts (achieving 100% coverage)
  • src/utils/deepmerge.ts (achieving 100% coverage, also included a bug fix for the function itself)
  • src/contexts/SavedFeaturesProvider.tsx (achieving 96.62% line coverage)
  • src/App.tsx (achieving 86.41% line coverage for its core logic)
  • src/components/TopMenu/TopMenu.tsx (achieving 100% line coverage)

This effort establishes a stronger foundation for future development and testing.

This commit introduces new unit tests for several key areas of the application, significantly improving overall test coverage from ~1.4% to ~10.16% lines.

New tests were added for:
- `src/utils/formatFeature.ts` (achieving 100% coverage)
- `src/utils/deepmerge.ts` (achieving 100% coverage, also included a bug fix for the function itself)
- `src/contexts/SavedFeaturesProvider.tsx` (achieving 96.62% line coverage)
- `src/App.tsx` (achieving 86.41% line coverage for its core logic)
- `src/components/TopMenu/TopMenu.tsx` (achieving 100% line coverage)

This effort establishes a stronger foundation for future development and testing.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hello @jricardo27, 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!

Summary of Changes

Hello team, Gemini here with a summary of this pull request by @jricardo27. The primary goal of this PR is to significantly enhance the test coverage across several core utilities and components of the application, as indicated by the title and description. This effort aims to improve the overall stability and maintainability of the codebase by adding new unit tests and addressing a specific bug found during the testing process. The PR also includes various dependency updates and minor file adjustments.

Highlights

  • Increased Test Coverage: Adds comprehensive unit tests for src/utils/formatFeature.ts, src/utils/deepmerge.ts, src/contexts/SavedFeaturesProvider.tsx, src/App.tsx, and src/components/TopMenu/TopMenu.tsx, boosting overall line coverage from approximately 1.4% to 10.16%.
  • Bug Fix in deepMerge Utility: Identifies and fixes a bug in the deepMerge function where non-object properties in the target were not correctly overwritten by object properties from the source.
  • Dependency Updates: Updates numerous development dependencies, including Babel, ESLint, TypeScript, Vite, React, and React DOM, and adds new dependencies related to Vitest coverage reporting.
  • Build Configuration Adjustment: Modifies the Vite configuration to remove most external dependencies from the Rollup build, relying instead on the importmap in index.html (which was subsequently removed in this PR, suggesting a potential build strategy change or cleanup).

Changelog

Click here to see the changelog
  • .gitignore
    • Adds coverage/ directory to the ignore list (line 34).
  • index.html
    • Removes the <script type="importmap"> block (lines 13-48).
  • package-lock.json
    • Adds @vitest/coverage-v8 dependency (line 50).
    • Updates typescript from ~5.6.3 to ^5.8.3 (line 61).
    • Updates vite from 6.3.4 to ^6.3.5 (line 63).
    • Updates various Babel dependencies (e.g., @babel/compat-data, @babel/core, @babel/generator, etc.) to newer versions (multiple diffs, e.g., lines 124, 133, 163).
    • Adds @bcoe/v8-coverage dependency (line 383).
    • Updates @eslint-community/eslint-utils to 4.7.0 (line 1137).
    • Updates @eslint/config-array to 0.20.0 (line 1178).
    • Updates @eslint/config-helpers to 0.2.2 (line 1192).
    • Updates @eslint/core to 0.14.0 (line 1201).
    • Updates @eslint/js to 9.27.0 (line 1250).
    • Updates @eslint/plugin-kit to 0.3.1 (line 1271).
    • Adds @istanbuljs/schema dependency (line 1453).
    • Updates @mui/icons-material to 6.4.11 (line 1526) and its peer dependency requirement (line 1540).
    • Removes license field from several @nodelib/fs dependencies (lines 1760, 1773, 1782).
    • Removes license field from @types/json-schema (line 2347).
    • Updates @types/leaflet to 1.9.18 (line 2357).
    • Updates @types/node to 22.15.21 (line 2366).
    • Updates @types/react to 19.1.5 (line 2387).
    • Updates @types/react-dom to 19.1.5 (line 2395).
    • Updates @typescript-eslint/eslint-plugin to 8.32.1 (line 2430) and updates its dependencies (lines 2436-2443).
    • Adds ignore dependency specifically for @typescript-eslint/eslint-plugin (line 2459).
    • Updates @typescript-eslint/parser to 8.32.1 (line 2468) and updates its dependencies (lines 2473-2476).
    • Updates @typescript-eslint/scope-manager to 8.32.1 (line 2492) and updates its dependencies (lines 2497-2498).
    • Updates @typescript-eslint/type-utils to 8.32.1 (line 2509) and updates its dependencies (lines 2514-2517).
    • Updates @typescript-eslint/types to 8.32.1 (line 2532).
    • Updates @typescript-eslint/typescript-estree to 8.32.1 (line 2545) and updates its dependencies (lines 2550-2557).
    • Updates @typescript-eslint/visitor-keys to 8.32.1 (line 2630) and updates its dependencies (line 2635).
    • Updates @vitejs/plugin-react to 4.4.1 (line 2647) and updates its dependencies (lines 2652, 2656).
    • Adds @vitest/coverage-v8 dependency details (lines 2665-2695).
    • Updates axios to 1.9.0 (line 3125).
    • Removes license field from braces (line 3171).
    • Updates browserslist to 4.24.5 (line 3180) and updates its dependencies (caniuse-lite, electron-to-chromium, update-browserslist-db) (lines 3199-3202).
    • Updates call-bind-apply-helpers to 1.0.2 (line 3241).
    • Updates call-bound to 1.0.4 (line 3254) and updates its dependencies (lines 3259-3260).
    • Updates caniuse-lite to 1.0.30001718 (line 3279).
    • Removes license field from caniuse-lite (line 3296).
    • Updates electron-to-chromium to 1.5.155 (line 3722).
    • Removes license field from electron-to-chromium (line 3725).
    • Updates eslint to 9.27.0 (line 3998) and updates its dependencies (lines 4005-4010).
    • Updates eslint-plugin-react to 7.37.5 (line 4152) and updates its object.entries dependency (line 4167).
    • Updates eslint-plugin-react-refresh to 0.4.20 (line 4197).
    • Removes license field from fast-glob (line 4348).
    • Removes license field from glob-parent (line 4364).
    • Removes license field from fastq (line 4390).
    • Removes license field from fill-range (line 4425).
    • Updates get-intrinsic to 1.3.0 (line 4626) and updates its dependencies (lines 4631, 4634, 4636).
    • Removes license field from graphemer (line 4788).
    • Adds html-escaper dependency (line 4906).
    • Removes license field from is-number (line 5266).
    • Adds istanbul-lib-coverage dependency (line 5467).
    • Adds istanbul-lib-report dependency (line 5477).
    • Adds istanbul-lib-source-maps dependency (line 5491).
    • Adds istanbul-reports dependency (line 5505).
    • Removes license field from lru-cache (line 5788).
    • Adds magicast dependency (line 5815).
    • Adds make-dir dependency (line 5826) and its semver dependency (line 5841).
    • Removes license field from merge2 (line 5866).
    • Removes license field from micromatch (line 5875).
    • Removes license field from node-releases (line 5994).
    • Updates object.entries to 1.1.9 (line 6057) and updates its dependencies (lines 6062-6065).
    • Removes license field from picomatch (line 6352).
    • Removes license field from react (line 6499).
    • Updates react to 19.1.0 (line 6501).
    • Updates react-dom to 19.1.0 (line 6509) and updates its scheduler dependency (line 6513) and peer dependency (line 6516).
    • Removes license field from react-dom (line 6518).
    • Updates react-refresh to 0.17.0 (line 6564).
    • Removes license field from react-refresh (line 6567).
    • Removes license field from reusify (line 6792).
    • Removes license field from run-parallel (line 6917).
    • Updates scheduler to 0.26.0 (line 7004).
    • Removes license field from scheduler (line 7007).
    • Adds test-exclude dependency (line 7486) and its nested brace-expansion (line 7500) and minimatch (line 7509) dependencies.
    • Updates tinymce to 7.9.0 (line 7583).
    • Removes license field from tinymce (line 7586).
    • Removes license field from to-regex-range (line 7641).
    • Removes license field from typescript (line 7834).
    • Updates typescript-eslint to 8.32.1 (line 7844) and updates its dependencies (lines 7849-7851).
    • Updates update-browserslist-db to 1.1.3 (line 7892).
    • Removes license field from update-browserslist-db (line 7910).
    • Updates vite to 6.3.5 (line 7951).
    • Removes license field from vite (line 7954).
    • Removes license field from yallist (line 8427).
  • package.json
    • Adds @vitest/coverage-v8 dependency (line 55).
    • Updates typescript from ~5.6.3 to ^5.8.3 (line 66).
    • Updates vite from 6.3.4 to ^6.3.5 (line 68).
  • public/docs/img/online_trip_explorer_qr.svg
    • Replaces the entire SVG content (lines 1-361 removed, line 1 added). This appears to be a re-export or optimization of the QR code image.
  • src/App.test.tsx
    • Adds a new file containing comprehensive unit tests for the App component (lines 1-166).
  • src/App.tsx
    • Uncomments the line that sets localStorage.setItem("hasShownModal", "true") when the welcome modal is shown for the first time (line 50).
  • src/components/SavedFeaturesDrawer/TabList/TabList.tsx
    • Adds type casting as React.MouseEvent to the event parameter in onContextMenu handlers for the Tabs component (line 22) and individual Tab components (line 31).
  • src/components/TopMenu/TopMenu.test.tsx
    • Adds a new file containing comprehensive unit tests for the TopMenu component (lines 1-183).
  • src/contexts/SavedFeaturesProvider.test.tsx
    • Adds a new file containing comprehensive unit tests for the SavedFeaturesProvider context (lines 1-337).
  • src/utils/deepmerge.test.ts
    • Adds a new file containing comprehensive unit tests for the deepMerge utility function (lines 1-164).
  • src/utils/deepmerge.ts
    • Refactors the logic within the deepMerge function to correctly handle cases where a target property is not an object but the corresponding source property is, ensuring the source object overwrites the target value (lines 8-23).
  • src/utils/formatFeature.test.ts
    • Adds a new file containing comprehensive unit tests for the formatFeature utility function (lines 1-158).
  • vite.config.ts
    • Adds a Vitest reference comment at the top of the file (line 1).
    • Removes most entries from the build.rollupOptions.external array, leaving only tinymce (lines 11-13).
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.


Tests written with care,
Coverage numbers start to flair,
Bugs fixed with a glance,
A code's second chance,
Confidence fills the air.

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.

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

Copy link
Copy Markdown

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 significantly boosts test coverage across several key components and utilities, which is a fantastic achievement! The new tests for App.tsx, TopMenu.tsx, SavedFeaturesProvider.tsx, deepmerge.ts, and formatFeature.ts are comprehensive and well-written, covering many important scenarios and edge cases. The bug fix in deepmerge.ts improves its robustness, and the fix in App.tsx for the welcome modal logic is also a good catch.

However, there are a couple of significant changes related to dependency management (index.html and vite.config.ts) that need clarification to ensure they align with the project's build and deployment strategy. Please see the specific comments on those files.

Overall, great work on enhancing the test suite and improving code quality!

Summary of Findings

  • Dependency Management Strategy Change: The removal of the import map in index.html and the corresponding reduction of externals in vite.config.ts suggest a major shift from using CDN-hosted dependencies to bundling them. This needs clarification regarding its intent and impact on production builds.
  • Test Coverage Improvement: Excellent work on significantly increasing test coverage. The new test suites are well-structured and cover many important use cases and edge conditions for App.tsx, TopMenu.tsx, SavedFeaturesProvider.tsx, deepmerge.ts, and formatFeature.ts.
  • Bug Fixes: The PR includes a valuable bug fix in deepmerge.ts improving its merging logic, and a fix in App.tsx ensuring the welcome modal's hasShownModal flag is correctly persisted.
  • SVG Optimization: The QR code SVG (public/docs/img/online_trip_explorer_qr.svg) has been significantly optimized, which is a good improvement for asset size.
  • Minor Code Refinements: Type assertions in TabList.tsx and path data changes in Illustration.tsx are minor refinements, likely addressing TypeScript or rendering details. These are considered low severity and not commented on individually.

Merge Readiness

This pull request makes excellent progress in increasing test coverage and includes some important bug fixes. However, the changes to index.html (removal of import map) and vite.config.ts (reduction of external dependencies) represent a significant shift in how frontend dependencies are managed. These changes could have a substantial impact on the production build and deployment strategy.

It is highly recommended that these dependency management changes are clarified and their implications fully understood before merging. If these changes were unintentional or their impact not fully assessed, they could be critical.

Once these points are addressed, the PR will be in a much better position for merging. As an AI, I am not authorized to approve pull requests; please ensure further review and approval from team members.

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