Skip to content

Fix code-review correctness + test/config findings - #71

Open
cyongverto wants to merge 1 commit into
upgrade/angular-22from
fix/review-correctness
Open

Fix code-review correctness + test/config findings#71
cyongverto wants to merge 1 commit into
upgrade/angular-22from
fix/review-correctness

Conversation

@cyongverto

Copy link
Copy Markdown
Contributor

Stacked on #69 (upgrade/angular-22). Addresses verified findings from the high-effort code review of the Angular 18→22 PR stack.

Correctness

  • OnPush staleness in the different-size demo — the component is ChangeDetectionStrategy.OnPush, but the constructor's queryParamMap subscription mutated size (bound to [size] and [ngModel]) from an async router emission that never marked the view dirty. On browser back/forward the dropdown and widget showed a stale size. Now calls markForCheck() after updating, and pipes through takeUntilDestroyed().

Test / config correctness

  • Explicit standalone: true on the value-accessor directive — it was relying on the Angular 22 default while the forms module lists it in imports:. Made explicit so form integration stays valid across the advertised Angular 18+ peer floor.
  • Dead vitest demo test targetngx-turnstile-demo declared a @analogjs/vitest-angular:test target that shared the library's root vitest config and ran zero specs (a false-green target). Removed it along with its orphaned tsconfig.spec.json. CI already targets the library explicitly (ng test ngx-turnstile).
  • Vitest include glob — dropped the workspace-root-relative glob. Vitest runs with the project directory as its root, so src/**/*.spec.ts is the glob that actually matches the library specs (the review's original claim about which glob was dead was inverted; verified by running).

Not addressed here

  • The reviewed "reset() emits null into the form control on token expiry" finding was intentionally left as-is: clearing an expired Turnstile token from the bound control is correct security behavior — an expired CAPTCHA token must not remain submittable, and Cloudflare's default refresh-expired: auto re-issues a fresh token right after. See the discussion for rationale.
  • Pure-cleanup findings (CI install caching, redundant tsconfig target, .gitignore/eslint noise, cypress tsconfig extends, dropped ng-reflect-language e2e assertion) are out of scope for this correctness-focused PR.

Verification

  • ng test ngx-turnstile --watch=false → 2 files, 5 tests pass
  • ng build ngx-turnstile and ng build ngx-turnstile-demo → build clean
  • ng lint → all files pass
  • prettier --check on changed files → clean

🤖 Generated with Claude Code

- different-size demo (OnPush): mark the view dirty when a router
  query-param emission mutates `size`, so back/forward navigation
  re-renders the widget/select instead of showing a stale size.
  Also pipe the subscription through takeUntilDestroyed().
- value-accessor directive: declare `standalone: true` explicitly
  instead of relying on the Angular 22 default, so the forms-module
  `imports:` entry stays valid across the Angular 18+ peer range.
- vitest: drop the dead workspace-root-relative include glob; vitest
  runs with the project dir as its root, so `src/**/*.spec.ts` is the
  glob that matches the library specs.
- remove the misleading ngx-turnstile-demo `test` target (and its
  orphaned tsconfig.spec.json): it ran zero specs and shared the
  library's root vitest config, giving a false-green test target.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@github-actions github-actions 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.

This pull request does not contain a valid label. Please add one of the following labels: ['major', 'minor', 'patch']

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying ngx-turnstile with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2e29833
Status: ✅  Deploy successful!
Preview URL: https://8d10ea99.ngx-turnstile.pages.dev
Branch Preview URL: https://fix-review-correctness.ngx-turnstile.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

1 participant