Skip to content

test: add unit test coverage across app and server#51

Open
toddeTV wants to merge 7 commits into
mainfrom
test/add-unit-coverage-tests
Open

test: add unit test coverage across app and server#51
toddeTV wants to merge 7 commits into
mainfrom
test/add-unit-coverage-tests

Conversation

@toddeTV
Copy link
Copy Markdown
Owner

@toddeTV toddeTV commented May 23, 2026

Summary by CodeRabbit

  • Tests

    • Added comprehensive unit test suites for phone URI, vCard, security.txt, build-release metadata, and project metadata logic.
    • CI now includes a dedicated unit test job and runs unit tests as part of the test script.
  • Chores

    • Updated build/test tooling and configuration (install hooks, test scripts, Vite config, staged linting).
    • Introduced centralized security.txt content generation and minor ignore-list updates.

Review Change Stack

@toddeTV toddeTV self-assigned this May 23, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 9e637658-2bac-477f-9e2f-622846fd938d

📥 Commits

Reviewing files that changed from the base of the PR and between 30d6144 and ecc12b3.

📒 Files selected for processing (3)
  • .gitignore
  • eslint.config.mjs
  • package.json
✅ Files skipped from review due to trivial changes (2)
  • eslint.config.mjs
  • .gitignore

📝 Walkthrough

Walkthrough

Adds Vite test config, updates package scripts and CI to run unit tests, extracts security.txt generation into utilities used by the route, and introduces multiple unit test suites for phone URI, vCard, release metadata, project metadata, and redirects.

Changes

Test Infrastructure and Utility Test Coverage

Layer / File(s) Summary
Test Infrastructure Setup
vite.config.ts, package.json, .github/workflows/validation-and-tests.yml
Vite config with staged ESLint, test discovery for app/, server/, shared/, scripts/; package.json adds postinstall, changes prepare to vp config --hooks-only, replaces wildcard test:* with explicit test:lint, test:redirects, test:types, test:unit, and adds test:unit to run vp test across multiple directories. CI workflow matrix adds a "Unit Tests" entry to run vp run test:unit.
Security.txt Utility Extraction
server/utils/security-txt.ts, server/utils/security-txt.test.ts, server/routes/.well-known/security.txt.get.ts
Adds defaultSecurityTxtLifetimeDays, SecurityTxtContentOptions, createSecurityTxtExpires(now, lifetimeDays), and buildSecurityTxtContent(options, now); tests validate expiration formatting, required fields and newline formatting, and optional Policy inclusion. Route now imports and uses buildSecurityTxtContent.
Phone URI Test Coverage
app/utils/build-phone-uri.test.ts
Test suite for buildPhoneUri verifying normalization of spaced/international numbers to tel: URIs, preservation of existing tel: URIs, stripping of display separators, and returning empty string when no digits present.
vCard Generation Test Coverage
app/utils/buildVCard.test.ts
Tests for buildVCard asserting field ordering (BEGIN/VERSION, name fields, URL/NOTE, EMAIL, TEL TYPE=CELL, X-SOCIALPROFILE entries, END), correct CRLF joining, escaping of semicolons/commas/backslashes/newlines, and omission of optional fields when deselected.
Metadata Processing Test Coverage
server/utils/build-release-metadata.test.ts, shared/utils/project-metadata.test.ts, shared/utils/project-metadata-redirects.test.ts
Build-release metadata tests for env precedence, date normalization and UTC fallback, unknown commit handling. Project metadata tests for deriving author fields, filtering/sorting/deduping socials, featured ordering, and primary contact extraction. Redirects tests validate group ordering, flattened entries, redirect route rule correctness, and Cloudflare artifact formatting.
Misc tooling ignores
.gitignore, eslint.config.mjs
Adds .wrangler to .gitignore and ESLint global ignores.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • toddeTV/todde.tv#4: Prior changes to package.json scripts and test/prepare tooling that relate to current script adjustments.
  • toddeTV/todde.tv#5: Earlier changes to the CI run-checks matrix affecting how test commands are run.
  • toddeTV/todde.tv#46: Related CI/workflow updates that introduced vp test commands into the matrix.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'test: add unit test coverage across app and server' directly and accurately summarizes the main changes: adding unit tests across multiple directories (app/, server/, shared/, scripts/) with new test files and test infrastructure setup.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.


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

🧹 Nitpick comments (1)
vite.config.ts (1)

5-5: ⚡ Quick win

Add JSDoc for resolveWorkspacePath.

This helper is missing a brief JSDoc block, which is required by project conventions.

♻️ Proposed patch
+/** Resolves a repository-relative path to an absolute filesystem path. */
 const resolveWorkspacePath = (path: string) => fileURLToPath(new URL(path, import.meta.url))

As per coding guidelines, "Brief JSDoc on all functions."

🤖 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` at line 5, Add a brief JSDoc block above the
resolveWorkspacePath function that describes its purpose, the parameter (path:
string) and the return value (string), following project conventions; e.g.,
include a one-line description, `@param` {string} path brief note, and `@returns`
{string} file system path so linters and documentation pick it up for the
resolveWorkspacePath helper.
🤖 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 `@package.json`:
- Line 69: The test script "test:unit" currently uses the --passWithNoTests flag
which can cause CI to succeed when no tests are discovered; update the
package.json "test:unit" script (the value for the "test:unit" key) to remove
the --passWithNoTests flag (or replace it with a CI-aware alternative that fails
when zero tests run) so that test discovery failures cause the CI job to fail.

---

Nitpick comments:
In `@vite.config.ts`:
- Line 5: Add a brief JSDoc block above the resolveWorkspacePath function that
describes its purpose, the parameter (path: string) and the return value
(string), following project conventions; e.g., include a one-line description,
`@param` {string} path brief note, and `@returns` {string} file system path so
linters and documentation pick it up for the resolveWorkspacePath helper.
🪄 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.yml

Review profile: CHILL

Plan: Pro

Run ID: fdaaad6f-adc4-4df3-9ec8-fb3a4ca0fd90

📥 Commits

Reviewing files that changed from the base of the PR and between fc61683 and 30d6144.

📒 Files selected for processing (11)
  • .github/workflows/validation-and-tests.yml
  • app/utils/build-phone-uri.test.ts
  • app/utils/buildVCard.test.ts
  • package.json
  • server/routes/.well-known/security.txt.get.ts
  • server/utils/build-release-metadata.test.ts
  • server/utils/security-txt.test.ts
  • server/utils/security-txt.ts
  • shared/utils/project-metadata-redirects.test.ts
  • shared/utils/project-metadata.test.ts
  • vite.config.ts

Comment thread package.json Outdated
@toddeTV
Copy link
Copy Markdown
Owner Author

toddeTV commented May 23, 2026

I am not applying this nitpick. The repo rule asks for brief JSDoc on non-trivial functions, and resolveWorkspacePath here is a trivial one-line helper in config code.

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