Skip to content

Normalize toktrack models and enhance integration tests#35

Merged
tyl3r-ch merged 5 commits intomainfrom
v629
Apr 27, 2026
Merged

Normalize toktrack models and enhance integration tests#35
tyl3r-ch merged 5 commits intomainfrom
v629

Conversation

@tyl3r-ch
Copy link
Copy Markdown
Contributor

@tyl3r-ch tyl3r-ch commented Apr 27, 2026

Summary by CodeRabbit

  • New Features

    • Better recognition and aggregation of provider-suffixed Toktrack model identifiers.
    • Added changelog entry for v6.2.9.
  • Bug Fixes

    • Made PDF report language selection stable and verifiable across locales.
    • Reduced TOCTOU and unsafe file/network test flows.
    • Improved language toggle test stability via deterministic test IDs.
  • Tests

    • Strengthened E2E/integration tests to enforce trusted loopback URLs and explicit test tokens; added unit coverage for normalization.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9903e089-61d3-4a14-8e2b-fab7f94a3d0f

📥 Commits

Reviewing files that changed from the base of the PR and between 87ebec2 and 0520924.

📒 Files selected for processing (3)
  • tests/e2e/dashboard-reporting.spec.ts
  • tests/integration/server-background-registry.test.ts
  • tests/integration/server-test-helpers.ts

📝 Walkthrough

Walkthrough

Adds Toktrack-style ::<provider> suffix parsing for model names, introduces trusted loopback validation and stricter registry normalization for test server interactions (including a new fetchLocalBootstrap), makes language toggle buttons testable via deterministic data-testids, and updates E2E/integration/unit tests to use these stable hooks and validations.

Changes

Cohort / File(s) Summary
Model Name Normalization
shared/dashboard-domain.js
Adds parser for Toktrack-style ::<provider> suffixes; extracts provider when recognized and canonicalizes the model segment; getModelProvider short-circuits on suffix provider.
Locale Toggle / Reporting E2E
src/components/layout/Header.tsx, tests/e2e/dashboard-reporting.spec.ts
Adds deterministic data-testid attributes for language buttons; E2E test switches via these IDs, asserts html[lang] changes, and validates PDF report request language payload for German and English runs.
Test Server Loopback & Auth Helpers
tests/integration/server-test-helpers.ts, tests/integration/server-local-auth.test.ts, tests/integration/server-auto-import.test.ts
Introduces trusted loopback validation utilities; fetchWithTimeout and new fetchLocalBootstrap enforce loopback-only URLs; local auth token provisioning via TTDASH_LOCAL_AUTH_TOKEN and bootstrap fetch URL changes; cleanup now consistently writes release sentinel.
Background Registry Hardening
tests/integration/server-test-helpers.ts, tests/integration/server-background-registry.test.ts
readBackgroundRegistry/tryReadBackgroundRegistry now validate and normalize entries (numeric pid/port, required fields, trusted-loopback URLs); writeBackgroundRegistry signature tightened to BackgroundRegistryEntry[] and rejects entries that would be changed by normalization; tests updated to compute port/origin from sharedServer.baseUrl and conditionally include authHeader.
Unit Tests for Normalization & Colors
tests/unit/model-normalization.test.ts, tests/unit/model-colors.test.ts, tests/unit/dashboard-aggregation.test.ts
Adds cases verifying Toktrack-suffixed names (e.g., GPT-5 4::openai) normalize to canonical names (GPT-5.4), aggregate correctly across provider/overall metrics, and map to consistent colors.
Changelog
CHANGELOG.md
Adds 6.2.9 entry documenting model normalization, test/E2E changes, PDF locale assertions, security/TOCTOU fixes, and included commit SHAs.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I parse the suffix, tidy model names bright,
I guard loopback paths through the dark of the night,
I press the language button with a steady test id,
PDFs obey, and registries no longer hid. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.57% 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 accurately reflects the main changes: normalizing toktrack model names with provider suffixes and enhancing integration tests with loopback validation and explicit test IDs.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v629

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGELOG.md`:
- Around line 3-18: Update the changelog header line "## [6.2.9] - 2026-04-28"
to use the actual release date (or remove the date if you prefer undated
entries) so the entry reflects the real publication time; locate the header
string "## [6.2.9] - 2026-04-28" in CHANGELOG.md and replace the incorrect
future date with the correct date for the release.

In `@tests/e2e/dashboard-reporting.spec.ts`:
- Around line 14-17: Test assumes German but doesn't explicitly set it; before
clicking the Report button, programmatically switch language to German (e.g.,
invoke the app language toggle via the command palette or call the settings/i18n
API) so the page.getByRole('button', { name: 'Report' }).click() and subsequent
expect.poll(() => pdfReport.getReportRequest()?.language).toBe('de') are
deterministic; update the test to perform that explicit language switch (using
the same selectors or a helper that wraps initI18n) immediately prior to the
first assertion.

In `@tests/integration/server-test-helpers.ts`:
- Around line 699-707: The writeBackgroundRegistry function currently only
checks that normalizedEntries.length === entries.length, which allows entries
that normalize to different values to be silently rewritten; update
writeBackgroundRegistry to enforce strict equivalence by comparing each original
entries[i] against normalizedEntries[i] (use a deep equality check such as
JSON.stringify or an existing deepEqual helper) and throw an Error (including
the index or a short description) if any entry differs, before writing the file;
reference the normalizeBackgroundRegistryEntries call and the
normalizedEntries/entries variables and fail fast so invalid fixtures are
rejected instead of being rewritten.
🪄 Autofix (Beta)

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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a763b9f7-819b-4ac3-a677-0013ee46cfef

📥 Commits

Reviewing files that changed from the base of the PR and between f826da0 and 87ebec2.

📒 Files selected for processing (11)
  • CHANGELOG.md
  • shared/dashboard-domain.js
  • src/components/layout/Header.tsx
  • tests/e2e/dashboard-reporting.spec.ts
  • tests/integration/server-auto-import.test.ts
  • tests/integration/server-background-registry.test.ts
  • tests/integration/server-local-auth.test.ts
  • tests/integration/server-test-helpers.ts
  • tests/unit/dashboard-aggregation.test.ts
  • tests/unit/model-colors.test.ts
  • tests/unit/model-normalization.test.ts

Comment thread CHANGELOG.md
Comment thread tests/e2e/dashboard-reporting.spec.ts
Comment thread tests/integration/server-test-helpers.ts
@tyl3r-ch tyl3r-ch enabled auto-merge April 27, 2026 23:39
@tyl3r-ch tyl3r-ch merged commit ba32052 into main Apr 27, 2026
11 checks passed
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