tests — wizard

Module: tests-wizard Cohesion: 0.80 Members: 0

tests — wizard

This document describes the tests/wizard/onboarding.test.ts module, which contains unit tests for the core onboarding logic found in src/wizard/onboarding.ts. These tests ensure the correct behavior of configuration handling, provider mappings, and default model selections during the initial setup wizard.

Module: tests/wizard/onboarding.test.ts

Purpose

This module serves as the comprehensive test suite for the src/wizard/onboarding.ts module. It verifies that the onboarding process correctly handles provider-specific environment variables, assigns appropriate default models, and accurately writes the config.json file without exposing sensitive information.

Tested Functionality Overview

The tests in this module validate the behavior of the following key components exported by src/wizard/onboarding.ts:

  1. PROVIDER_ENV_MAP: A constant object mapping AI provider names to their corresponding environment variable names for API keys.
  2. PROVIDER_DEFAULT_MODEL: A constant object mapping AI provider names to their default model identifiers.
  3. writeConfig(configPath: string, result: OnboardingResult): A function responsible for writing the config.json file to a specified path based on the OnboardingResult object.

Test Suite Structure

The tests are organized using describe blocks, mirroring the structure of the src/wizard/onboarding.ts module's exports:

graph TD
    A[onboarding.test.ts] --> B{onboarding.js Module}
    B --> C[PROVIDER_ENV_MAP Tests]
    B --> D[PROVIDER_DEFAULT_MODEL Tests]
    B --> E[writeConfig() Tests]

Detailed Test Cases

PROVIDER_ENV_MAP Tests

This suite verifies the correctness of the PROVIDER_ENV_MAP constant.

PROVIDER_DEFAULT_MODEL Tests

This suite ensures that the PROVIDER_DEFAULT_MODEL constant provides accurate default model names for each supported AI provider.

writeConfig Tests

This is the most extensive test suite, validating the critical writeConfig function. It uses temporary directories to simulate real-world file system operations without affecting the actual project configuration.

Test Setup and Teardown

The writeConfig test suite utilizes beforeEach and afterEach hooks to manage temporary directories:

Dependencies