activeloopai / activeloopai/hivemind

test layout: move shared tests out of `claude-code/tests/` to a root-level `tests/` dir

Đang mở
#123 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
1.6k
Fork
107
Merge trung bình
17 giờ 30 phút
Pull request đã merge (30 ngày)
6

Mô tả

## Problem

`claude-code/tests/` currently holds **107 test files** — but the overwhelming majority test code that has nothing to do with claude-code specifically:

- Tests for shared `src/` modules (auth, cli, deeplake-api, embeddings, hooks, skillify, notifications, …)
- Tests that exercise **other agents'** bundles (`cursor-session-start-hook.test.ts`, `hermes-session-start-hook.test.ts`, `cli-install-codex-fs.test.ts`, `cli-install-openclaw.test.ts`, etc.)

By contrast, the agent-specific test directories are tiny:
- `codex/tests/` — 4 files (codex hooks + capture integration)
- `openclaw/tests/` — 3 files (auto-recall, hivemind-tools, setup-command)
- `cursor/` / `hermes/` / `pi/` — no `tests/` dir at all; their tests live under `claude-code/tests/`

The root `vitest.config.ts:4-6` already acknowledges the oddity:

> The one in claude-code/ is a historical leftover and is not used by the root test script.

## Proposal

Move shared tests to a root-level `tests/` directory and keep `/tests/` for genuinely agent-specific integration tests.

### Target layout

```
tests/ <- new home for everything that tests shared src/
auth.test.ts
deeplake-api.test.ts
skillify-*.test.ts
embeddings/*.test.ts
...

claude-code/tests/ <- claude-code-specific only
session-start-hook.test.ts (the one that tests CC's own SessionStart bundle)
install-end-to-end.test.ts (if it really only exercises CC)
...

codex/tests/ <- unchanged
cursor/tests/ <- new home for cursor-session-start-hook.test.ts, etc.
hermes/tests/ <- new home for hermes-session-start-hook.test.ts, etc.
openclaw/tests/ <- unchanged
pi/tests/ <- new home for pi-* tests if they exist
```

### Steps

1. `git mv` the ~95 shared-module tests from `claude-code/tests/` to `tests/`
2. `git mv` cursor/hermes hook tests to their respective `/tests/` directories
3. Update import paths in moved tests (`../../src/...` → `../src/...` for `tests/`, stays `../../src/...` for `/tests/`)
4. Update `vitest.config.ts` `include` array:
```ts
include: [
"tests/**/*.test.ts",
"claude-code/tests/**/*.test.ts",
"codex/tests/**/*.test.ts",
"cursor/tests/**/*.test.ts",
"hermes/tests/**/*.test.ts",
"openclaw/tests/**/*.test.ts",
"pi/tests/**/*.test.ts",
],
```
5. Update the stale comment in `vitest.config.ts:4-6`
6. Grep CI workflows for hardcoded `claude-code/tests/` paths and update (`ci.yml` references it in the coverage step)
7. Update the testing-philosophy section in CLAUDE.md that names `claude-code/tests/upload-summary.test.ts` etc. — those paths will change

### Gotchas to handle in the PR

- **Big diff**: ~107 file moves, but mechanical — should be reviewable as a pure rename PR
- **Import paths**: relative `../../src/` becomes `../src/` for files moved to root `tests/`. Codemod-able with `sed -i`
- **Agent boundary judgment calls**: some tests live in `claude-code/tests/` but exercise generic shared code via a claude-code-bundled artifact (e.g. bundle-scan tests). These could go either way — root `tests/` if they cover all-agent invariants, `claude-code/tests/` if specifically about CC's bundle
- **Coverage thresholds in `vitest.config.ts`**: per-file `thresholds` block references `src/**` paths, not test paths — no change needed there
- **Pre-commit hook + lint-staged**: only target `*.ts` globally, unaffected

### Why now / why not later

- **Why now**: skillify code lives under `src/skillify/` (root), gets bundled into every agent, but its tests live under `claude-code/tests/skillify-*.test.ts` — actively confusing for anyone navigating the codebase. The wrong location reinforces the wrong mental model.
- **Why not later**: a refactor PR is cheaper to land in isolation than bundled with a feature change. Every PR that touches a test file under `claude-code/tests/` (i.e. most PRs) postpones this by burying it under reviewer fatigue.

## Out of scope

- Splitting tests by domain (`tests/auth/`, `tests/skillify/`, etc.) — possible follow-up; this issue just gets the wrong-named container fixed first.
- Migrating coverage thresholds — they key on `src/**`, unaffected.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.