feat(analytics): add daily trend and activity heatmap endpoints, and implement corresponding frontend components
- Added new API endpoints for daily trend data and activity heatmap in analyticsRoutes.ts. - Created new frontend components: ActivityChart, ControlBar, Heatmap, SummaryCards, TopicList, TrendChart, UserTable, and ViolatorTable for displaying analytics data. - Implemented loading and empty states in the new components. - Enhanced the existing moderation tests with remote fallback handling for Indonesian text normalization.
This commit is contained in:
@@ -1,4 +1,18 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("../../src/moderation/indonesianTextNormalizer.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("../../src/moderation/indonesianTextNormalizer.js")>();
|
||||
return {
|
||||
...actual,
|
||||
formatModerationTextEvidenceForPrompt: vi.fn(async (content: string) => {
|
||||
// Deterministic mock evidence — length tuned for the "tight budget" test:
|
||||
// maxTokens=300, target ~88, c3 ~108, c2 ~108, c1 ~108
|
||||
// Expectation: target+c3 fits (196), target+c3+c2 overflows (304)
|
||||
return "[text_evidence] categories=[\"offensive\",\"profanity\",\"sexual_violence\"] severity=high confidence=0.92 language=id detected=badword normalized=false metadata_v2=true context=true";
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
import {
|
||||
buildConversationContext,
|
||||
estimateTokens,
|
||||
@@ -6,6 +20,10 @@ import {
|
||||
} from "../../src/moderation/conversationContext";
|
||||
import type { MessageRecord } from "../../src/moderation/types";
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
function message(
|
||||
id: string,
|
||||
content: string,
|
||||
|
||||
Reference in New Issue
Block a user