feat: Increase test coverage for core utilities and components#36
feat: Increase test coverage for core utilities and components#36jricardo27 wants to merge 1 commit into
Conversation
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.
There was a problem hiding this comment.
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, andsrc/components/TopMenu/TopMenu.tsx, boosting overall line coverage from approximately 1.4% to 10.16%. - Bug Fix in
deepMergeUtility: Identifies and fixes a bug in thedeepMergefunction 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).
- Adds
- index.html
- Removes the
<script type="importmap">block (lines 13-48).
- Removes the
- package-lock.json
- Adds
@vitest/coverage-v8dependency (line 50). - Updates
typescriptfrom~5.6.3to^5.8.3(line 61). - Updates
vitefrom6.3.4to^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-coveragedependency (line 383). - Updates
@eslint-community/eslint-utilsto4.7.0(line 1137). - Updates
@eslint/config-arrayto0.20.0(line 1178). - Updates
@eslint/config-helpersto0.2.2(line 1192). - Updates
@eslint/coreto0.14.0(line 1201). - Updates
@eslint/jsto9.27.0(line 1250). - Updates
@eslint/plugin-kitto0.3.1(line 1271). - Adds
@istanbuljs/schemadependency (line 1453). - Updates
@mui/icons-materialto6.4.11(line 1526) and its peer dependency requirement (line 1540). - Removes
licensefield from several@nodelib/fsdependencies (lines 1760, 1773, 1782). - Removes
licensefield from@types/json-schema(line 2347). - Updates
@types/leafletto1.9.18(line 2357). - Updates
@types/nodeto22.15.21(line 2366). - Updates
@types/reactto19.1.5(line 2387). - Updates
@types/react-domto19.1.5(line 2395). - Updates
@typescript-eslint/eslint-pluginto8.32.1(line 2430) and updates its dependencies (lines 2436-2443). - Adds
ignoredependency specifically for@typescript-eslint/eslint-plugin(line 2459). - Updates
@typescript-eslint/parserto8.32.1(line 2468) and updates its dependencies (lines 2473-2476). - Updates
@typescript-eslint/scope-managerto8.32.1(line 2492) and updates its dependencies (lines 2497-2498). - Updates
@typescript-eslint/type-utilsto8.32.1(line 2509) and updates its dependencies (lines 2514-2517). - Updates
@typescript-eslint/typesto8.32.1(line 2532). - Updates
@typescript-eslint/typescript-estreeto8.32.1(line 2545) and updates its dependencies (lines 2550-2557). - Updates
@typescript-eslint/visitor-keysto8.32.1(line 2630) and updates its dependencies (line 2635). - Updates
@vitejs/plugin-reactto4.4.1(line 2647) and updates its dependencies (lines 2652, 2656). - Adds
@vitest/coverage-v8dependency details (lines 2665-2695). - Updates
axiosto1.9.0(line 3125). - Removes
licensefield frombraces(line 3171). - Updates
browserslistto4.24.5(line 3180) and updates its dependencies (caniuse-lite,electron-to-chromium,update-browserslist-db) (lines 3199-3202). - Updates
call-bind-apply-helpersto1.0.2(line 3241). - Updates
call-boundto1.0.4(line 3254) and updates its dependencies (lines 3259-3260). - Updates
caniuse-liteto1.0.30001718(line 3279). - Removes
licensefield fromcaniuse-lite(line 3296). - Updates
electron-to-chromiumto1.5.155(line 3722). - Removes
licensefield fromelectron-to-chromium(line 3725). - Updates
eslintto9.27.0(line 3998) and updates its dependencies (lines 4005-4010). - Updates
eslint-plugin-reactto7.37.5(line 4152) and updates itsobject.entriesdependency (line 4167). - Updates
eslint-plugin-react-refreshto0.4.20(line 4197). - Removes
licensefield fromfast-glob(line 4348). - Removes
licensefield fromglob-parent(line 4364). - Removes
licensefield fromfastq(line 4390). - Removes
licensefield fromfill-range(line 4425). - Updates
get-intrinsicto1.3.0(line 4626) and updates its dependencies (lines 4631, 4634, 4636). - Removes
licensefield fromgraphemer(line 4788). - Adds
html-escaperdependency (line 4906). - Removes
licensefield fromis-number(line 5266). - Adds
istanbul-lib-coveragedependency (line 5467). - Adds
istanbul-lib-reportdependency (line 5477). - Adds
istanbul-lib-source-mapsdependency (line 5491). - Adds
istanbul-reportsdependency (line 5505). - Removes
licensefield fromlru-cache(line 5788). - Adds
magicastdependency (line 5815). - Adds
make-dirdependency (line 5826) and itssemverdependency (line 5841). - Removes
licensefield frommerge2(line 5866). - Removes
licensefield frommicromatch(line 5875). - Removes
licensefield fromnode-releases(line 5994). - Updates
object.entriesto1.1.9(line 6057) and updates its dependencies (lines 6062-6065). - Removes
licensefield frompicomatch(line 6352). - Removes
licensefield fromreact(line 6499). - Updates
reactto19.1.0(line 6501). - Updates
react-domto19.1.0(line 6509) and updates itsschedulerdependency (line 6513) and peer dependency (line 6516). - Removes
licensefield fromreact-dom(line 6518). - Updates
react-refreshto0.17.0(line 6564). - Removes
licensefield fromreact-refresh(line 6567). - Removes
licensefield fromreusify(line 6792). - Removes
licensefield fromrun-parallel(line 6917). - Updates
schedulerto0.26.0(line 7004). - Removes
licensefield fromscheduler(line 7007). - Adds
test-excludedependency (line 7486) and its nestedbrace-expansion(line 7500) andminimatch(line 7509) dependencies. - Updates
tinymceto7.9.0(line 7583). - Removes
licensefield fromtinymce(line 7586). - Removes
licensefield fromto-regex-range(line 7641). - Removes
licensefield fromtypescript(line 7834). - Updates
typescript-eslintto8.32.1(line 7844) and updates its dependencies (lines 7849-7851). - Updates
update-browserslist-dbto1.1.3(line 7892). - Removes
licensefield fromupdate-browserslist-db(line 7910). - Updates
viteto6.3.5(line 7951). - Removes
licensefield fromvite(line 7954). - Removes
licensefield fromyallist(line 8427).
- Adds
- package.json
- Adds
@vitest/coverage-v8dependency (line 55). - Updates
typescriptfrom~5.6.3to^5.8.3(line 66). - Updates
vitefrom6.3.4to^6.3.5(line 68).
- Adds
- 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
Appcomponent (lines 1-166).
- Adds a new file containing comprehensive unit tests for the
- src/App.tsx
- Uncomments the line that sets
localStorage.setItem("hasShownModal", "true")when the welcome modal is shown for the first time (line 50).
- Uncomments the line that sets
- src/components/SavedFeaturesDrawer/TabList/TabList.tsx
- Adds type casting
as React.MouseEventto theeventparameter inonContextMenuhandlers for theTabscomponent (line 22) and individualTabcomponents (line 31).
- Adds type casting
- src/components/TopMenu/TopMenu.test.tsx
- Adds a new file containing comprehensive unit tests for the
TopMenucomponent (lines 1-183).
- Adds a new file containing comprehensive unit tests for the
- src/contexts/SavedFeaturesProvider.test.tsx
- Adds a new file containing comprehensive unit tests for the
SavedFeaturesProvidercontext (lines 1-337).
- Adds a new file containing comprehensive unit tests for the
- src/utils/deepmerge.test.ts
- Adds a new file containing comprehensive unit tests for the
deepMergeutility function (lines 1-164).
- Adds a new file containing comprehensive unit tests for the
- src/utils/deepmerge.ts
- Refactors the logic within the
deepMergefunction 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).
- Refactors the logic within the
- src/utils/formatFeature.test.ts
- Adds a new file containing comprehensive unit tests for the
formatFeatureutility function (lines 1-158).
- Adds a new file containing comprehensive unit tests for the
- vite.config.ts
- Adds a Vitest reference comment at the top of the file (line 1).
- Removes most entries from the
build.rollupOptions.externalarray, leaving onlytinymce(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
-
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. ↩
There was a problem hiding this comment.
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.htmland the corresponding reduction of externals invite.config.tssuggest 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, andformatFeature.ts. - Bug Fixes: The PR includes a valuable bug fix in
deepmerge.tsimproving its merging logic, and a fix inApp.tsxensuring the welcome modal'shasShownModalflag 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.tsxand path data changes inIllustration.tsxare 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.
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.