evOo-local/apps/web/src/lib/onboarding-discovery.test.ts
cynarAI 6c7eed7580 Initial clean evOo-local from f00577b
Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline
(Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/*
packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
2026-09-20 17:15:16 +02:00

99 lines
2.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
computeDiscoveryItems,
countConfiguredIntegrations,
discoveryProgress,
summarizeProfileSignals,
visibleDiscoveryItems,
} from "./onboarding-discovery";
import { collectLocalProfileSignals } from "./user-profile-harvest";
describe("onboarding-discovery", () => {
it("marks profile basics found when me is loaded", () => {
const items = computeDiscoveryItems({
phase: "loading",
me: {
name: "Ingo",
email: "ingo@example.com",
needsModel: false,
defaultProvider: "openrouter",
defaultModel: "gpt-4",
computerHost: null,
},
});
const profile = items.find((item) => item.id === "profile-basics");
expect(profile?.status).toBe("found");
expect(profile?.detail).toContain("Ingo");
});
it("returns only four visible onboarding steps", () => {
const items = computeDiscoveryItems({ phase: "assembly", crewReady: true });
expect(items.map((item) => item.id)).toEqual([
"profile-basics",
"model-ready",
"connected-tools",
"specialist-crew",
]);
});
it("reports configured integration count honestly", () => {
expect(
countConfiguredIntegrations({
canConfigure: true,
needsSetup: false,
webUrl: "https://example.com",
providers: [
{ id: "slack", configured: true },
{ id: "gmail", configured: false },
],
}),
).toBe(1);
});
it("tracks assembly progress for crew and persisted profile", () => {
const signals = collectLocalProfileSignals({
name: "Robin",
email: "r@example.com",
defaultProvider: null,
defaultModel: null,
computerHost: null,
});
const items = computeDiscoveryItems({
phase: "assembly",
profileSignals: signals,
profilePersisted: true,
crewReady: true,
me: {
name: "Robin",
email: "r@example.com",
needsModel: false,
defaultProvider: null,
defaultModel: null,
computerHost: null,
},
});
expect(items.find((item) => item.id === "specialist-crew")?.status).toBe("found");
const progress = discoveryProgress(items);
expect(progress.done).toBeGreaterThanOrEqual(3);
});
it("summarizes profile signals without inventing data", () => {
const summary = summarizeProfileSignals(
collectLocalProfileSignals({
name: "Ingo",
email: "a@b.c",
defaultProvider: null,
defaultModel: null,
computerHost: null,
}),
);
expect(summary).toContain("Ingo");
expect(summary.length).toBeGreaterThan(0);
});
it("visibleDiscoveryItems passes through the four onboarding steps", () => {
const items = computeDiscoveryItems({ phase: "loading" });
expect(visibleDiscoveryItems(items)).toHaveLength(4);
});
});