Files
open-design/apps/web/tests/runtime/brand-enrichment.test.ts
f1a0b60c6c chore: unify product name display to OpenDesign repo-wide (#6998)
* chore: unify product name display to OpenDesign repo-wide

Rename the user-facing product name from "Open Design" to "OpenDesign"
across documentation, web/desktop UI strings, i18n locales, prompts,
plugin/skill/design-system content, changelogs, and specs, matching the
landing-page rename already in flight.

Deliberately excluded so installed-app identity stays untouched:
- packages/release PRODUCT_NAME and everything derived from it
  (app bundle names, installer/registry identity, updater feeds)
- tools/pack, tools/release, apps/packaged, landing page (PR #6983)
- mocks/ recorded traces and LICENSE
- test fixtures and comments that encode real on-disk install paths
  (Open Design.app, Program Files\Open Design, AppData paths)

Validated with pnpm guard, pnpm typecheck, and targeted web/desktop/host
test runs over the renamed strings.

* fix(web): keep two-letter author monogram for CamelCase brand names

authorInitials split words on whitespace only, so the renamed single-token
author name "OpenDesign" produced a one-letter monogram. Treat lower-to-upper
CamelCase boundaries as word breaks so the avatar fallback stays "OD".

* fix(release): restore spaced Windows source artifact names in win.ps1

tools/pack still derives builder outputs from the unchanged PRODUCT_NAME
("Open Design"), so the asset script must look for the spaced filenames.
Matches the mac/mac-intel/linux asset scripts, which were already kept on
the original names.

---------

Co-authored-by: Joey <236967869+joeylee12629-star@users.noreply.github.com>
2026-08-18 07:09:45 +00:00

89 lines
3.3 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import {
buildBrandEnrichmentPrompt,
installedBrandEnrichmentSkillIds,
isProgrammaticBrandExtractionProject,
} from '../../src/runtime/brand-enrichment';
describe('brand enrichment runtime helpers', () => {
it('keeps the default skill bundle hidden and filters it to installed skills', () => {
expect(installedBrandEnrichmentSkillIds([
{ id: 'color-expert' },
{ id: 'unrelated' },
{ id: 'design-md' },
{ id: 'plan-design-review' },
{ id: 'brand-guidelines' },
])).toEqual(['design-md', 'plan-design-review', 'color-expert', 'brand-guidelines']);
});
it('builds a complete fallback prompt when no seeded prompt is available', () => {
const prompt = buildBrandEnrichmentPrompt('');
expect(prompt).toContain('AI optimize this OpenDesign design system in place.');
expect(prompt).toContain('Do not create a duplicate system.');
expect(prompt).toContain('10-20');
expect(prompt).toContain('anti-bot verification page');
expect(prompt).toContain('frequency-rank colors and fonts');
expect(prompt).toContain('design best practices');
});
it('appends the quality bar to an existing extraction prompt without replacing context', () => {
const prompt = buildBrandEnrichmentPrompt('Existing source URL: https://example.com');
expect(prompt).toContain('Existing source URL: https://example.com');
expect(prompt).toContain('AI Optimize quality bar:');
expect(prompt).toContain('DESIGN.md, README.md, SKILL.md');
expect(prompt).toContain('content hierarchy, grid and density');
});
it('adds structured programmatic extraction evidence to the optimize prompt', () => {
const prompt = buildBrandEnrichmentPrompt('Existing extraction prompt', {
metadata: {
kind: 'brand',
brandSourceUrl: 'https://open-design.ai/',
brandId: 'brand_open_design',
brandDesignSystemId: 'user:open-design-6',
entryFile: 'brand.html',
importedFrom: 'brand-extraction',
},
designSystemId: 'user:open-design-6',
designSystemTitle: 'OpenDesign',
projectFiles: [
{
name: 'system/variables.css',
size: 2048,
kind: 'code',
mime: 'text/css',
},
{
name: 'fonts/Inter.woff2',
size: 8192,
kind: 'binary',
mime: 'font/woff2',
},
],
});
expect(prompt).toContain('Current programmatic extraction context:');
expect(prompt).toContain('Existing registered design system: OpenDesign (user:open-design-6)');
expect(prompt).toContain('Source to re-check: https://open-design.ai/');
expect(prompt).toContain('system/variables.css');
expect(prompt).toContain('fonts/Inter.woff2');
expect(prompt).toContain('Programmatic modules to inspect and reconcile');
});
it('recognizes reopened programmatic brand extraction projects from persisted metadata', () => {
expect(isProgrammaticBrandExtractionProject({
kind: 'prototype',
importedFrom: 'brand-extraction',
brandId: 'brand_baidu',
})).toBe(true);
expect(isProgrammaticBrandExtractionProject({
kind: 'prototype',
brandDesignSystemId: 'user:brand_baidu',
})).toBe(true);
expect(isProgrammaticBrandExtractionProject({ kind: 'prototype' })).toBe(false);
});
});