Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

test(model-lib): cover cardTitleFromPrompt against real forge prompts

nirholas3cb3cc43052b
diff --git a/tests/model-lib.test.js b/tests/model-lib.test.js
index 84979d707..b604dfa8e 100644
--- a/tests/model-lib.test.js
+++ b/tests/model-lib.test.js
@@ -7,6 +7,7 @@ import { describe, it, expect } from 'vitest';
import {
modelIdFromPath,
titleFromPrompt,
+ cardTitleFromPrompt,
formatCount,
formatBytes,
timeAgo,
@@ -47,6 +48,38 @@ describe('titleFromPrompt', () => {
});
});
+// Card labels come from the same prompt column, but a card is two lines wide and
+// the prompts that reach it are often generated specs, so the heading rules are
+// far too generous there. These cases are the real shapes seen in the AR Studio
+// tray and the gallery's forge row.
+describe('cardTitleFromPrompt', () => {
+ it('keeps a short prompt intact', () => {
+ expect(cardTitleFromPrompt('trench car')).toBe('Trench car');
+ });
+ it('drops the leading list marker a generated spec opens with', () => {
+ expect(cardTitleFromPrompt('1. Geometry and pose: torso, volumetric')).toBe('Geometry and pose');
+ });
+ it('cuts at the numbered section that follows a real subject', () => {
+ expect(cardTitleFromPrompt('sleeping mouse 1. Geometry: torso')).toBe('Sleeping mouse');
+ });
+ it('keeps decimals and thousands separators whole', () => {
+ expect(cardTitleFromPrompt('a 3.5 inch floppy disk, retro')).toBe('A 3.5 inch floppy disk');
+ expect(cardTitleFromPrompt('a tower of 1,200 bricks')).toBe('A tower of 1,200 bricks');
+ });
+ it('caps on a word boundary with an ellipsis', () => {
+ const t = cardTitleFromPrompt('a '.repeat(60).trim());
+ expect(t.length).toBeLessThanOrEqual(50);
+ expect(t.endsWith('…')).toBe(true);
+ });
+ it('works on non-latin prompts', () => {
+ expect(cardTitleFromPrompt('1. Геометрия и поза: Туловище')).toBe('Геометрия и поза');
+ });
+ it('falls back for empty prompts', () => {
+ expect(cardTitleFromPrompt('')).toBe('Untitled model');
+ expect(cardTitleFromPrompt(null)).toBe('Untitled model');
+ });
+});
+
describe('formatCount', () => {
it('keeps small numbers verbatim and compacts thousands/millions', () => {
expect(formatCount(0)).toBe('0');