# Test Utils And Template Tests

## Why this note exists

This update adds meaningful package, template, and downstream test coverage while keeping ownership boundaries clear. Package-owned contracts live in package tests/test-utils; `_template` keeps scaffold smoke tests and examples; downstream projects keep custom tests for project-specific workflows and routes.

The new package-level test-utils subpaths are being prepared in the monorepo packages:

- `@elevasis/core/test-utils`
- `@elevasis/ui/test-utils`
- `@elevasis/sdk/test-utils`

Until the bundled release train publishes those expanded package surfaces, `_template` keeps small local compatibility wrappers for tests that need the new helpers. Do not replace those wrappers with local `file:` dependencies.

## Applies to

All template-derived projects that sync from `external/_template`.

Known affected projects: `nirvana-marketing`, `ZentaraHQ`.

## Required actions

### Step 1 -- Pull template changes via `/git-sync`

Accept the new tests under sync-managed scaffold surfaces:

- `ui/src/routes/__tests__/`
- `core/types/**`
- `core/config/**`
- local core compatibility helpers under `core/test-utils/`

Operations tests are intentionally narrower. Treat `operations/src/**` as project-owned runtime code. Only keep or add Operations tests in a downstream project when the project owns the workflow/module being tested. The template's email-notification tests are examples, not a requirement for every derived project.

### Step 2 -- Run the expanded test chain

From project root:

```bash
pnpm test
```

The root test script now runs `operations check` between UI and operations tests so resource-registry drift fails during ordinary test runs.

### Step 3 -- Keep compatibility wrappers until the bundled release lands

Do not delete any local compatibility wrapper that is still used by a project-owned custom test until the project has upgraded to package versions that publish the expanded test-utils subpaths.

After the release train lands, projects can migrate local compatibility imports to:

```ts
import { renderWithProviders } from '@elevasis/ui/test-utils'
import { makeProject } from '@elevasis/core/test-utils'
import { runWorkflow } from '@elevasis/sdk/test-utils'
```

### Step 4 -- Adjust only for intentionally removed features

If a derived project intentionally removed a feature route or workflow, skip or adjust the specific synced test case. For Operations, prefer project-owned tests that import package helpers over copied template workflow tests.

## Verification

- `pnpm -C ui test` passes.
- `pnpm -C operations check` passes.
- `pnpm -C operations test` passes.
- `pnpm -C core test` passes.
- `pnpm test` passes from project root.

## Not handled by /git-sync

- `/git-sync` does not publish or upgrade `@elevasis/*` package versions.
- `/git-sync` does not remove compatibility wrappers after the release train.
- `/git-sync` does not decide how a project-specific removed feature should be represented in tests.
- `/git-sync` does not force template-only Operations example tests into downstream projects that do not own the matching workflow files.
