test(player): type callback mocks in PlayerView tests - #43
Conversation
Replace `as any` casts on the component props with mocks typed against the PlayerView callback signatures. The setup now uses vitest's `Mock` generic and `vi.fn` with explicit function types, so mismatches in handler arguments surface at compile time instead of being silently erased.
|
Warning Review limit reached
Next review available in: 58 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe pull request updates TypeScript tooling and local proxy configuration, adds GitHub branding, preserves original errors as causes, normalizes Svelte markup and utility classes, and adjusts test typing and fixtures. ChangesApplication maintenance
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Switch type checking to the TypeScript 7 native port via `svelte-check --tsgo`, keeping 6.x pinned for Svelte plugin peers. Bump major versions: Vite 8, ESLint 10, jsdom 30, Svelte plugin 7. Reformat components, scripts, tests, and manifests with Prettier. Preserve original errors as `cause` in request and share services. Add GitHub brand icon and make the API proxy target configurable.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@AGENTS.md`:
- Line 45: Update the AGENTS.md guidance for the --tsgo fallback to remove the
unqualified “same results” claim. Describe classic 6.x checking as slower and
avoid asserting full equivalence, while preserving the existing fallback
instruction.
In `@vite.config.ts`:
- Around line 79-82: Update the proxy target configuration to retain
API_PROXY_TARGET as the override while falling back to the production API URL
for normal development and the local mock server when E2E_TEST is enabled.
Restore this behavior in the target setting near the commented E2E_TEST logic.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 90847d4a-0dfd-4fd1-b5d7-cdaae8e806fb
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (66)
.github/workflows/ci.ymlAGENTS.mdCLAUDE.mdpackage.jsonscripts/build-cdn-sveltekit.tsscripts/build-sveltekit.tsscripts/inject-env.tssrc/lib/components/ChristmasConfetti.sveltesrc/lib/components/ChristmasDecoration.sveltesrc/lib/components/ChristmasSnowfall.sveltesrc/lib/components/ControlBar.sveltesrc/lib/components/InstallPrompt.sveltesrc/lib/components/LayoutModeToggle.sveltesrc/lib/components/MapPreview.sveltesrc/lib/components/NetworkStatus.sveltesrc/lib/components/PageSizeSelector.sveltesrc/lib/components/Pagination.sveltesrc/lib/components/PlayerShareCard.sveltesrc/lib/components/PlayerShareCardMobile.sveltesrc/lib/components/PlayerShareModal.sveltesrc/lib/components/PlayerTable.sveltesrc/lib/components/PlayerView.sveltesrc/lib/components/QuickFilterButtons.sveltesrc/lib/components/SearchInput.sveltesrc/lib/components/ServerShareCard.sveltesrc/lib/components/ServerShareCardMobile.sveltesrc/lib/components/ServerShareModal.sveltesrc/lib/components/ServerTable.sveltesrc/lib/components/ServerView.sveltesrc/lib/components/StatsBar.sveltesrc/lib/components/TranslatedText.sveltesrc/lib/components/ViewModeToggle.sveltesrc/lib/components/icons/BrandIcon.sveltesrc/lib/request.tssrc/lib/services/player-share.tssrc/lib/services/server-share.tssrc/lib/utils/sorting.tssrc/lib/utils/url-state.tssrc/routes/+layout.sveltesrc/routes/+page.sveltesrc/routes/AnnouncementBar.sveltesrc/routes/Header.sveltestatic/manifest.webmanifesttests/e2e/demo.test.tstests/unit/components/AutoRefresh.svelte.test.tstests/unit/components/ControlBar.svelte.test.tstests/unit/components/LanguageSwitcher.svelte.test.tstests/unit/components/MobileInfiniteScroll.svelte.test.tstests/unit/components/PlayerDatabaseSelector.svelte.test.tstests/unit/components/PlayerView.svelte.test.tstests/unit/components/SearchInput.svelte.test.tstests/unit/components/ServerTable.svelte.test.tstests/unit/components/ServerView.svelte.test.tstests/unit/components/ThemeToggle.svelte.test.tstests/unit/config/server-columns.test.tstests/unit/hooks.server.test.tstests/unit/hooks.test.tstests/unit/player-share.test.tstests/unit/server-share.test.tstests/unit/services/background-sync.test.tstests/unit/services/players.test.tstests/unit/services/servers.test.tstests/unit/share/player-utils.test.tstests/unit/utils/url-state.test.tsvite.config.tsworker.ts
💤 Files with no reviewable changes (6)
- tests/unit/components/AutoRefresh.svelte.test.ts
- tests/unit/components/LanguageSwitcher.svelte.test.ts
- tests/unit/hooks.test.ts
- tests/unit/components/ThemeToggle.svelte.test.ts
- scripts/build-sveltekit.ts
- tests/unit/utils/url-state.test.ts
| `typescript-eslint` peer-require a 5.x/6.x API | ||
| - TypeScript 7 is installed alongside as the alias `@typescript/native` | ||
| (`npm:typescript@^7`), which is what `svelte-check --tsgo` drives | ||
| - drop `--tsgo` to fall back to the classic 6.x checker (slower, same results) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf 'AGENTS.md relevant lines:\n'
if [ -f AGENTS.md ]; then
nl -ba AGENTS.md | sed -n '35,55p'
else
echo 'AGENTS.md not found'
fi
printf '\nLocate svelte-check references:\n'
rg -n "svelte-check|--tsgo|tsgo|6\.x|classic" AGENTS.md . --glob '!node_modules' --glob '!dist' --glob '!build' 2>/dev/null || true
printf '\nPackage manifests:\n'
for f in package.json pnpm-lock.yaml package-lock.json yarn.lock bun.lockb bun.lock; do
if [ -f "$f" ]; then
echo "--- $f ---"
if [ "$f" = "package.json" ]; then
cat "$f"
else
rg -n "svelte-check|version:" "$f" | head -80
fi
fi
done
printf '\nGit diff summary:\n'
git diff --stat 2>/dev/null || trueRepository: rwr-infra/robin-web
Length of output: 223
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf 'AGENTS.md relevant lines:\n'
if [ -f AGENTS.md ]; then
awk 'NR>=35 && NR<=55 { printf "%6d %s\n", NR, $0 }' AGENTS.md
else
echo 'AGENTS.md not found'
fi
printf '\nLocate svelte-check references:\n'
rg -n "svelte-check|--tsgo|tsgo|6\.x|classic" AGENTS.md . --glob '!node_modules' --glob '!dist' --glob '!build' 2>/dev/null || true
printf '\nPackage manifests:\n'
for f in package.json pnpm-lock.yaml package-lock.json yarn.lock bun.lockb bun.lock; do
if [ -f "$f" ]; then
echo "--- $f ---"
if [ "$f" = "package.json" ]; then
cat "$f"
else
rg -n "svelte-check|version:" "$f" 2>/dev/null | head -120
fi
fi
done
printf '\nGit diff summary:\n'
git diff --stat 2>/dev/null || trueRepository: rwr-infra/robin-web
Length of output: 8350
🌐 Web query:
svelte-check 4.7.4 --tsgo limitations results TypeScript 7
💡 Result:
Svelte-check version 4.7.4 includes specific support for TypeScript 7 stable via an npm alias, addressing compatibility issues introduced by the new TypeScript version [1][2][3]. The --tsgo flag in svelte-check is designed to leverage TypeScript's Go-based implementation (tsgo) for faster type checking [4][5]. However, it is an advanced feature that comes with several documented limitations as of August 2026: 1. Requirement: It requires the @typescript/native-preview package to be installed in the project [5][6]. 2. Shared Limitations with --incremental: The --tsgo flag is subject to the same functional limitations as the --incremental flag [5][7]. Specifically, Svelte files located outside the root directory defined in your tsconfig.json may not be properly loaded or type-checked [4][5]. 3. Dependency Inconsistency: In projects using tsconfig references, using --tsgo can lead to inconsistent error reporting or leakage of errors from dependencies (such as missing globals or implicit any errors) because the generated temporary tsconfig.json may not correctly include or rebase those references [8][9]. 4. Tooling Gaps: Because the integration relies on command-line execution rather than a comprehensive TypeScript API (which is still evolving for tsgo), some editor-specific or language server protocol (LSP) features—such as full component prop resolution or specific module resolution strategies (e.g., NodeNext)—may behave differently compared to standard tsc [10][6][11]. Setting moduleResolution to "bundler" is sometimes required to resolve issues with component type visibility in this mode [10]. While version 4.7.4 stabilizes support for TypeScript 7, users are encouraged to monitor status bar indicators or settings (e.g., js/ts.experimental.useTsgo) if they encounter discrepancies between Svelte-check and native TypeScript behavior in their editors [11].
Citations:
- 1: https://github.com/sveltejs/language-tools/blob/master/packages/svelte-check/CHANGELOG.md
- 2: chore(deps-dev): bump svelte-check from 4.7.3 to 4.7.4 sixcolors/cs50-final-project#568
- 3: https://dependabot.ecosyste.ms/hosts/GitHub/repositories/jansinger%2Fostsee-tiere/issues/653
- 4: feat: svelte-check
--incremental/--tsgosveltejs/language-tools#2932 - 5: https://github.com/sveltejs/language-tools/tree/master/packages/svelte-check
- 6: TypeScript Go support (at least in CLI) sveltejs/language-tools#2733
- 7: https://registry.npmjs.org/svelte-check
- 8: --tsgo: missing references in generated tsconfig causes dependency source files to be checked sveltejs/language-tools#2948
- 9: svelte-check --tsgo --incremental tsconfig.json "references" inconsistency sveltejs/language-tools#3027
- 10: Missing component types on
--tsgosveltejs/language-tools#2984 - 11:
svelte-check: Doesn't flag TS2614 about exporting snippets from .svelte files, but TypeScript does sveltejs/language-tools#3083
Remove the unqualified “same results” claim.
--tsgo is a supported fast path in svelte-check, but it has documented use limitations. Reword this so fallback mode is not presented as fully equivalent.
Suggested wording
-- drop `--tsgo` to fall back to the classic 6.x checker (slower, same results)
+- drop `--tsgo` to fall back to the classic 6.x checker (slower; see `svelte-check`'s `--tsgo` limitations)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - drop `--tsgo` to fall back to the classic 6.x checker (slower, same results) | |
| - drop `--tsgo` to fall back to the classic 6.x checker (slower; see `svelte-check`'s `--tsgo` limitations) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@AGENTS.md` at line 45, Update the AGENTS.md guidance for the --tsgo fallback
to remove the unqualified “same results” claim. Describe classic 6.x checking as
slower and avoid asserting full equivalence, while preserving the existing
fallback instruction.
Source: MCP tools
| // Override with API_PROXY_TARGET to point dev/e2e at another backend | ||
| target: process.env.API_PROXY_TARGET ?? 'http://localhost:5800', | ||
| // Use mock server for E2E tests, production API for dev | ||
| target: process.env.E2E_TEST ? 'http://localhost:5800' : 'https://robin.rwr-infra.uk', | ||
| // target: process.env.E2E_TEST ? 'http://localhost:5800' : 'https://robin.rwr-infra.uk', |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 3 'API_PROXY_TARGET|E2E_TEST|localhost:5800|robin\.rwr-infra\.uk' .Repository: rwr-infra/robin-web
Length of output: 2362
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- package.json scripts ---'
sed -n '1,220p' package.json
printf '\n--- AGENTS dev/e2e instructions ---'
sed -n '70,90p' AGENTS.md
printf '\n--- vite proxy section ---'
sed -n '68,87p' vite.config.tsRepository: rwr-infra/robin-web
Length of output: 3629
Restore the production API fallback for normal dev.
npm run dev runs vite dev without setting API_PROXY_TARGET, so /api now proxies to http://localhost:5800 instead of the production API. Restore the process.env.E2E_TEST fallback to https://robin.rwr-infra.uk, or set API_PROXY_TARGET in the dev command.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@vite.config.ts` around lines 79 - 82, Update the proxy target configuration
to retain API_PROXY_TARGET as the override while falling back to the production
API URL for normal development and the local mock server when E2E_TEST is
enabled. Restore this behavior in the target setting near the commented E2E_TEST
logic.
Replace
as anycasts on the component props with mocks typed against the PlayerView callback signatures. The setup now uses vitest'sMockgeneric andvi.fnwith explicit function types, so mismatches in handler arguments surface at compile time instead of being silently erased.Summary by CodeRabbit
New Features
Bug Fixes
Chores
Style