# Testing mit echtem Vault ## Übersicht Die Test-Infrastruktur unterstützt jetzt das Testen mit echten Vault-Dateien und Konfigurationen. Du musst **nicht** mehr Dateien in die Fixtures kopieren - du kannst direkt auf dein echtes Vault verweisen. ## Verwendung ### Option 1: Nur Fixtures (Standard) ```typescript import { createVaultAppFromFixtures } from "../helpers/vaultHelper"; import { loadChainRolesFromFixtures, loadChainTemplatesFromFixtures } from "../helpers/configHelper"; const app = createVaultAppFromFixtures(); const chainRoles = loadChainRolesFromFixtures(); const chainTemplates = loadChainTemplatesFromFixtures(); ``` ### Option 2: Echter Vault-Path ```typescript import { createVaultAppFromPath } from "../helpers/vaultHelper"; import { loadChainRolesFromFixtures, loadChainTemplatesFromFixtures } from "../helpers/configHelper"; const vaultPath = "\\\\nashome\\mindnet\\vault\\mindnet_dev"; const app = createVaultAppFromPath(vaultPath); const chainRoles = loadChainRolesFromFixtures(vaultPath); const chainTemplates = loadChainTemplatesFromFixtures(vaultPath); ``` ### Option 3: Hybrid (Vault + Fixtures als Fallback) ```typescript import { createVaultAppFromFixtures } from "../helpers/vaultHelper"; const vaultPath = "\\\\nashome\\mindnet\\vault\\mindnet_dev"; const app = createVaultAppFromFixtures(vaultPath); // Lädt zuerst aus vaultPath, dann aus fixtures als Fallback ``` ## Beispiel: Test mit echtem Vault ```typescript import { describe, it, expect } from "vitest"; import { matchTemplates } from "../../analysis/templateMatching"; import { createVaultAppFromPath } from "../helpers/vaultHelper"; import { loadChainRolesFromFixtures, loadChainTemplatesFromFixtures } from "../helpers/configHelper"; import { buildNoteIndex } from "../../analysis/graphIndex"; import type { TFile } from "obsidian"; describe("template matching with real vault", () => { const vaultPath = "\\\\nashome\\mindnet\\vault\\mindnet_dev"; it("should match template from real vault note", async () => { const app = createVaultAppFromPath(vaultPath); const chainRoles = loadChainRolesFromFixtures(vaultPath); const chainTemplates = loadChainTemplatesFromFixtures(vaultPath); if (!chainRoles || !chainTemplates) { throw new Error("Config files not found"); } // Lade echte Note aus dem Vault const currentFile = app.vault.getAbstractFileByPath("leitbild/Leitbild – Identity Core (MOC).md"); if (!currentFile || !("extension" in currentFile) || currentFile.extension !== "md") { throw new Error("File not found"); } const { edges } = await buildNoteIndex(app, currentFile as TFile); const matches = await matchTemplates( app, { file: currentFile.path, heading: null }, edges, chainTemplates, chainRoles, mockEdgeVocabulary, { includeNoteLinks: true, includeCandidates: false } ); expect(matches.length).toBeGreaterThan(0); }); }); ``` ## Priorität beim Laden 1. **Vault-Path** (wenn angegeben): Dateien werden zuerst aus dem echten Vault geladen 2. **Fixtures**: Als Fallback werden Dateien aus `tests/fixtures/` geladen ## Konfigurationsdateien Die Config-Helper (`loadChainRolesFromFixtures`, `loadChainTemplatesFromFixtures`) suchen in folgender Reihenfolge: 1. `tests/fixtures/_system/dictionary/chain_roles.yaml` 2. `tests/fixtures/chain_roles.yaml` 3. `{vaultPath}/_system/dictionary/chain_roles.yaml` (wenn vaultPath angegeben) ## Vorteile - ✅ **Kein Kopieren nötig**: Teste direkt gegen echte Vault-Dateien - ✅ **Fallback**: Fixtures werden automatisch als Fallback verwendet - ✅ **Flexibel**: Kann mit Fixtures, echtem Vault oder beidem arbeiten - ✅ **Wartbar**: Änderungen am echten Vault werden sofort in Tests sichtbar ## Hinweise - Verwende absolute Pfade für Vault-Paths (z.B. `\\\\nashome\\mindnet\\vault\\mindnet_dev`) - Die Funktionen sind read-only - keine Dateien werden modifiziert - Bei Netzwerk-Pfaden kann die Performance langsamer sein als mit lokalen Fixtures