refactor: extract shared Navbar and Footer components#2
Merged
Conversation
Add the first test suite to the project โ 68 pure unit tests covering
the two core Python modules (ping_tester.py and cli.py).
Tests are network-free and subprocess-free; they run in ~50ms and work
offline, making them safe to run in CI before any network access.
Coverage includes:
- validate_ip: valid/invalid IPv4/IPv6, hostnames, injection strings
- calculate_jitter: empty, single-value, zero, alternating, high-jitter cases
- get_best_server: empty list, all-timeout, lowest-ping selection,
packet-loss-beats-ping ordering, 100% loss exclusion
- get_connection_quality: all 5 quality tiers with boundary value checks
- sort_results: all 5 sort keys, timeout-last guarantee, unknown-key fallback
- filter_by_max_ping: pass-all, block-all, timeout exclusion, boundary edge cases
- results_to_json: valid JSON, field correctness, best-only, error case, empty
- results_to_csv: parseable output, header row, best-only, multiple rows
- Color helpers: no-color mode, format_ping, format_loss
- build_parser: defaults, flags, region/sort validation, type coercion
Files: desktop/tests/__init__.py, desktop/tests/test_ping_tester.py,
desktop/tests/test_cli.py, desktop/pytest.ini
The navigation bar and footer were copy-pasted identically across 4 pages (home, dashboard, community, download), totaling ~200 lines of duplicated JSX. Changes: - Add web/src/components/Navbar.tsx: shared nav with usePathname-based active state highlighting, mobile menu toggle, ARIA attributes, and declarative NAV_LINKS config array โ single source of truth for site navigation - Add web/src/components/Footer.tsx: shared footer with logo, copyright, and Privacy/Terms/GitHub links - Refactor page.tsx, dashboard/page.tsx, community/page.tsx, download/page.tsx: replace inline nav/footer blocks with <Navbar /> and <Footer /> imports - Remove now-unused mobileMenuOpen state and Menu/X/Activity imports from each page file Benefits: - Any nav change (new link, style update) now requires editing one file - Active page highlighting (text-white font-medium) is now automatic via usePathname โ previously each page hardcoded its own active link - Eliminates ~180 lines of net duplicated code (-338 / +157) - No behavior changes โ visual output is identical
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The navigation bar and footer were copy-pasted across 4 pages, totaling ~200 lines of duplicated JSX with no single source of truth.
Changes
New:
web/src/components/Navbar.tsxโ shared nav component with:usePathname-based active link highlighting (automatic, no per-page hardcoding)NAV_LINKSconfig array โ add a nav link in one placearia-expandedandaria-controlsattributesNew:
web/src/components/Footer.tsxโ shared footer with logo, copyright, and linksRefactored:
page.tsx,dashboard/page.tsx,community/page.tsx,download/page.tsx<Navbar /><Footer />mobileMenuOpenstate andMenu/X/Activityicon importsResult
<img>warnings unchanged)