feat: add validation tests and cases for ui_header and ui_home packages

This commit is contained in:
2025-12-30 01:48:48 +00:00
parent 2d65639c13
commit 2985826a7b
6 changed files with 154 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
{
"component_fields": [
{ "field": "id", "type": "string", "desc": "unique identifier" },
{ "field": "type", "type": "string", "desc": "component type" }
]
}

View File

@@ -0,0 +1,21 @@
-- Component validation tests for ui_header package
-- Uses lua_test framework
describe("App Header Components", function()
local components = load_cases("components.json")
it("should be a valid array", function()
expect(components).toBeType("table")
end)
it("should have valid component structure if components exist", function()
if #components > 0 then
for _, component in ipairs(components) do
expect(component.id).toBeTruthy()
expect(component.type).toBeTruthy()
expect(component.id).toBeType("string")
expect(component.type).toBeType("string")
end
end
end)
end)

View File

@@ -0,0 +1,24 @@
{
"package_id_validation": [
{ "pattern": "^[a-z_]+$", "desc": "lowercase with underscores only" }
],
"version_validation": [
{ "pattern": "^%d+%.%d+%.%d+$", "desc": "semantic version format" }
],
"required_fields": [
{ "field": "packageId", "desc": "package identifier" },
{ "field": "name", "desc": "display name" },
{ "field": "version", "desc": "version string" },
{ "field": "description", "desc": "package description" }
],
"required_dependencies": [
{ "dep": "ui_permissions", "desc": "permission handling" }
],
"export_types": [
{ "type": "components", "desc": "component exports" },
{ "type": "scripts", "desc": "lua script exports" }
],
"expected_components": [
{ "name": "AppHeader", "desc": "application header" }
]
}

View File

@@ -0,0 +1,38 @@
-- Metadata validation tests for ui_header package
-- Uses lua_test framework
describe("App Header Package Metadata", function()
local metadata = load_cases("metadata.json")
it("should have valid package structure", function()
expect(metadata.packageId).toBe("ui_header")
expect(metadata.name).toBe("App Header")
expect(metadata.version).toBeTruthy()
expect(metadata.description).toBeTruthy()
end)
it("should have correct package ID format", function()
expect(metadata.packageId).toMatch("^[a-z_]+$")
end)
it("should have semantic version", function()
expect(metadata.version).toMatch("^%d+%.%d+%.%d+$")
end)
it("should have exports defined", function()
expect(metadata.exports).toBeTruthy()
expect(metadata.exports.components).toBeType("table")
end)
it("should have dependencies array", function()
expect(metadata.dependencies).toBeType("table")
end)
it("should depend on ui_permissions", function()
local found = false
for _, dep in ipairs(metadata.dependencies) do
if dep == "ui_permissions" then found = true break end
end
expect(found).toBe(true)
end)
end)

View File

@@ -0,0 +1,24 @@
{
"package_id_validation": [
{ "pattern": "^[a-z_]+$", "desc": "lowercase with underscores only" }
],
"version_validation": [
{ "pattern": "^%d+%.%d+%.%d+$", "desc": "semantic version format" }
],
"required_fields": [
{ "field": "packageId", "desc": "package identifier" },
{ "field": "name", "desc": "display name" },
{ "field": "version", "desc": "version string" },
{ "field": "description", "desc": "package description" }
],
"required_dependencies": [
{ "dep": "ui_permissions", "desc": "permission handling" }
],
"export_types": [
{ "type": "pages", "desc": "page exports" },
{ "type": "scripts", "desc": "lua script exports" }
],
"expected_pages": [
{ "name": "level1", "desc": "home page" }
]
}

View File

@@ -0,0 +1,41 @@
-- Metadata validation tests for ui_home package
-- Uses lua_test framework
describe("Home Page Package Metadata", function()
local metadata = load_cases("metadata.json")
it("should have valid package structure", function()
expect(metadata.packageId).toBe("ui_home")
expect(metadata.name).toBe("Home Page")
expect(metadata.version).toBeTruthy()
expect(metadata.description).toBeTruthy()
end)
it("should have correct package ID format", function()
expect(metadata.packageId).toMatch("^[a-z_]+$")
end)
it("should have semantic version", function()
expect(metadata.version).toMatch("^%d+%.%d+%.%d+$")
end)
it("should have exports defined", function()
expect(metadata.exports).toBeTruthy()
end)
it("should have dependencies array", function()
expect(metadata.dependencies).toBeType("table")
end)
it("should depend on ui_permissions", function()
local found = false
for _, dep in ipairs(metadata.dependencies) do
if dep == "ui_permissions" then found = true break end
end
expect(found).toBe(true)
end)
it("should export pages", function()
expect(metadata.exports.pages).toBeType("table")
end)
end)