mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-02-13 15:15:45 +01:00
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:
@@ -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,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user