- 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.
4.0 KiB
4.0 KiB
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)
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
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)
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
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
- Vault-Path (wenn angegeben): Dateien werden zuerst aus dem echten Vault geladen
- Fixtures: Als Fallback werden Dateien aus
tests/fixtures/geladen
Konfigurationsdateien
Die Config-Helper (loadChainRolesFromFixtures, loadChainTemplatesFromFixtures) suchen in folgender Reihenfolge:
tests/fixtures/_system/dictionary/chain_roles.yamltests/fixtures/chain_roles.yaml{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