tests — plugins

Module: tests-plugins Cohesion: 0.80 Members: 0

tests — plugins

This document provides an overview of the unit tests for the plugin system, focusing on the tests/plugins module. It covers the purpose of these tests, the key components they validate, and how they ensure the robustness and correctness of the plugin architecture and bundled providers.

1. Introduction

The tests/plugins module contains a comprehensive suite of unit tests designed to validate the core plugin management system, the plugin SDK, and all bundled provider plugins. These tests are crucial for ensuring that:

By isolating and testing individual components, this module helps maintain a high level of confidence in the extensibility and functionality of the application's plugin ecosystem.

2. Testing Philosophy

The tests in this module adhere to a unit testing philosophy, characterized by:

3. Core Plugin Management Tests (plugin-manager.test.ts)

This file tests the central PluginManager class, which is responsible for the entire lifecycle and management of plugins and their registered providers.

3.1. Plugin Discovery and Lifecycle

3.2. Provider Registration and Retrieval

The PluginManager acts as a registry for various types of providers (LLM, embedding, search) that plugins can offer.

3.3. Plugin Configuration

Plugins can define default configurations and allow users to override them.

3.4. Mocking Strategy

plugin-manager.test.ts heavily mocks file system operations (fs-extra), the ToolManager, SlashCommandManager, and IsolatedPluginRunner to focus solely on the PluginManager's internal logic.

4. Provider Onboarding & Lifecycle Tests (provider-onboarding.test.ts)

This file tests the runProviderOnboarding utility function, which orchestrates the multi-step onboarding process for providers, and includes specific tests for the bundled Ollama and vLLM LLM providers.

4.1. runProviderOnboarding Utility

The runProviderOnboarding function guides a user through setting up a provider, including authentication, configuration, and model selection.

graph TD
    A[Start runProviderOnboarding] --> B{Provider has onboarding hooks?};
    B -- No --> Z[Return success: skipped];
    B -- Yes --> C{Auth hook defined?};
    C -- Yes --> D[Call onboarding.auth()];
    D -- Valid: false / Error --> E[Return failure: Auth failed];
    D -- Valid: true --> F{Wizard onboarding hook defined?};
    F -- Yes --> G[Call onboarding.wizard.onboarding()];
    G -- Returns config --> H{Discovery hook defined?};
    H -- Yes --> I[Call onboarding.discovery.run()];
    I -- Error --> J[Return failure: Discovery error];
    I -- Returns models --> K{Models found?};
    K -- No --> L[Skip modelPicker];
    K -- Yes --> M{Model picker hook defined?};
    M -- Yes --> N[Call onboarding.wizard.modelPicker(models)];
    N -- Returns selectedModelId --> O{onModelSelected hook defined?};
    O -- Yes --> P[Call onboarding.onModelSelected(selectedModelId)];
    P -- No / Done --> Q[Return success: Onboarding complete];
    L --> Q;
    M -- No --> Q;
    F -- No --> H;

4.2. Ollama Provider Tests

4.3. vLLM Provider Tests

4.4. Mocking Strategy

Both runProviderOnboarding and the specific provider tests heavily mock global.fetch to simulate API responses and network conditions, and logger for output.

5. Bundled LLM Provider Tests

These files test the integration of various cloud and local LLM providers.

5.1. Cloud Providers (cloud-providers.test.ts)

This file focuses on AWS Bedrock and Azure OpenAI.

5.2. Extra Providers (extra-providers.test.ts)

This file covers Groq, Together AI, and Fireworks AI.

6. GitNexus Integration Tests (gitnexus.test.ts)

This file tests the GitNexusManager and GitNexusMCPClient classes, which facilitate interaction with the GitNexus CLI and its Micro-service Control Plane (MCP).

6.1. GitNexusManager

6.2. GitNexusMCPClient

The GitNexusMCPClient is designed to interact with a running GitNexus MCP server. In these unit tests, it operates in a "stub mode" as no actual MCP server is started.

6.3. Mocking Strategy

gitnexus.test.ts heavily mocks child_process (execSync, spawn) to control CLI execution, fs (existsSync, readFileSync) for file system interactions, and logger for output.

7. Plugin SDK Channel Tests (plugin-sdk-channel.test.ts)

This file tests the defineChannel function from the plugin SDK, specifically focusing on its ability to define a describeMessageTool method for channel plugins.

7.1. Mocking Strategy

This test file focuses on the pure functional aspects of defineChannel and does not require any external mocks.