mindnet_obsidian/docs/TESTING_WITH_REAL_VAULT.md
Lars 3bb59afdda
Some checks are pending
Node.js build / build (20.x) (push) Waiting to run
Node.js build / build (22.x) (push) Waiting to run
Enhance template matching and chain inspection features
- Added new properties to TemplateMatch interface for tracking slots and links completeness, and confidence levels.
- Updated resolveCanonicalEdgeType function to handle optional edge vocabulary.
- Enhanced computeFindings function to include missing link constraints findings.
- Improved inspectChains function to report on links completeness and confidence levels.
- Refactored tests to utilize real configuration files and improve integration with the vault structure.
- Updated helper functions to support loading from real vault paths, enhancing test reliability.
2026-01-18 22:10:44 +01:00

113 lines
4.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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