feat: initial implementation of TFTSR IT Triage & RCA application
Implements Phases 1-8 of the TFTSR implementation plan.
Rust backend (Tauri 2.x, src-tauri/):
- Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama
- PII detection engine: 11 regex patterns with overlap resolution
- SQLCipher AES-256 encrypted database with 10 versioned migrations
- 28 Tauri IPC commands for triage, analysis, document, and system ops
- Ollama: hardware probe, model recommendations, pull/delete with events
- RCA and blameless post-mortem Markdown document generators
- PDF export via printpdf
- Audit log: SHA-256 hash of every external data send
- Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2)
Frontend (React 18 + TypeScript + Vite, src/):
- 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings
- 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives
- 3 Zustand stores: session, settings (persisted), history
- Type-safe tauriCommands.ts matching Rust backend types exactly
- 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs)
DevOps:
- .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push
- .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload
Verified:
- cargo check: zero errors
- tsc --noEmit: zero errors
- vitest run: 13/13 unit tests passing
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 03:36:25 +00:00
|
|
|
import { describe, it, expect, beforeEach } from "vitest";
|
|
|
|
|
import { useSettingsStore } from "@/stores/settingsStore";
|
|
|
|
|
import type { ProviderConfig } from "@/lib/tauriCommands";
|
|
|
|
|
|
|
|
|
|
const mockProvider: ProviderConfig = {
|
|
|
|
|
name: "openai",
|
|
|
|
|
api_url: "https://api.openai.com/v1",
|
|
|
|
|
api_key: "sk-test-key",
|
|
|
|
|
model: "gpt-4o",
|
|
|
|
|
};
|
|
|
|
|
|
2026-04-06 00:33:23 +00:00
|
|
|
const DEFAULT_PII_PATTERNS = ["email", "ip_address", "phone", "ssn", "credit_card", "hostname", "password", "api_key"];
|
|
|
|
|
|
feat: initial implementation of TFTSR IT Triage & RCA application
Implements Phases 1-8 of the TFTSR implementation plan.
Rust backend (Tauri 2.x, src-tauri/):
- Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama
- PII detection engine: 11 regex patterns with overlap resolution
- SQLCipher AES-256 encrypted database with 10 versioned migrations
- 28 Tauri IPC commands for triage, analysis, document, and system ops
- Ollama: hardware probe, model recommendations, pull/delete with events
- RCA and blameless post-mortem Markdown document generators
- PDF export via printpdf
- Audit log: SHA-256 hash of every external data send
- Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2)
Frontend (React 18 + TypeScript + Vite, src/):
- 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings
- 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives
- 3 Zustand stores: session, settings (persisted), history
- Type-safe tauriCommands.ts matching Rust backend types exactly
- 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs)
DevOps:
- .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push
- .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload
Verified:
- cargo check: zero errors
- tsc --noEmit: zero errors
- vitest run: 13/13 unit tests passing
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 03:36:25 +00:00
|
|
|
describe("Settings Store", () => {
|
|
|
|
|
beforeEach(() => {
|
2026-04-05 04:37:05 +00:00
|
|
|
localStorage.clear();
|
feat: initial implementation of TFTSR IT Triage & RCA application
Implements Phases 1-8 of the TFTSR implementation plan.
Rust backend (Tauri 2.x, src-tauri/):
- Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama
- PII detection engine: 11 regex patterns with overlap resolution
- SQLCipher AES-256 encrypted database with 10 versioned migrations
- 28 Tauri IPC commands for triage, analysis, document, and system ops
- Ollama: hardware probe, model recommendations, pull/delete with events
- RCA and blameless post-mortem Markdown document generators
- PDF export via printpdf
- Audit log: SHA-256 hash of every external data send
- Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2)
Frontend (React 18 + TypeScript + Vite, src/):
- 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings
- 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives
- 3 Zustand stores: session, settings (persisted), history
- Type-safe tauriCommands.ts matching Rust backend types exactly
- 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs)
DevOps:
- .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push
- .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload
Verified:
- cargo check: zero errors
- tsc --noEmit: zero errors
- vitest run: 13/13 unit tests passing
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 03:36:25 +00:00
|
|
|
useSettingsStore.setState({
|
|
|
|
|
theme: "dark",
|
|
|
|
|
ai_providers: [],
|
|
|
|
|
active_provider: undefined,
|
|
|
|
|
default_provider: "ollama",
|
|
|
|
|
default_model: "llama3.2:3b",
|
|
|
|
|
ollama_url: "http://localhost:11434",
|
2026-04-06 00:33:23 +00:00
|
|
|
pii_enabled_patterns: Object.fromEntries(DEFAULT_PII_PATTERNS.map((id) => [id, true])),
|
feat: initial implementation of TFTSR IT Triage & RCA application
Implements Phases 1-8 of the TFTSR implementation plan.
Rust backend (Tauri 2.x, src-tauri/):
- Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama
- PII detection engine: 11 regex patterns with overlap resolution
- SQLCipher AES-256 encrypted database with 10 versioned migrations
- 28 Tauri IPC commands for triage, analysis, document, and system ops
- Ollama: hardware probe, model recommendations, pull/delete with events
- RCA and blameless post-mortem Markdown document generators
- PDF export via printpdf
- Audit log: SHA-256 hash of every external data send
- Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2)
Frontend (React 18 + TypeScript + Vite, src/):
- 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings
- 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives
- 3 Zustand stores: session, settings (persisted), history
- Type-safe tauriCommands.ts matching Rust backend types exactly
- 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs)
DevOps:
- .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push
- .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload
Verified:
- cargo check: zero errors
- tsc --noEmit: zero errors
- vitest run: 13/13 unit tests passing
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 03:36:25 +00:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("adds a provider", () => {
|
|
|
|
|
useSettingsStore.getState().addProvider(mockProvider);
|
|
|
|
|
expect(useSettingsStore.getState().ai_providers).toHaveLength(1);
|
|
|
|
|
expect(useSettingsStore.getState().ai_providers[0].name).toBe("openai");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("removes a provider", () => {
|
|
|
|
|
useSettingsStore.getState().addProvider(mockProvider);
|
|
|
|
|
useSettingsStore.getState().removeProvider(0);
|
|
|
|
|
expect(useSettingsStore.getState().ai_providers).toHaveLength(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("updates a provider", () => {
|
|
|
|
|
useSettingsStore.getState().addProvider(mockProvider);
|
|
|
|
|
useSettingsStore.getState().updateProvider(0, { ...mockProvider, model: "gpt-4o-mini" });
|
|
|
|
|
expect(useSettingsStore.getState().ai_providers[0].model).toBe("gpt-4o-mini");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("toggles theme", () => {
|
|
|
|
|
useSettingsStore.getState().setTheme("light");
|
|
|
|
|
expect(useSettingsStore.getState().theme).toBe("light");
|
|
|
|
|
});
|
2026-04-05 04:37:05 +00:00
|
|
|
|
|
|
|
|
it("does not persist API keys to localStorage", () => {
|
|
|
|
|
useSettingsStore.getState().addProvider(mockProvider);
|
|
|
|
|
const raw = localStorage.getItem("tftsr-settings");
|
|
|
|
|
expect(raw).toBeTruthy();
|
|
|
|
|
expect(raw).not.toContain("sk-test-key");
|
|
|
|
|
});
|
feat: initial implementation of TFTSR IT Triage & RCA application
Implements Phases 1-8 of the TFTSR implementation plan.
Rust backend (Tauri 2.x, src-tauri/):
- Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama
- PII detection engine: 11 regex patterns with overlap resolution
- SQLCipher AES-256 encrypted database with 10 versioned migrations
- 28 Tauri IPC commands for triage, analysis, document, and system ops
- Ollama: hardware probe, model recommendations, pull/delete with events
- RCA and blameless post-mortem Markdown document generators
- PDF export via printpdf
- Audit log: SHA-256 hash of every external data send
- Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2)
Frontend (React 18 + TypeScript + Vite, src/):
- 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings
- 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives
- 3 Zustand stores: session, settings (persisted), history
- Type-safe tauriCommands.ts matching Rust backend types exactly
- 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs)
DevOps:
- .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push
- .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload
Verified:
- cargo check: zero errors
- tsc --noEmit: zero errors
- vitest run: 13/13 unit tests passing
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 03:36:25 +00:00
|
|
|
});
|
2026-04-06 00:33:23 +00:00
|
|
|
|
|
|
|
|
describe("Settings Store — PII patterns", () => {
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
localStorage.clear();
|
|
|
|
|
useSettingsStore.setState({
|
|
|
|
|
theme: "dark",
|
|
|
|
|
ai_providers: [],
|
|
|
|
|
active_provider: undefined,
|
|
|
|
|
default_provider: "ollama",
|
|
|
|
|
default_model: "llama3.2:3b",
|
|
|
|
|
ollama_url: "http://localhost:11434",
|
|
|
|
|
pii_enabled_patterns: Object.fromEntries(DEFAULT_PII_PATTERNS.map((id) => [id, true])),
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("initializes all 8 PII patterns as enabled by default", () => {
|
|
|
|
|
const patterns = useSettingsStore.getState().pii_enabled_patterns;
|
|
|
|
|
for (const id of DEFAULT_PII_PATTERNS) {
|
|
|
|
|
expect(patterns[id]).toBe(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("setPiiPattern disables a single pattern", () => {
|
|
|
|
|
useSettingsStore.getState().setPiiPattern("email", false);
|
|
|
|
|
expect(useSettingsStore.getState().pii_enabled_patterns["email"]).toBe(false);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("setPiiPattern does not affect other patterns", () => {
|
|
|
|
|
useSettingsStore.getState().setPiiPattern("email", false);
|
|
|
|
|
for (const id of DEFAULT_PII_PATTERNS.filter((id) => id !== "email")) {
|
|
|
|
|
expect(useSettingsStore.getState().pii_enabled_patterns[id]).toBe(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("setPiiPattern re-enables a disabled pattern", () => {
|
|
|
|
|
useSettingsStore.getState().setPiiPattern("ssn", false);
|
|
|
|
|
useSettingsStore.getState().setPiiPattern("ssn", true);
|
|
|
|
|
expect(useSettingsStore.getState().pii_enabled_patterns["ssn"]).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("pii_enabled_patterns is persisted to localStorage", () => {
|
|
|
|
|
useSettingsStore.getState().setPiiPattern("api_key", false);
|
|
|
|
|
const raw = localStorage.getItem("tftsr-settings");
|
|
|
|
|
expect(raw).toBeTruthy();
|
|
|
|
|
// Zustand persist wraps state in { state: {...}, version: ... }
|
|
|
|
|
const parsed = JSON.parse(raw!);
|
|
|
|
|
const stored = parsed.state ?? parsed;
|
|
|
|
|
expect(stored.pii_enabled_patterns.api_key).toBe(false);
|
|
|
|
|
expect(stored.pii_enabled_patterns.email).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
});
|