# Orchard API Functional Tests (nodeV2)

## Folder Structure

- `config/` — Configuration files (API hosts, test data, project/client definitions)
- `helpers/` — Utility/helper modules for assertions, client setup, payloads, etc.
- `payloads/` — Request payload templates for various API endpoints
- `setup/` — Global and per-project Jest setup scripts
- `specs/` — Test suites organized by project type:
  - `DA/`, `NoAccessToken/`, `NonDA/`, `OA/`, `Subaccount/` — Each contains relevant API test specs
- `biome.json`, `jest.config.js`, `package.json`, `pnpm-lock.yaml` — Project configuration and dependency management


## Scripts Overview

The following scripts are available in `package.json`:

| Script                | Description                                                      |
|-----------------------|------------------------------------------------------------------|
| `pnpm format`         | Formats all files using Biome (`biome format . --write`).         |
| `pnpm lint`           | Lints all files using Biome (`biome lint .`).                     |
| `pnpm check`          | Runs Biome's static analysis checks (`biome check .`).            |
| `pnpm test`           | Runs all Jest tests.                                              |
| `pnpm test:integration` | Runs Jest tests with up to 5 workers (parallel integration tests).|
| `pnpm test:serial`    | Runs Jest tests serially (one at a time, useful for debugging).   |
| `pnpm test:watch`     | Runs Jest in watch mode (reruns tests on file changes).           |
| `pnpm test:da`        | Runs only DA project tests.                                       |
| `pnpm test:nonDa`     | Runs only NonDA project tests.                                    |
| `pnpm test:subaccount`| Runs only Subaccount project tests.                               |
| `pnpm test:oa`        | Runs only OA project tests.                                       |
| `pnpm test:noAccessToken` | Runs only NoAccessToken project tests.                        |

You can run any script with `pnpm <script>`, e.g.:

```sh
pnpm lint
pnpm test:oa
```

## Getting Started

### 1. Install Dependencies

```sh
pnpm install
```

### 2. Environment Variables

- Copy `.env.shadow` to `.env`:
  ```sh
  cp .env.shadow .env
  ```
- By default, tests run against the QA server. To test against your local server, edit `.env` and set:
  ```env
  FRISBY_VAPI_HOST=http://localhost:3000
  ```

### 3. Running Tests

- Run all tests:
  ```sh
  pnpm test
  ```
- Run tests for a specific project (e.g., NonDA):
  ```sh
  pnpm test:nonDa
  ```
  (Other scripts may be defined in `package.json` for DA, OA, etc.)

### 4. Suppressing dotenv Logs

To hide verbose dotenv logs, add this to your `.env`:
```
DOTENV_CONFIG_QUIET=true
```

## Adding/Editing Tests
- Add new test specs in the appropriate `specs/<Project>/` folder.
- Use helpers and payloads from `helpers/` and `payloads/` for consistency.
- Update or add configuration in `config/` as needed.

## Notes
- Make sure your local server is running if you point `FRISBY_VAPI_HOST` to localhost.
- All environment variables in `.env` are loaded automatically via `dotenv`.
- For any issues with dependencies, run `pnpm approve-builds` if prompted.

---

For further details, see comments in the code or reach out to the project maintainer.
