Spaces:
Running
Running
File size: 3,492 Bytes
805101e 84810e9 6a6bf47 805101e 84810e9 805101e 67447a4 84810e9 67447a4 84810e9 52e074c 67447a4 805101e 84810e9 805101e 6a6bf47 805101e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { join } from 'node:path';
import { describe, it } from 'node:test';
import { GIT_DEPLOY_AUTHOR_EMAIL, GIT_DEPLOY_AUTHOR_NAME } from './deploy-hf-space.mjs';
import { HF_SPACE_ID, HF_SPACE_URL } from './hf-space-doctor-utils.mjs';
import { FORMAL_PRODUCT_NAME } from './status.mjs';
const repoRoot = fileURLToPath(new URL('..', import.meta.url));
function readRepositoryText(path) {
return readFileSync(join(repoRoot, path), 'utf8');
}
describe('product branding', () => {
it('uses the formal product name in Hugging Face metadata and the browser icon', () => {
const readme = readRepositoryText('README.md');
const favicon = readRepositoryText('public/favicon.svg');
assert.match(
readme,
/^---\ntitle: 图像手记 \/ Visual Journal\nshort_description: 本地优先的 AI 图片创作工作台\nsdk: docker\napp_port: 4783\n---/m
);
assert.match(readme, /HF Space 已使用 `visual-journal` 名称;/);
assert.doesNotMatch(readme, /HF Space slug、环境变量、API 路径和 Skill 标识继续使用/);
assert.match(favicon, /<title>图像手记 \/ Visual Journal<\/title>/);
});
it('offers an isolated private Hugging Face Space copy without sharing production credentials', () => {
const readme = readRepositoryText('README.md');
assert.match(
readme,
/https:\/\/huggingface\.co\/new-space\?duplicate=misonL%2Fvisual-journal/
);
assert.match(readme, /登录 Hugging Face 后,创建页会预填本 Space 作为复制来源。请在创建页选择 Private;/);
assert.match(
readme,
/`npm run deploy:space` 不会自动定位或更新该私人副本。/
);
});
it('uses the formal product name in access-code guidance and history downloads', () => {
const translations = readRepositoryText('src/lib/i18n.tsx');
const page = readRepositoryText('src/app/page.tsx');
assert.match(translations, /'password\.entryDescription': '请输入访问码以使用图像手记服务。'/);
assert.match(translations, /'password\.entryDescription': 'Enter the access code to use Visual Journal.'/);
assert.match(page, /link\.download = `visual-journal-history-\$\{item\.timestamp\}\.zip`;/);
});
it('uses Visual Journal identifiers for automated Space maintenance', () => {
const keepalive = readRepositoryText('scripts/keepalive-hf-space.mjs');
assert.match(keepalive, /const KEEPALIVE_USER_AGENT = 'visual-journal-keepalive\/1\.0';/);
assert.match(keepalive, /'User-Agent': KEEPALIVE_USER_AGENT/);
assert.equal(HF_SPACE_ID, 'misonL/visual-journal');
assert.equal(HF_SPACE_URL, 'https://misonl-visual-journal.hf.space');
assert.equal(GIT_DEPLOY_AUTHOR_NAME, 'Visual Journal deploy');
assert.equal(GIT_DEPLOY_AUTHOR_EMAIL, 'deploy@visual-journal.local');
});
it('uses the formal product name in operational status while retaining the package identifier', () => {
const status = readRepositoryText('scripts/status.mjs');
assert.equal(FORMAL_PRODUCT_NAME, '图像手记 / Visual Journal');
assert.match(status, /product: FORMAL_PRODUCT_NAME,/);
assert.match(status, /package_name: packageJson\.name,/);
});
});
|