config: role,packages,editor (5 files)

This commit is contained in:
Richard Ward
2025-12-30 14:25:40 +00:00
parent 1ddc6d9bd5
commit dfcc6bdace
5 changed files with 188 additions and 0 deletions

View File

@@ -88,6 +88,9 @@ import {
Popover,
} from '@/fakemui'
// Import Icon component from atoms
import { Icon } from '@/components/atoms/display/Icon'
import type { ComponentType, FC } from 'react'
// Type helper to cast components to generic LuaComponentProps
@@ -222,6 +225,9 @@ export const componentRegistry: Record<string, AnyComponent> = {
// Utils
Tooltip,
// Icons
Icon,
}
/**

View File

@@ -0,0 +1,51 @@
-- Icon mappings for dashboard components
-- This module provides icon names that work with fakemui icons
---@class DashboardIcons
local M = {}
---Common dashboard icon names mapped to fakemui icons
M.icons = {
-- Stats & Analytics
CHART_LINE = "ChartLine",
TREND_UP = "TrendUp",
BAR_CHART = "BarChart",
PIE_CHART = "PieChart",
ANALYTICS = "Analytics",
DASHBOARD = "Dashboard",
STATS = "Stats",
-- Status & Validation
CHECK_CIRCLE = "CheckCircle",
SHIELD_CHECK = "ShieldCheck",
WARNING = "Warning",
ERROR = "CircleX",
INFO = "Info",
-- Time & Schedule
CLOCK = "Clock",
CALENDAR = "Calendar",
SCHEDULE = "Schedule",
-- User & People
USER = "User",
USERS = "Users",
USER_CIRCLE = "UserCircle",
PEOPLE = "People",
-- Actions
ADD = "Add",
EDIT = "Edit",
DELETE = "Delete",
REFRESH = "Refresh",
SETTINGS = "Settings",
}
---Get icon name for a given dashboard element
---@param key string Icon key (e.g., "CHART_LINE")
---@return string icon_name The fakemui icon name
function M.get(key)
return M.icons[key] or "Info"
end
return M

View File

@@ -0,0 +1,28 @@
{
"roleEditor": [
{
"desc": "creates role editor with basic props",
"input": {
"role": "user"
},
"expected_type": "Card"
},
{
"desc": "creates role editor with allowed roles filter",
"input": {
"role": "admin",
"allowedRoles": ["user", "admin", "moderator"]
},
"expected_type": "Card"
},
{
"desc": "creates role editor with instance owner toggle",
"input": {
"role": "god",
"showInstanceOwner": true,
"isInstanceOwner": false
},
"expected_type": "Card"
}
]
}

View File

@@ -0,0 +1,54 @@
{
"getRoleLabel": [
{
"desc": "returns correct label for public role",
"input": "public",
"expected": "Public"
},
{
"desc": "returns correct label for user role",
"input": "user",
"expected": "User"
},
{
"desc": "returns correct label for admin role",
"input": "admin",
"expected": "Admin"
},
{
"desc": "returns correct label for god role",
"input": "god",
"expected": "God"
}
],
"isValidRole": [
{
"desc": "returns true for valid roles",
"input": "admin",
"expected": true
},
{
"desc": "returns false for invalid roles",
"input": "invalid",
"expected": false
}
],
"getAllRoles": [
{
"desc": "returns all roles in correct order",
"expected": ["public", "user", "moderator", "admin", "god", "supergod"]
}
],
"filterRoles": [
{
"desc": "returns all roles when no filter provided",
"input": null,
"expected_length": 6
},
{
"desc": "returns filtered roles when list provided",
"input": ["user", "admin"],
"expected_length": 2
}
]
}

View File

@@ -0,0 +1,49 @@
-- Role module tests
-- Uses lua_test framework with parameterized test cases
describe("Role Module", function()
local cases = load_cases("role.cases.json")
local role = require("role")
describe("getRoleLabel", function()
it_each(cases.getRoleLabel, "$desc", function(tc)
local result = role.getRoleLabel(tc.input)
expect(result).toBe(tc.expected)
end)
end)
describe("isValidRole", function()
it_each(cases.isValidRole, "$desc", function(tc)
local result = role.isValidRole(tc.input)
expect(result).toBe(tc.expected)
end)
end)
describe("getAllRoles", function()
it_each(cases.getAllRoles, "$desc", function(tc)
local result = role.getAllRoles()
expect(#result).toBe(#tc.expected)
for i, expectedRole in ipairs(tc.expected) do
expect(result[i]).toBe(expectedRole)
end
end)
end)
describe("filterRoles", function()
it_each(cases.filterRoles, "$desc", function(tc)
local result = role.filterRoles(tc.input)
expect(#result).toBe(tc.expected_length)
end)
end)
describe("getRoleInfo", function()
it("returns role info with all required fields", function()
local info = role.getRoleInfo("admin")
expect(info).toBeDefined()
expect(info.label).toBeDefined()
expect(info.blurb).toBeDefined()
expect(info.highlights).toBeDefined()
expect(#info.highlights).toBeGreaterThan(0)
end)
end)
end)