|
1 | 1 | // @vitest-environment node |
2 | 2 | import { describe, it, expect } from 'vitest' |
| 3 | +import path from 'path' |
| 4 | +import { fileURLToPath } from 'url' |
3 | 5 | import { isDraftFile, isPrivateFile, getAliasFromFileName } from './build-catalog.js' |
| 6 | +import { buildDistributionCatalog, validateDistributionCatalog } from './distribution.js' |
| 7 | + |
| 8 | +const __filename = fileURLToPath(import.meta.url) |
| 9 | +const __dirname = path.dirname(__filename) |
| 10 | +const REPO_ROOT = path.resolve(__dirname, '../../') |
4 | 11 |
|
5 | 12 | describe('isPrivateFile', () => { |
6 | 13 | it('returns true for #-prefixed filenames', () => { |
@@ -79,3 +86,167 @@ describe('sync-to-api: listed filtering', () => { |
79 | 86 | expect(filtered).toHaveLength(2) |
80 | 87 | }) |
81 | 88 | }) |
| 89 | + |
| 90 | +describe('distribution catalog', () => { |
| 91 | + it('builds a public app catalog from listed brand warps', async () => { |
| 92 | + const catalog = await buildDistributionCatalog( |
| 93 | + REPO_ROOT, |
| 94 | + { |
| 95 | + schemaVersion: 1, |
| 96 | + source: 'github', |
| 97 | + repo: 'JoAiHQ/warps', |
| 98 | + branch: 'main', |
| 99 | + network: 'mainnet', |
| 100 | + commitSha: 'test', |
| 101 | + generatedAt: '2026-04-01T00:00:00.000Z', |
| 102 | + warps: [ |
| 103 | + { |
| 104 | + key: 'multiversx:joai-agent-create', |
| 105 | + identifier: '@multiversx:joai-agent-create', |
| 106 | + alias: 'joai-agent-create', |
| 107 | + chain: 'multiversx', |
| 108 | + hash: 'warp-hash-1', |
| 109 | + checksum: 'warp-hash-1', |
| 110 | + name: 'JoAi: Create Agent', |
| 111 | + title: { en: 'Create Agent' }, |
| 112 | + description: { en: 'Create a JoAi agent.' }, |
| 113 | + preview: null, |
| 114 | + creator: 'github:JoAiHQ/warps', |
| 115 | + privileges: [], |
| 116 | + listed: true, |
| 117 | + primaryAddress: null, |
| 118 | + primaryFunc: null, |
| 119 | + brand: { |
| 120 | + hash: 'brand-hash-1', |
| 121 | + slug: 'joai', |
| 122 | + active: true, |
| 123 | + protocol: 'brand:1.0.0', |
| 124 | + name: 'JoAi', |
| 125 | + description: { en: 'JoAi brand' }, |
| 126 | + logo: { default: 'https://example.com/logo.svg' }, |
| 127 | + urls: { web: 'https://joai.ai' }, |
| 128 | + colors: { primary: '#98FF98' }, |
| 129 | + }, |
| 130 | + warp: { |
| 131 | + actions: [{ type: 'collect' }], |
| 132 | + }, |
| 133 | + extras: null, |
| 134 | + }, |
| 135 | + { |
| 136 | + key: 'multiversx:joai-private-warp', |
| 137 | + identifier: '@multiversx:joai-private-warp', |
| 138 | + alias: 'joai-private-warp', |
| 139 | + chain: 'multiversx', |
| 140 | + hash: 'warp-hash-2', |
| 141 | + checksum: 'warp-hash-2', |
| 142 | + name: 'JoAi: Private Warp', |
| 143 | + title: { en: 'Private Warp' }, |
| 144 | + description: { en: 'Private warp' }, |
| 145 | + preview: null, |
| 146 | + creator: 'github:JoAiHQ/warps', |
| 147 | + privileges: [], |
| 148 | + listed: false, |
| 149 | + primaryAddress: null, |
| 150 | + primaryFunc: null, |
| 151 | + brand: { |
| 152 | + hash: 'brand-hash-1', |
| 153 | + slug: 'joai', |
| 154 | + active: true, |
| 155 | + protocol: 'brand:1.0.0', |
| 156 | + name: 'JoAi', |
| 157 | + description: { en: 'JoAi brand' }, |
| 158 | + logo: { default: 'https://example.com/logo.svg' }, |
| 159 | + urls: { web: 'https://joai.ai' }, |
| 160 | + colors: { primary: '#98FF98' }, |
| 161 | + }, |
| 162 | + warp: { |
| 163 | + actions: [{ type: 'contract' }], |
| 164 | + }, |
| 165 | + extras: null, |
| 166 | + }, |
| 167 | + ], |
| 168 | + }, |
| 169 | + new Map(), |
| 170 | + ) |
| 171 | + |
| 172 | + expect(catalog.apps).toHaveLength(1) |
| 173 | + expect(catalog.apps[0]).toMatchObject({ |
| 174 | + slug: 'joai', |
| 175 | + mcpUrl: 'https://cortex.joai.ai/mcp/apps/joai', |
| 176 | + providers: { |
| 177 | + claude: { enabled: true, status: 'ready' }, |
| 178 | + codex: { enabled: true, status: 'ready' }, |
| 179 | + openai: { enabled: true, status: 'runtime_ready' }, |
| 180 | + }, |
| 181 | + }) |
| 182 | + expect(catalog.apps[0].actions).toEqual([ |
| 183 | + { |
| 184 | + alias: 'joai-agent-create', |
| 185 | + identifier: '@multiversx:joai-agent-create', |
| 186 | + chain: 'multiversx', |
| 187 | + name: 'JoAi: Create Agent', |
| 188 | + title: { en: 'Create Agent' }, |
| 189 | + description: { en: 'Create a JoAi agent.' }, |
| 190 | + actionTypes: ['collect'], |
| 191 | + }, |
| 192 | + ]) |
| 193 | + expect(validateDistributionCatalog(catalog)).toEqual([]) |
| 194 | + }) |
| 195 | + |
| 196 | + it('requires screenshots only for submission-ready OpenAI apps', () => { |
| 197 | + const errors = validateDistributionCatalog({ |
| 198 | + schemaVersion: 1, |
| 199 | + source: 'github', |
| 200 | + repo: 'JoAiHQ/warps', |
| 201 | + branch: 'main', |
| 202 | + network: 'mainnet', |
| 203 | + commitSha: 'test', |
| 204 | + generatedAt: '2026-04-01T00:00:00.000Z', |
| 205 | + apps: [ |
| 206 | + { |
| 207 | + slug: 'joai', |
| 208 | + name: 'JoAi', |
| 209 | + description: { en: 'JoAi' }, |
| 210 | + logo: { default: 'https://example.com/logo.svg' }, |
| 211 | + urls: { web: 'https://joai.ai' }, |
| 212 | + hash: 'brand-hash', |
| 213 | + mcpUrl: 'https://cortex.joai.ai/mcp/apps/joai', |
| 214 | + install: { |
| 215 | + summary: 'summary', |
| 216 | + examplePrompts: ['prompt'], |
| 217 | + usageNotes: [], |
| 218 | + authPrerequisites: [], |
| 219 | + }, |
| 220 | + legal: { |
| 221 | + privacyUrl: 'https://legal.vleap.ai/policies/privacy.html', |
| 222 | + supportEmail: 'support@joai.ai', |
| 223 | + }, |
| 224 | + review: { |
| 225 | + screenshots: [], |
| 226 | + reviewerNotes: ['note'], |
| 227 | + testPrompts: ['prompt'], |
| 228 | + }, |
| 229 | + ui: { |
| 230 | + prefersBorder: true, |
| 231 | + csp: { |
| 232 | + connectDomains: [], |
| 233 | + resourceDomains: [], |
| 234 | + frameDomains: [], |
| 235 | + baseUriDomains: [], |
| 236 | + }, |
| 237 | + permissions: {}, |
| 238 | + domain: undefined, |
| 239 | + }, |
| 240 | + providers: { |
| 241 | + claude: { provider: 'claude', enabled: true, status: 'ready', notes: [] }, |
| 242 | + codex: { provider: 'codex', enabled: true, status: 'ready', notes: [] }, |
| 243 | + openai: { provider: 'openai', enabled: true, status: 'submission_ready', notes: [] }, |
| 244 | + }, |
| 245 | + actions: [], |
| 246 | + }, |
| 247 | + ], |
| 248 | + }) |
| 249 | + |
| 250 | + expect(errors).toContain('joai: openai marked submission_ready without screenshots') |
| 251 | + }) |
| 252 | +}) |
0 commit comments