feat: complete tRPC integration and fix platform UI issues

- Implement comprehensive tRPC setup with type-safe API
- Create tRPC routers for dashboard, admin, and auth endpoints
- Migrate frontend components to use tRPC client
- Fix platform dashboard Settings button functionality
- Add platform settings page with profile and security management
- Create OpenAI API mocking infrastructure for cost-safe testing
- Update tests to work with new tRPC architecture
- Sync database schema to fix AIBatchRequest table errors
This commit is contained in:
2025-07-11 15:37:53 +02:00
committed by Kaj Kowalski
parent f2a3d87636
commit fa7e815a3b
38 changed files with 4285 additions and 518 deletions

View File

@ -1,6 +1,9 @@
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
import { PrismaClient } from "@prisma/client";
import { processUnprocessedSessions, getAIProcessingCosts } from "../../lib/processingScheduler";
import {
processUnprocessedSessions,
getAIProcessingCosts,
} from "../../lib/processingScheduler";
vi.mock("../../lib/prisma", () => ({
prisma: {
@ -85,7 +88,9 @@ describe("Processing Scheduler", () => {
it("should handle errors gracefully", async () => {
const { prisma } = await import("../../lib/prisma");
vi.mocked(prisma.session.findMany).mockRejectedValue(new Error("Database error"));
vi.mocked(prisma.session.findMany).mockRejectedValue(
new Error("Database error")
);
await expect(processUnprocessedSessions(1)).resolves.not.toThrow();
});
@ -95,7 +100,7 @@ describe("Processing Scheduler", () => {
it("should calculate processing costs correctly", async () => {
const mockAggregation = {
_sum: {
totalCostEur: 10.50,
totalCostEur: 10.5,
promptTokens: 1000,
completionTokens: 500,
totalTokens: 1500,
@ -106,12 +111,14 @@ describe("Processing Scheduler", () => {
};
const { prisma } = await import("../../lib/prisma");
vi.mocked(prisma.aIProcessingRequest.aggregate).mockResolvedValue(mockAggregation);
vi.mocked(prisma.aIProcessingRequest.aggregate).mockResolvedValue(
mockAggregation
);
const result = await getAIProcessingCosts();
expect(result).toEqual({
totalCostEur: 10.50,
totalCostEur: 10.5,
totalRequests: 25,
totalPromptTokens: 1000,
totalCompletionTokens: 500,
@ -133,7 +140,9 @@ describe("Processing Scheduler", () => {
};
const { prisma } = await import("../../lib/prisma");
vi.mocked(prisma.aIProcessingRequest.aggregate).mockResolvedValue(mockAggregation);
vi.mocked(prisma.aIProcessingRequest.aggregate).mockResolvedValue(
mockAggregation
);
const result = await getAIProcessingCosts();
@ -146,4 +155,4 @@ describe("Processing Scheduler", () => {
});
});
});
});
});