# How To Test

This guide describes the current verification workflow.

## Run All Tests

```bash
npm test
```

This runs Vitest across the configured test suite.

## Server And Shared Tests

```bash
npm run test:server
```

Server/shared tests cover:

* Root path resolution.
* Path traversal rejection.
* Symlink escape rejection.
* Markdown extension detection.
* File tree listing.
* Read and save behavior.
* Conflict detection.
* Create and rename behavior.
* Asset copy and link generation.
* Settings persistence.
* Express app routes.

## Client Tests

```bash
npm run test:client
```

Client tests cover:

* App loading.
* File tree rendering.
* Disabled non-Markdown files.
* Recent files.
* Mode switching.
* Dirty-state indicators.
* Manual save.
* External save requests from the file tree.
* Relative Preview link navigation.
* Outline rendering and collapse.
* Markdown preview and Mermaid rendering.
* API client error handling.

## End-To-End Smoke Tests

```bash
npm run test:e2e
```

Playwright starts the built app through:

```bash
npm run e2e:server
```

The smoke tests verify:

* App loads in a browser.
* Markdown files open.
* Editing and saving works.
* Explorer collapse preserves the editor area.
* Dirty nested files show an in-row save action.

## Documentation Screenshots

```bash
npm run build
node scripts/capture-doc-screenshots.mjs
```

This uses Playwright to update:

* `docs/project/images/workspace-source.png`
* `docs/project/images/preview-mermaid.png`
* `docs/project/images/dirty-document.png`
* `docs/project/images/collapsed-explorer.png`

## Build And Lint

```bash
npm run build
npm run lint
```

`npm run lint` runs TypeScript with `--noEmit` and a Vite test-mode build.

## Verification Before Release

Before publishing, run:

```bash
npm run lint
npm test
npm run build
npm run test:e2e
powershell -ExecutionPolicy Bypass -File scripts/package-local.ps1
```
