name refactor

This commit is contained in:
2026-05-25 23:23:27 -04:00
parent 8ac2ce5273
commit aacb800f4a
98 changed files with 605 additions and 464 deletions

View File

@@ -6,38 +6,119 @@ import type { JSX } from "solid-js";
vi.mock("~/lib/api", () => ({
api: {
correlation: {
getStats: { query: vi.fn().mockResolvedValue({ threatScore: 25, totalAlerts: 5, bySeverity: {}, bySource: {}, activeGroups: 2, resolvedCount: 3, falsePositiveCount: 1, threatBreakdown: [] }) },
getAlerts: { query: vi.fn().mockResolvedValue({ items: [
{ id: "1", title: "New credential leak detected", severity: "HIGH", source: "DARKWATCH", createdAt: new Date().toISOString() },
{ id: "2", title: "Suspicious call", severity: "WARNING", source: "SPAMSHIELD", createdAt: new Date().toISOString() },
], total: 2, page: 1, limit: 10, totalPages: 1 }) },
getStats: {
query: vi
.fn()
.mockResolvedValue({
threatScore: 25,
totalAlerts: 5,
bySeverity: {},
bySource: {},
activeGroups: 2,
resolvedCount: 3,
falsePositiveCount: 1,
threatBreakdown: [],
}),
},
getAlerts: {
query: vi.fn().mockResolvedValue({
items: [
{
id: "1",
title: "New credential leak detected",
severity: "HIGH",
source: "DARKWATCH",
createdAt: new Date().toISOString(),
},
{
id: "2",
title: "Suspicious call",
severity: "WARNING",
source: "SPAMSHIELD",
createdAt: new Date().toISOString(),
},
],
total: 2,
page: 1,
limit: 10,
totalPages: 1,
}),
},
resolveAlert: { mutate: vi.fn().mockResolvedValue({}) },
},
darkwatch: {
getExposures: { query: vi.fn().mockResolvedValue({ items: [], total: 0, page: 1, limit: 1, totalPages: 0 }) },
getExposures: {
query: vi
.fn()
.mockResolvedValue({
items: [],
total: 0,
page: 1,
limit: 1,
totalPages: 0,
}),
},
runScan: { mutate: vi.fn().mockResolvedValue({}) },
},
voiceprint: {
getEnrollments: { query: vi.fn().mockResolvedValue([]) },
getAnalyses: { query: vi.fn().mockResolvedValue({ items: [], total: 0, page: 1, limit: 10, totalPages: 0 }) },
getAnalyses: {
query: vi
.fn()
.mockResolvedValue({
items: [],
total: 0,
page: 1,
limit: 10,
totalPages: 0,
}),
},
},
spamshield: {
getStats: { query: vi.fn().mockResolvedValue({ period: "week", totalDetections: 10, spamCount: 8, notSpamCount: 2, accuracy: 80, activeRules: 3 }) },
getRules: { query: vi.fn().mockResolvedValue({ userRules: [], globalRules: [] }) },
getStats: {
query: vi
.fn()
.mockResolvedValue({
period: "week",
totalDetections: 10,
spamCount: 8,
notSpamCount: 2,
accuracy: 80,
activeRules: 3,
}),
},
getRules: {
query: vi.fn().mockResolvedValue({ userRules: [], globalRules: [] }),
},
},
hometitle: {
getProperties: { query: vi.fn().mockResolvedValue([]) },
getAlerts: { query: vi.fn().mockResolvedValue([]) },
},
removebrokers: {
getStats: { query: vi.fn().mockResolvedValue({ total: 0, byStatus: {}, totalListings: 0, listingsRemoved: 0, completionRate: 0 }) },
getStats: {
query: vi
.fn()
.mockResolvedValue({
total: 0,
byStatus: {},
totalListings: 0,
listingsRemoved: 0,
completionRate: 0,
}),
},
getBrokerRegistry: { query: vi.fn().mockResolvedValue([]) },
},
},
}));
vi.mock("@solidjs/router", () => ({
A: (props: { href?: string; children?: JSX.Element; class?: string; onClick?: () => void }) => (
A: (props: {
href?: string;
children?: JSX.Element;
class?: string;
onClick?: () => void;
}) => (
<a href={props.href || "#"} class={props.class} onClick={props.onClick}>
{props.children}
</a>
@@ -49,7 +130,7 @@ vi.mock("@solidjs/router", () => ({
vi.mock("~/hooks", () => ({
useAuth: () => ({
user: () => ({ name: "Test User", email: "test@shieldai.app" }),
user: () => ({ name: "Test User", email: "test@kordant.ai" }),
isAuthenticated: () => true,
isLoading: () => false,
logout: vi.fn(),
@@ -62,11 +143,41 @@ vi.mock("~/hooks", () => ({
}),
useNotifications: () => ({
alerts: () => [
{ id: "1", title: "New credential leak detected", description: "Your email was found in a data breach", severity: "HIGH", createdAt: "5m ago" },
{ id: "2", title: "VoicePrint scan completed", description: "No deepfake voice activity detected", severity: "INFO", createdAt: "1h ago" },
{ id: "3", title: "RemoveBroker opt-out confirmed", description: "Your data has been removed from Whitepages", severity: "INFO", createdAt: "3h ago" },
{ id: "4", title: "Suspicious call blocked", description: "SpamShield blocked a call", severity: "WARNING", createdAt: "6h ago" },
{ id: "5", title: "HomeTitle alert", description: "A document was filed", severity: "CRITICAL", createdAt: "1d ago" },
{
id: "1",
title: "New credential leak detected",
description: "Your email was found in a data breach",
severity: "HIGH",
createdAt: "5m ago",
},
{
id: "2",
title: "VoicePrint scan completed",
description: "No deepfake voice activity detected",
severity: "INFO",
createdAt: "1h ago",
},
{
id: "3",
title: "RemoveBroker opt-out confirmed",
description: "Your data has been removed from Whitepages",
severity: "INFO",
createdAt: "3h ago",
},
{
id: "4",
title: "Suspicious call blocked",
description: "SpamShield blocked a call",
severity: "WARNING",
createdAt: "6h ago",
},
{
id: "5",
title: "HomeTitle alert",
description: "A document was filed",
severity: "CRITICAL",
createdAt: "1d ago",
},
],
unreadCount: () => 5,
markRead: vi.fn(),
@@ -124,7 +235,9 @@ describe("BlogPage (listing)", () => {
it("renders post titles and excerpts", () => {
mount(() => <BlogPage />);
expect(document.body.textContent).toContain("AI Scam Trends to Watch in 2026");
expect(document.body.textContent).toContain(
"AI Scam Trends to Watch in 2026",
);
expect(document.body.textContent).toContain("Sarah Chen");
expect(document.body.textContent).toContain("Mike Reynolds");
});
@@ -133,7 +246,9 @@ describe("BlogPage (listing)", () => {
describe("BlogPostPage ([slug])", () => {
it("renders post content for valid slug", () => {
mount(() => <BlogPostPage />);
expect(document.body.textContent).toContain("AI Scam Trends to Watch in 2026");
expect(document.body.textContent).toContain(
"AI Scam Trends to Watch in 2026",
);
expect(document.body.textContent).toContain("Sarah Chen");
expect(document.body.textContent).toContain("Security Researcher");
expect(document.body.textContent).toContain("May 15, 2026");
@@ -150,7 +265,9 @@ describe("BlogPostPage ([slug])", () => {
it("renders social share buttons", () => {
mount(() => <BlogPostPage />);
const shareBtns = document.querySelectorAll("button[aria-label]");
const shareLabels = Array.from(shareBtns).map(b => b.getAttribute("aria-label"));
const shareLabels = Array.from(shareBtns).map((b) =>
b.getAttribute("aria-label"),
);
expect(shareLabels).toContain("Share on Twitter");
expect(shareLabels).toContain("Share on LinkedIn");
expect(shareLabels).toContain("Copy link");
@@ -192,14 +309,18 @@ describe("AdsPage", () => {
it("marks Plus plan as Most Popular", () => {
mount(() => <AdsPage />);
const badges = document.body.querySelectorAll("span");
const popularBadge = Array.from(badges).find(b => b.textContent === "Most Popular");
const popularBadge = Array.from(badges).find(
(b) => b.textContent === "Most Popular",
);
expect(popularBadge).toBeTruthy();
});
it("renders FAQ section with toggle functionality", () => {
mount(() => <AdsPage />);
expect(document.body.textContent).toContain("Frequently Asked Questions");
expect(document.body.textContent).toContain("How does Kordant detect voice clones?");
expect(document.body.textContent).toContain(
"How does Kordant detect voice clones?",
);
expect(document.body.textContent).toContain("Is my data encrypted?");
});
@@ -224,7 +345,9 @@ describe("AdsPage", () => {
it("renders CTA section with Get Started Free button", () => {
mount(() => <AdsPage />);
expect(document.body.textContent).toContain("Ready to protect your identity?");
expect(document.body.textContent).toContain(
"Ready to protect your identity?",
);
expect(document.body.textContent).toContain("Get Started Free");
});
});
@@ -276,14 +399,26 @@ describe("StatCard", () => {
it("renders up trend indicator", () => {
mount(() => (
<StatCard label="Up Trend" value="10" trend="up" trendLabel="+5%" icon={() => <svg />} />
<StatCard
label="Up Trend"
value="10"
trend="up"
trendLabel="+5%"
icon={() => <svg />}
/>
));
expect(document.body.textContent).toContain("+5%");
});
it("renders down trend indicator", () => {
mount(() => (
<StatCard label="Down Trend" value="10" trend="down" trendLabel="-3%" icon={() => <svg />} />
<StatCard
label="Down Trend"
value="10"
trend="down"
trendLabel="-3%"
icon={() => <svg />}
/>
));
expect(document.body.textContent).toContain("-3%");
});
@@ -292,7 +427,13 @@ describe("StatCard", () => {
describe("ActivityFeed", () => {
it("renders activities", () => {
const activities = [
{ id: "1", title: "Test Alert", description: "Test description", timestamp: "5m ago", type: "alert" as const },
{
id: "1",
title: "Test Alert",
description: "Test description",
timestamp: "5m ago",
type: "alert" as const,
},
];
mount(() => <ActivityFeed activities={activities} />);
expect(document.body.textContent).toContain("Recent Activity");