mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-02-13 19:15:44 +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:
@@ -1,11 +1,16 @@
|
||||
import { describe, it, expect, beforeEach, vi } from "vitest";
|
||||
import { NextRequest } from "next/server";
|
||||
import { hash } from "bcryptjs";
|
||||
|
||||
// Mock getServerSession
|
||||
const mockGetServerSession = vi.fn();
|
||||
vi.mock("next-auth", () => ({
|
||||
getServerSession: () => mockGetServerSession(),
|
||||
// Mock neonAuth from lib/auth/server
|
||||
const mockNeonAuth = vi.fn();
|
||||
vi.mock("../../lib/auth/server", () => ({
|
||||
neonAuth: () => mockNeonAuth(),
|
||||
getAuthenticatedPlatformUser: () => mockNeonAuth(),
|
||||
hasPlatformAccess: vi.fn(() => true),
|
||||
isPlatformRole: vi.fn((role: string) =>
|
||||
["PLATFORM_SUPER_ADMIN", "PLATFORM_ADMIN", "PLATFORM_SUPPORT"].includes(
|
||||
role
|
||||
)
|
||||
),
|
||||
}));
|
||||
|
||||
// Mock database
|
||||
@@ -42,7 +47,7 @@ describe("Platform API Endpoints", () => {
|
||||
|
||||
describe("Authentication Requirements", () => {
|
||||
it("should require platform authentication", async () => {
|
||||
mockGetServerSession.mockResolvedValue(null);
|
||||
mockNeonAuth.mockResolvedValue({ user: null });
|
||||
|
||||
// Test that endpoints check for authentication
|
||||
const endpoints = [
|
||||
@@ -55,26 +60,28 @@ describe("Platform API Endpoints", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("should require platform user flag", () => {
|
||||
const regularUserSession = {
|
||||
user: {
|
||||
email: "regular@user.com",
|
||||
isPlatformUser: false,
|
||||
},
|
||||
expires: new Date().toISOString(),
|
||||
it("should require platform user role", () => {
|
||||
const regularUser = {
|
||||
id: "1",
|
||||
email: "regular@user.com",
|
||||
role: "USER",
|
||||
companyId: "company-123",
|
||||
};
|
||||
|
||||
const platformUserSession = {
|
||||
user: {
|
||||
email: "admin@notso.ai",
|
||||
isPlatformUser: true,
|
||||
platformRole: "SUPER_ADMIN",
|
||||
},
|
||||
expires: new Date().toISOString(),
|
||||
const platformUser = {
|
||||
id: "2",
|
||||
email: "admin@notso.ai",
|
||||
role: "PLATFORM_SUPER_ADMIN",
|
||||
companyId: null,
|
||||
};
|
||||
|
||||
expect(regularUserSession.user.isPlatformUser).toBe(false);
|
||||
expect(platformUserSession.user.isPlatformUser).toBe(true);
|
||||
const isPlatformRole = (role: string) =>
|
||||
["PLATFORM_SUPER_ADMIN", "PLATFORM_ADMIN", "PLATFORM_SUPPORT"].includes(
|
||||
role
|
||||
);
|
||||
|
||||
expect(isPlatformRole(regularUser.role)).toBe(false);
|
||||
expect(isPlatformRole(platformUser.role)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -117,11 +124,10 @@ describe("Platform API Endpoints", () => {
|
||||
expect(result[0]._count).toHaveProperty("users");
|
||||
});
|
||||
|
||||
it("should create company with admin user", async () => {
|
||||
it("should create company with admin user placeholder", async () => {
|
||||
const newCompany = {
|
||||
id: "123",
|
||||
name: "New Company",
|
||||
email: "admin@newcompany.com",
|
||||
status: "ACTIVE",
|
||||
maxUsers: 10,
|
||||
createdAt: new Date(),
|
||||
@@ -132,13 +138,12 @@ describe("Platform API Endpoints", () => {
|
||||
id: "456",
|
||||
email: "admin@newcompany.com",
|
||||
name: "Admin User",
|
||||
hashedPassword: "hashed_password",
|
||||
role: "ADMIN",
|
||||
companyId: "123",
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
invitedBy: null,
|
||||
invitedAt: null,
|
||||
invitedBy: "platform@notso.ai",
|
||||
invitedAt: new Date(),
|
||||
};
|
||||
|
||||
mockDb.company.create.mockResolvedValue({
|
||||
@@ -149,13 +154,13 @@ describe("Platform API Endpoints", () => {
|
||||
const result = await mockDb.company.create({
|
||||
data: {
|
||||
name: "New Company",
|
||||
email: "admin@newcompany.com",
|
||||
users: {
|
||||
create: {
|
||||
email: "admin@newcompany.com",
|
||||
name: "Admin User",
|
||||
hashedPassword: "hashed_password",
|
||||
role: "ADMIN",
|
||||
invitedBy: "platform@notso.ai",
|
||||
invitedAt: new Date(),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user