Skip to content

[ef-18] test: add unit tests for preuninstall lifecycle script#19

Merged
NiveditJain merged 2 commits into
mainfrom
ef-18
Apr 7, 2026
Merged

[ef-18] test: add unit tests for preuninstall lifecycle script#19
NiveditJain merged 2 commits into
mainfrom
ef-18

Conversation

@NiveditJain

@NiveditJain NiveditJain commented Apr 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds __tests__/scripts/preuninstall.test.ts — the only lifecycle script without test coverage
  • 14 tests covering: dev-context guard, marker-based and legacy hook removal, empty-structure cleanup, preservation of third-party hooks, missing/corrupt file handling, multi-scope removal, path deduplication, and telemetry payload

Context

scripts/preuninstall.mjs already implements hook removal from all three Claude Code settings scopes on package uninstall. This PR adds the missing test coverage to verify that behavior is correct.

Test plan

  • bun run test:run — all 723 tests pass (14 new in this PR)
  • Manual smoke test: install the package, configure hooks, then uninstall — verify hooks are removed from ~/.claude/settings.json

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for the uninstall script to ensure reliable uninstall behavior.

Covers hook removal from all three Claude settings scopes (user,
project, local), legacy hook detection, empty-structure cleanup,
graceful error handling, dev-context guard, and telemetry payload.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 6, 2026

Copy link
Copy Markdown
ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 7434307e-8934-427b-ba09-45cbe4289960

📥 Commits

Reviewing files that changed from the base of the PR and between ca824cc and 32f76f9.

📒 Files selected for processing (1)
  • __tests__/scripts/preuninstall.test.ts

📝 Walkthrough

Walkthrough

A comprehensive test suite for the preuninstall.mjs script is being introduced, validating dev context guards, hook removal logic across multiple settings scopes, file cleanup behavior, JSON corruption handling, and telemetry event tracking with platform and architecture metadata.

Changes

Cohort / File(s) Summary
Preuninstall Script Tests
__tests__/scripts/preuninstall.test.ts
New test suite covering dev context guard behavior, hook removal from settings files (__failproofai_hook__ and legacy hook detection), multi-scope testing (user/project/local), empty structure cleanup, corrupt JSON handling, and telemetry validation with platform/arch payload.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 With hooks and settings all in place,
Tests now guard against each case—
From legacy marks to corrupt files,
Uninstall works with gentle styles!
Telemetry tracks our software grace, 🎉


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@NiveditJain NiveditJain merged commit d0ccc7f into main Apr 7, 2026
7 checks passed
@NiveditJain NiveditJain deleted the ef-18 branch April 21, 2026 01:31
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