Skip to content

test(player): type callback mocks in PlayerView tests - #43

Merged
Kreedzt merged 4 commits into
masterfrom
feature/sid
Aug 5, 2026
Merged

Kreedzt merged 4 commits into
masterfrom
feature/sid

Conversation

@Kreedzt

@Kreedzt Kreedzt commented Aug 5, 2026 •

Copy link
Copy Markdown
Collaborator

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.

Summary by CodeRabbit

  • New Features

    • Added GitHub branding support to shared interface icons and the site header.
  • Bug Fixes

    • Improved error diagnostics by preserving underlying causes when network, image, download, and clipboard operations fail.
    • Added configurable development API proxy targeting.
  • Chores

    • Updated TypeScript checking and development tooling for improved compatibility.
  • Style

    • Standardized formatting and utility-class ordering across the interface, scripts, tests, and metadata without changing behavior.

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.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Kreedzt, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: da32160e-c89e-4e0f-b9b6-b95b7c287ddb

📥 Commits

Reviewing files that changed from the base of the PR and between 3e5f041 and bc262e4.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml
  • .nvmrc
  • Dockerfile
📝 Walkthrough

Walkthrough

The 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.

Changes

Application maintenance

Layer / File(s) Summary
Tooling and development configuration
package.json, vite.config.ts, AGENTS.md, CLAUDE.md, .github/workflows/ci.yml
The project uses svelte-check --tsgo, updated packages, @typescript/native, and a configurable API proxy target. Documentation reflects the checker setup.
Svelte components and routes
src/lib/components/*, src/routes/*
Components and routes receive formatting, Svelte shorthand, and Tailwind class-order updates. BrandIcon now supports GitHub, and Header uses it.
Error cause preservation
src/lib/request.ts, src/lib/services/*-share.ts
Wrapped request and share-service errors now retain the original error in cause.
Build, worker, and utility normalization
scripts/*, src/lib/utils/*, worker.ts, static/manifest.webmanifest
Build expressions, environment injection, sorting, URL state, worker markup, and manifest formatting are normalized without stated behavior changes.
Test typing and fixture updates
tests/*
Tests receive formatting updates, typed PlayerView mocks, delayed mobile props creation, and the scrollMargin mock property.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • rwr-infra/robin-web#42: Changes related PlayerTable, PlayerView, +page.svelte, and url-state.ts for SID-neighbor functionality.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: adding typed callback mocks to the PlayerView tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/sid

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

@coderabbitai coderabbitai 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 12d06dd and 3e5f041.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (66)
  • .github/workflows/ci.yml
  • AGENTS.md
  • CLAUDE.md
  • package.json
  • scripts/build-cdn-sveltekit.ts
  • scripts/build-sveltekit.ts
  • scripts/inject-env.ts
  • src/lib/components/ChristmasConfetti.svelte
  • src/lib/components/ChristmasDecoration.svelte
  • src/lib/components/ChristmasSnowfall.svelte
  • src/lib/components/ControlBar.svelte
  • src/lib/components/InstallPrompt.svelte
  • src/lib/components/LayoutModeToggle.svelte
  • src/lib/components/MapPreview.svelte
  • src/lib/components/NetworkStatus.svelte
  • src/lib/components/PageSizeSelector.svelte
  • src/lib/components/Pagination.svelte
  • src/lib/components/PlayerShareCard.svelte
  • src/lib/components/PlayerShareCardMobile.svelte
  • src/lib/components/PlayerShareModal.svelte
  • src/lib/components/PlayerTable.svelte
  • src/lib/components/PlayerView.svelte
  • src/lib/components/QuickFilterButtons.svelte
  • src/lib/components/SearchInput.svelte
  • src/lib/components/ServerShareCard.svelte
  • src/lib/components/ServerShareCardMobile.svelte
  • src/lib/components/ServerShareModal.svelte
  • src/lib/components/ServerTable.svelte
  • src/lib/components/ServerView.svelte
  • src/lib/components/StatsBar.svelte
  • src/lib/components/TranslatedText.svelte
  • src/lib/components/ViewModeToggle.svelte
  • src/lib/components/icons/BrandIcon.svelte
  • src/lib/request.ts
  • src/lib/services/player-share.ts
  • src/lib/services/server-share.ts
  • src/lib/utils/sorting.ts
  • src/lib/utils/url-state.ts
  • src/routes/+layout.svelte
  • src/routes/+page.svelte
  • src/routes/AnnouncementBar.svelte
  • src/routes/Header.svelte
  • static/manifest.webmanifest
  • tests/e2e/demo.test.ts
  • tests/unit/components/AutoRefresh.svelte.test.ts
  • tests/unit/components/ControlBar.svelte.test.ts
  • tests/unit/components/LanguageSwitcher.svelte.test.ts
  • tests/unit/components/MobileInfiniteScroll.svelte.test.ts
  • tests/unit/components/PlayerDatabaseSelector.svelte.test.ts
  • tests/unit/components/PlayerView.svelte.test.ts
  • tests/unit/components/SearchInput.svelte.test.ts
  • tests/unit/components/ServerTable.svelte.test.ts
  • tests/unit/components/ServerView.svelte.test.ts
  • tests/unit/components/ThemeToggle.svelte.test.ts
  • tests/unit/config/server-columns.test.ts
  • tests/unit/hooks.server.test.ts
  • tests/unit/hooks.test.ts
  • tests/unit/player-share.test.ts
  • tests/unit/server-share.test.ts
  • tests/unit/services/background-sync.test.ts
  • tests/unit/services/players.test.ts
  • tests/unit/services/servers.test.ts
  • tests/unit/share/player-utils.test.ts
  • tests/unit/utils/url-state.test.ts
  • vite.config.ts
  • worker.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

Comment thread AGENTS.md
`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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 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 || true

Repository: 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 || true

Repository: 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:


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.

Suggested change
- 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

Comment thread vite.config.ts
Comment on lines +79 to +82
// 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',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 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.ts

Repository: 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.

@Kreedzt
Kreedzt merged commit a66e6b2 into master Aug 5, 2026
3 checks passed
@Kreedzt
Kreedzt deleted the feature/sid branch August 5, 2026 08:28
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