- Add JWT middleware unit tests (8 tests covering all auth edge cases) - Add WebSocket hub tests (5 tests for client lifecycle and broadcast) - Add full HTTP integration tests (12 tests through real Chi router with DB) - Add frontend component tests for login, issues, and issue detail pages - Add auth context unit tests (9 tests for login/logout/name resolution) - Add Playwright E2E tests for auth, issues, comments, and navigation - Configure Vitest with jsdom, React plugin, and path aliases Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
91 lines
2.2 KiB
TypeScript
91 lines
2.2 KiB
TypeScript
import React from "react";
|
|
import { render, type RenderOptions } from "@testing-library/react";
|
|
import type { User, Workspace, MemberWithUser, Agent } from "@multica/types";
|
|
|
|
// Mock user
|
|
export const mockUser: User = {
|
|
id: "user-1",
|
|
name: "Test User",
|
|
email: "test@multica.ai",
|
|
avatar_url: null,
|
|
created_at: "2026-01-01T00:00:00Z",
|
|
updated_at: "2026-01-01T00:00:00Z",
|
|
};
|
|
|
|
// Mock workspace
|
|
export const mockWorkspace: Workspace = {
|
|
id: "ws-1",
|
|
name: "Test Workspace",
|
|
slug: "test-ws",
|
|
description: "A test workspace",
|
|
settings: {},
|
|
created_at: "2026-01-01T00:00:00Z",
|
|
updated_at: "2026-01-01T00:00:00Z",
|
|
};
|
|
|
|
// Mock members
|
|
export const mockMembers: MemberWithUser[] = [
|
|
{
|
|
id: "member-1",
|
|
workspace_id: "ws-1",
|
|
user_id: "user-1",
|
|
role: "owner",
|
|
created_at: "2026-01-01T00:00:00Z",
|
|
name: "Test User",
|
|
email: "test@multica.ai",
|
|
avatar_url: null,
|
|
},
|
|
];
|
|
|
|
// Mock agents
|
|
export const mockAgents: Agent[] = [
|
|
{
|
|
id: "agent-1",
|
|
workspace_id: "ws-1",
|
|
name: "Claude Agent",
|
|
status: "idle",
|
|
runtime_mode: "cloud",
|
|
visibility: "workspace",
|
|
max_concurrent_tasks: 3,
|
|
description: "A test agent",
|
|
system_prompt: null,
|
|
config: {},
|
|
created_at: "2026-01-01T00:00:00Z",
|
|
updated_at: "2026-01-01T00:00:00Z",
|
|
},
|
|
];
|
|
|
|
// Mock auth context value
|
|
export const mockAuthValue = {
|
|
user: mockUser,
|
|
workspace: mockWorkspace,
|
|
members: mockMembers,
|
|
agents: mockAgents,
|
|
isLoading: false,
|
|
login: vi.fn(),
|
|
logout: vi.fn(),
|
|
refreshMembers: vi.fn(),
|
|
refreshAgents: vi.fn(),
|
|
getMemberName: (userId: string) => {
|
|
const m = mockMembers.find((m) => m.user_id === userId);
|
|
return m?.name ?? "Unknown";
|
|
},
|
|
getAgentName: (agentId: string) => {
|
|
const a = mockAgents.find((a) => a.id === agentId);
|
|
return a?.name ?? "Unknown Agent";
|
|
},
|
|
getActorName: (type: string, id: string) => {
|
|
if (type === "member") {
|
|
const m = mockMembers.find((m) => m.user_id === id);
|
|
return m?.name ?? "Unknown";
|
|
}
|
|
if (type === "agent") {
|
|
const a = mockAgents.find((a) => a.id === id);
|
|
return a?.name ?? "Unknown Agent";
|
|
}
|
|
return "System";
|
|
},
|
|
getActorInitials: (type: string, id: string) => {
|
|
return "TU";
|
|
},
|
|
};
|