fix: resolve Prettier markdown code block parsing errors

- Fix syntax errors in skills markdown files (.github/skills, .opencode/skills)
- Change typescript to tsx for code blocks with JSX
- Replace ellipsis (...) in array examples with valid syntax
- Separate CSS from TypeScript into distinct code blocks
- Convert JavaScript object examples to valid JSON in docs
- Fix enum definitions with proper comma separation
This commit is contained in:
2026-01-20 21:09:29 +01:00
parent 7932fe7386
commit cd05fc8648
177 changed files with 5042 additions and 5541 deletions

View File

@@ -7,16 +7,21 @@ import { axe, toHaveNoViolations } from "jest-axe";
import { ThemeProvider } from "@/components/theme-provider";
import UserManagementPage from "@/app/dashboard/users/page";
import SessionViewPage from "@/app/dashboard/sessions/[id]/page";
import { useSession } from "next-auth/react";
import { useParams } from "next/navigation";
// Extend Jest matchers
expect.extend(toHaveNoViolations);
// Mock auth client
const mockUseSession = vi.fn();
vi.mock("@/lib/auth/client", () => ({
authClient: {
useSession: () => mockUseSession(),
},
}));
// Mock dependencies
vi.mock("next-auth/react");
vi.mock("next/navigation");
const mockUseSession = vi.mocked(useSession);
const mockUseParams = vi.mocked(useParams);
// Mock fetch
@@ -39,8 +44,8 @@ describe("Accessibility Tests", () => {
describe("User Management Page Accessibility", () => {
beforeEach(() => {
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
(global.fetch as any).mockResolvedValue({
@@ -183,8 +188,8 @@ describe("Accessibility Tests", () => {
describe("Basic Accessibility Compliance", () => {
it("should have basic accessibility features", async () => {
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
(global.fetch as any).mockResolvedValue({
@@ -214,8 +219,8 @@ describe("Accessibility Tests", () => {
describe("Interactive Elements", () => {
it("should have focusable interactive elements", async () => {
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
(global.fetch as any).mockResolvedValue({
@@ -246,8 +251,8 @@ describe("Accessibility Tests", () => {
describe("Dark Mode Accessibility", () => {
beforeEach(() => {
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
(global.fetch as any).mockResolvedValue({

View File

@@ -189,9 +189,8 @@ describe("Environment Management", () => {
process.env.SESSION_PROCESSING_CONCURRENCY = "8";
vi.resetModules();
const { getSchedulerConfig: freshGetSchedulerConfig } = await import(
"../../lib/env"
);
const { getSchedulerConfig: freshGetSchedulerConfig } =
await import("../../lib/env");
const config = freshGetSchedulerConfig();
@@ -210,9 +209,8 @@ describe("Environment Management", () => {
delete process.env.IMPORT_PROCESSING_INTERVAL;
vi.resetModules();
const { getSchedulerConfig: freshGetSchedulerConfig } = await import(
"../../lib/env"
);
const { getSchedulerConfig: freshGetSchedulerConfig } =
await import("../../lib/env");
const config = freshGetSchedulerConfig();

View File

@@ -3,16 +3,21 @@
*/
import { describe, it, expect, vi, beforeEach } from "vitest";
import { render, screen, fireEvent } from "@testing-library/react";
import { useSession } from "next-auth/react";
import { useParams } from "next/navigation";
import UserManagementPage from "@/app/dashboard/users/page";
import SessionViewPage from "@/app/dashboard/sessions/[id]/page";
import ModernDonutChart from "@/components/charts/donut-chart";
// Mock auth client
const mockUseSession = vi.fn();
vi.mock("@/lib/auth/client", () => ({
authClient: {
useSession: () => mockUseSession(),
},
}));
// Mock dependencies
vi.mock("next-auth/react");
vi.mock("next/navigation");
const mockUseSession = vi.mocked(useSession);
const mockUseParams = vi.mocked(useParams);
// Mock fetch
@@ -22,8 +27,8 @@ describe("Keyboard Navigation Tests", () => {
describe("User Management Page Keyboard Navigation", () => {
beforeEach(() => {
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
(global.fetch as any).mockResolvedValue({
@@ -189,8 +194,8 @@ describe("Keyboard Navigation Tests", () => {
describe("Session Details Page Keyboard Navigation", () => {
beforeEach(() => {
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
mockUseParams.mockReturnValue({
@@ -346,8 +351,8 @@ describe("Keyboard Navigation Tests", () => {
describe("Focus Management", () => {
beforeEach(() => {
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
(global.fetch as any).mockResolvedValue({
@@ -427,8 +432,8 @@ describe("Keyboard Navigation Tests", () => {
describe("Screen Reader Support", () => {
beforeEach(() => {
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
(global.fetch as any).mockResolvedValue({
@@ -456,7 +461,7 @@ describe("Keyboard Navigation Tests", () => {
// Test loading state announcement
mockUseSession.mockReturnValue({
data: null,
status: "loading",
isPending: true,
});
render(<UserManagementPage />);
@@ -507,8 +512,8 @@ describe("Keyboard Navigation Tests", () => {
});
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
(global.fetch as any).mockResolvedValue({

View File

@@ -1,9 +1,13 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
// Mock modules before imports
vi.mock("next-auth/react", () => ({
useSession: vi.fn(),
SessionProvider: ({ children }: { children: React.ReactNode }) => children,
// Mock auth client
vi.mock("../../lib/auth/client", () => ({
authClient: {
useSession: vi.fn(() => ({
data: { session: null, user: null },
isPending: false,
})),
},
}));
vi.mock("next/navigation", () => ({
@@ -22,30 +26,37 @@ describe("Platform Dashboard", () => {
describe("Authentication", () => {
it("should require platform user authentication", () => {
// Test that the dashboard checks for platform user authentication
const mockSession = {
user: {
email: "admin@notso.ai",
isPlatformUser: true,
platformRole: "SUPER_ADMIN",
},
expires: new Date().toISOString(),
// Test that the dashboard checks for platform user role
const platformUser = {
id: "1",
email: "admin@notso.ai",
role: "PLATFORM_SUPER_ADMIN",
companyId: null,
};
expect(mockSession.user.isPlatformUser).toBe(true);
expect(mockSession.user.platformRole).toBeTruthy();
const isPlatformRole = (role: string) =>
["PLATFORM_SUPER_ADMIN", "PLATFORM_ADMIN", "PLATFORM_SUPPORT"].includes(
role
);
expect(isPlatformRole(platformUser.role)).toBe(true);
expect(platformUser.companyId).toBeNull();
});
it("should not allow regular users", () => {
const mockSession = {
user: {
email: "regular@user.com",
isPlatformUser: false,
},
expires: new Date().toISOString(),
const regularUser = {
id: "2",
email: "regular@user.com",
role: "USER",
companyId: "company-123",
};
expect(mockSession.user.isPlatformUser).toBe(false);
const isPlatformRole = (role: string) =>
["PLATFORM_SUPER_ADMIN", "PLATFORM_ADMIN", "PLATFORM_SUPPORT"].includes(
role
);
expect(isPlatformRole(regularUser.role)).toBe(false);
});
});
@@ -93,20 +104,21 @@ describe("Platform Dashboard", () => {
describe("Platform Roles", () => {
it("should support all platform roles", () => {
const roles = [
{ role: "SUPER_ADMIN", canEdit: true },
{ role: "ADMIN", canEdit: true },
{ role: "SUPPORT", canEdit: false },
{ role: "PLATFORM_SUPER_ADMIN", canEdit: true },
{ role: "PLATFORM_ADMIN", canEdit: true },
{ role: "PLATFORM_SUPPORT", canEdit: false },
];
roles.forEach(({ role, canEdit }) => {
const user = {
id: "1",
email: `${role.toLowerCase()}@notso.ai`,
isPlatformUser: true,
platformRole: role,
role: role,
companyId: null,
};
expect(user.platformRole).toBe(role);
if (role === "SUPER_ADMIN" || role === "ADMIN") {
expect(user.role).toBe(role);
if (role === "PLATFORM_SUPER_ADMIN" || role === "PLATFORM_ADMIN") {
expect(canEdit).toBe(true);
} else {
expect(canEdit).toBe(false);

View File

@@ -3,12 +3,15 @@
*/
import { describe, it, expect, vi, beforeEach } from "vitest";
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
import { useSession } from "next-auth/react";
import UserManagementPage from "@/app/dashboard/users/page";
// Mock next-auth
vi.mock("next-auth/react");
const mockUseSession = vi.mocked(useSession);
// Mock auth client
const mockUseSession = vi.fn();
vi.mock("@/lib/auth/client", () => ({
authClient: {
useSession: () => mockUseSession(),
},
}));
// Mock fetch
const mockFetch = vi.fn();
@@ -33,8 +36,13 @@ describe("UserManagementPage", () => {
describe("Access Control", () => {
it("should deny access for non-admin users", async () => {
mockUseSession.mockReturnValue({
data: { user: { role: "USER" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "user@example.com" } },
isPending: false,
});
// Mock API to return user role
mockFetch.mockResolvedValueOnce({
ok: true,
json: () => Promise.resolve({ role: "USER", companyId: "123" }),
});
render(<UserManagementPage />);
@@ -47,8 +55,8 @@ describe("UserManagementPage", () => {
it("should allow access for admin users", async () => {
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
render(<UserManagementPage />);
@@ -61,7 +69,7 @@ describe("UserManagementPage", () => {
it("should show loading state while checking authentication", () => {
mockUseSession.mockReturnValue({
data: null,
status: "loading",
isPending: true,
});
render(<UserManagementPage />);
@@ -73,8 +81,8 @@ describe("UserManagementPage", () => {
describe("User List Display", () => {
beforeEach(() => {
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
});
@@ -128,8 +136,8 @@ describe("UserManagementPage", () => {
describe("User Invitation Form", () => {
beforeEach(() => {
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
});
@@ -260,8 +268,8 @@ describe("UserManagementPage", () => {
describe("Form Validation", () => {
beforeEach(() => {
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
});
@@ -297,8 +305,8 @@ describe("UserManagementPage", () => {
describe("Accessibility", () => {
beforeEach(() => {
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
});
@@ -339,8 +347,8 @@ describe("UserManagementPage", () => {
describe("Error Handling", () => {
beforeEach(() => {
mockUseSession.mockReturnValue({
data: { user: { role: "ADMIN" } },
status: "authenticated",
data: { session: { id: "1" }, user: { email: "admin@example.com" } },
isPending: false,
});
});