Skip to content

test: add unit tests for stripHtml and validateTextInput in sanitize.ts#2876

Open
yachikadev wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
yachikadev:feat/add-sanitize-unit-tests
Open

test: add unit tests for stripHtml and validateTextInput in sanitize.ts#2876
yachikadev wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
yachikadev:feat/add-sanitize-unit-tests

Conversation

@yachikadev

Copy link
Copy Markdown
Contributor

Summary

Closes #2805

Added missing unit tests for stripHtml() and validateTextInput() functions in src/lib/sanitize.ts as per issue requirements.

Changes Made

Added the following missing test cases to test/sanitize.test.ts:

stripHtml()

  • Plain text input returns unchanged output
  • Apostrophe entity decoding (' and ')
  • Mixed HTML tags and entities handled correctly

validateTextInput()

  • Script tag injection is stripped and returns ok: true with clean value

Testing

All vitest tests pass locally.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature type:testing GSSoC type bonus: tests (+10 pts) labels Jun 27, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@yachikadev

Copy link
Copy Markdown
Contributor Author

The Playwright smoke test failure is not related to this PR.
It is caused by a pnpm-lock.yaml lockfile mismatch with the current overrides config in package.json — a pre-existing repo issue. All checks relevant to this PR pass successfully.

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

Labels

gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test : add unit tests for sanitize.ts

1 participant