Skip to content

INTER-2348: Close coverage gaps and drop dead wait-until helper#208

Open
JuroUhlar wants to merge 44 commits into
mainfrom
test/coverage-gaps-and-cleanup
Open

INTER-2348: Close coverage gaps and drop dead wait-until helper#208
JuroUhlar wants to merge 44 commits into
mainfrom
test/coverage-gaps-and-cleanup

Conversation

@JuroUhlar

@JuroUhlar JuroUhlar commented Jul 21, 2026

Copy link
Copy Markdown
Contributor
  • Add targeted coverage for provider initialization, rebuild behavior, SSR handling, hook race and error paths, and environment detection
  • Verify public hook behavior for default fetching, settled-request eviction, refetch state, and semantic option changes
  • Remove hollow and low-value tests
  • Delete the unused wait-until helper left over from the v4 agent migration
  • Keep the provider public API and runtime behavior unchanged

Verification

  • 42 tests passing
  • 96.4% statement, 94.79% branch, and 96.89% line coverage
  • Lint and production build passing

JuroUhlar and others added 25 commits July 17, 2026 08:39
Widen the react peer range to >=18 <20, verify the SDK against React 19
via a second CI matrix job (catalog stays pinned to 18 as the default
dev/test toolchain), and bump the Next.js examples to 16.2.10.

Add @next/eslint-plugin-next lint rules scoped to the Next examples
instead of eslint-config-next, since the latter bundles
eslint-plugin-react which only supports ESLint below version 10.
Re-add the two @eslint-react rule overrides for React 19-only idioms
so linting stays green under both supported versions.
Next.js 16 requires Node >=20.9.0; declare it explicitly so
contributors on older Node get a clear engine error instead of a
confusing runtime failure.
no-html-link-for-pages (and other core-web-vitals rules) default to
looking for pages/app at the repo root, so they silently no-op since
both Next examples live under examples/. Set settings.next.rootDir to
point at them explicitly.
Add a CI matrix that boots each example app with Playwright and asserts the
Fingerprint React SDK identifies the visitor (a visitor ID renders in the
browser). Each example is tested against the React versions it supports.

- e2e/: a single Playwright harness driven by an EXAMPLE env var, with a
  per-example registry (examples.ts) and one framework-agnostic spec.
- .github/workflows/e2e.yml: matrix of {example} x {React 18, 19}. React 19
  jobs flip the pnpm catalog so the SDK and every example move in lockstep
  (a single @types/react, which the Next App Router type-check requires).
  The preact example runs once (it uses Preact via preact/compat).
- examples: optional region env support (the CI key is EU) that leaves the
  default behavior unchanged. Also fixes pre-existing build breakage: the CRA
  example was missing react-app-env.d.ts, and the preact example's ESM
  preact.config.js failed to load on Node 22 (and was redundant with
  preact-cli's native .env / PREACT_APP_* injection) so it was removed and a
  scoped process type declaration added.

INTER-2322

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014F14pjZxadmtLq8uTuzwXb
Read the Fingerprint region from the FPJS_REGION Actions variable (defaulting
to eu) instead of hardcoding it, so the region is configurable alongside the
public key secret.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014F14pjZxadmtLq8uTuzwXb
Drop the eu fallback so the region comes solely from the FPJS_REGION repo
variable, and fail fast in the pre-flight check when it (or the API key
secret) is missing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014F14pjZxadmtLq8uTuzwXb
The Fingerprint public key isn't sensitive, so read FPJS_PUBLIC_API_KEY from
either a repo secret or a repo variable. Fixes the matrix failing when the key
was added under the Variables tab alongside FPJS_REGION.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014F14pjZxadmtLq8uTuzwXb
preact-cli's dev server (`preact watch`) fails to resolve its entrypoint on
the CI Node version and never serves, so the e2e job timed out. Build the
example once and serve the static output with sirv instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014F14pjZxadmtLq8uTuzwXb
Align examples on a shared data-testid for successful identifies, flip
React via pnpm overrides instead of sed, and verify the installed React
major in CI.
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
96.41% (+10.04% 🔼)
161/167
🟢 Branches
94.79% (+21.79% 🔼)
91/96
🟢 Functions
97.92% (+11.38% 🔼)
47/48
🟢 Lines
96.89% (+10.42% 🔼)
156/161

Test suite run success

42 tests passing in 16 suites.

Report generated by 🧪jest coverage report action from fb82343

Show full coverage report
St File % Stmts % Branch % Funcs % Lines Uncovered Line #s
🟢 All files 96.4 94.79 97.91 96.89
🟢  src 98.87 97.5 100 98.85
🟢   detect-env.ts 95 91.66 100 95 87
🟢   env.ts 100 100 100 100
🟢   env.types.ts 100 100 100 100
🟢   ...nt-context.ts 100 100 100 100
🟢   get-env.ts 100 100 100 100
🟢   ssr.ts 100 100 100 100
🟢   ...sitor-data.ts 100 100 100 100
🟢  src/components 100 100 100 100
🟢   ...-provider.tsx 100 100 100 100
🟢   ...vironment.tsx 100 100 100 100
🟢  src/utils 88.09 87.5 92.3 90
🟢   ...is-defined.ts 100 100 100 100
🟢   ...-cache-key.ts 80.76 83.33 85.71 84 5,10,43,52
🟢   to-error.ts 100 100 100 100
🟢   ...mise-store.ts 100 100 100 100

JuroUhlar and others added 4 commits July 21, 2026 13:51
Co-authored-by: Dan McNulty <212590662+mcnulty-fp@users.noreply.github.com>
Co-authored-by: Dan McNulty <212590662+mcnulty-fp@users.noreply.github.com>
Base automatically changed from inter-2322/use-visitor-data-mount-fetch to main July 22, 2026 14:22
@JuroUhlar

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Addressed in 6ea1e4a.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR strengthens test coverage around provider initialization/rebuild behavior, SSR usage, hook race/error handling, and environment detection, while removing low-value tests and deleting an unused wait-until utility.

Changes:

  • Added targeted tests for FingerprintProvider (Next.js integrationInfo, force rebuild, custom agent loader fallback, provider-level getOptions merge, SSR guard).
  • Expanded useVisitorData coverage for mid-flight option changes, null params rejection, and error normalization/preservation.
  • Improved environment detection coverage (no-window path; getEnvironment parsing vs detection fallback) and removed dead/low-signal tests and helpers.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/utils/wait-until.ts Removes an unused async polling helper.
tests/with-environment.test.tsx Drops a low-value props echo test.
tests/use-visitor-data.test.tsx Adds coverage for race/error paths and stricter error handling expectations.
tests/fpjs-provider.test.tsx Adds coverage for provider init/rebuild behavior, SSR guard, Next detection, and option merging.
tests/detect-env.test.ts Adds coverage for window-unavailable detection and getEnvironment JSON parsing fallbacks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread __tests__/use-visitor-data.test.tsx

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread __tests__/detect-env.test.ts Outdated
@JuroUhlar JuroUhlar changed the title test: close coverage gaps and drop dead wait-until helper INTER-2348: Close coverage gaps and drop dead wait-until helper Jul 23, 2026
@JuroUhlar
JuroUhlar marked this pull request as ready for review July 23, 2026 13:23
mcnulty-fp
mcnulty-fp previously approved these changes Jul 23, 2026
Comment thread __tests__/fpjs-provider.test.tsx Outdated
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Following releases will be created using changesets from this PR:

@fingerprint/react@3.1.0

Minor Changes

  • Behavior bug fixes:

    • Stale automatic useVisitorData requests (when immediate changes from true to false during an automatic request) no longer overwrite state (the result is ignored).
    • Loading state is now correctly synchronized when immediate changes.

    We recommend double-checking that your implementation isn't relying on the previous incorrect behavior when upgrading. (ba26003)

  • Add support for React 19 and Next.js 16. The react peer range now accepts >=18 <20. (5307b3b)

Patch Changes

  • Bump @fingerprint/agent dependency to ^4.1.2 and drop the fast-deep-equal runtime dependency in favor of an internal cache-key comparison. (87b776f)

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.

5 participants