upddate
This commit is contained in:
1 parent
ff6c2df618
commit
43cfaa0411
18 files changed
+683
-299
No files matched your search
@@ -1,30 +1,37 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { describe, it } from 'node:test';
|
||||
import { CONTENT_LANGUAGES } from './content-languages.ts';
|
||||
import { CATEGORY_PROMPT_EXAMPLES, CATEGORY_FORMULA_RULES, localizedCategoryPromptExample } from './categories/prompt-examples.ts';
|
||||
import { CATEGORY_FORMULA_RULES, localizedCategoryPromptExample } from './categories/prompt-examples.ts';
|
||||
|
||||
const sections = ['title', 'description', 'meta'] as const;
|
||||
const expectedTagOrder = ['p', 'h2', 'p', 'h2', 'ul'];
|
||||
|
||||
describe('localized category prompt examples', () => {
|
||||
it('has meaningful localized examples for every supported content language', () => {
|
||||
assert.equal(Object.keys(CATEGORY_PROMPT_EXAMPLES).length, CONTENT_LANGUAGES.length);
|
||||
const en = CATEGORY_PROMPT_EXAMPLES.en;
|
||||
for (const { value: lang } of CONTENT_LANGUAGES) {
|
||||
describe('localized category prompt SEO formulas', () => {
|
||||
it('covers every supported language with localized title, HTML description and SEO meta instructions', () => {
|
||||
assert.equal(Object.keys(CATEGORY_FORMULA_RULES).length, CONTENT_LANGUAGES.length);
|
||||
for (const { value: language } of CONTENT_LANGUAGES) {
|
||||
for (const section of sections) {
|
||||
const example = localizedCategoryPromptExample(lang, section);
|
||||
assert.ok(example.length >= 45, `${lang}/${section} is too short`);
|
||||
assert.ok(example.includes('{{name}}'), `${lang}/${section} loses the name token`);
|
||||
assert.ok(example.startsWith(CATEGORY_PROMPT_EXAMPLES[lang][section]));
|
||||
assert.ok(example.includes(CATEGORY_FORMULA_RULES[lang][section]));
|
||||
assert.ok(CATEGORY_FORMULA_RULES[lang][section].length > 30, `${lang}/${section} missing detailed formula`);
|
||||
if (lang !== 'en') assert.notEqual(example, en[section], `${lang}/${section} is English`);
|
||||
const rule = localizedCategoryPromptExample(language, section);
|
||||
assert.equal(rule, CATEGORY_FORMULA_RULES[language][section]);
|
||||
assert.ok(rule.length > 90, `${language}/${section} incomplete`);
|
||||
assert.ok(rule.includes('{') && rule.includes('}'), `${language}/${section} missing instruction braces`);
|
||||
}
|
||||
const description = CATEGORY_FORMULA_RULES[language].description;
|
||||
assert.deepEqual([...description.matchAll(/<(p|h2|ul)(?=>)/g)].map((m) => m[1]), expectedTagOrder, `${language} wrong HTML order`);
|
||||
assert.equal((description.match(/<ul><li>\{/g) ?? []).length, 1, `${language} needs one specs list`);
|
||||
assert.ok(!description.includes('<h1>'), `${language} must not add another product H1`);
|
||||
assert.ok(description.includes('{{name}}') && description.includes('{{attrs}}'), `${language} missing evidence tokens`);
|
||||
assert.ok(CATEGORY_FORMULA_RULES[language].meta.includes('meta_title:'));
|
||||
assert.ok(CATEGORY_FORMULA_RULES[language].meta.includes('meta_description:'));
|
||||
assert.ok(!/five distinct H2|approximately 100 words below each|pet različitih naslova H2|pet različnih naslovov H2/i.test(description), `${language} old bloated SEO template`);
|
||||
}
|
||||
});
|
||||
it('changes the example to match the selected content language, independently of UI locale', () => {
|
||||
assert.match(localizedCategoryPromptExample('hr', 'description'), /Opiši/);
|
||||
assert.match(localizedCategoryPromptExample('sl', 'description'), /Naravno opiši/);
|
||||
assert.match(localizedCategoryPromptExample('ja', 'title'), /商品名/);
|
||||
assert.match(localizedCategoryPromptExample('de', 'title'), /Produkttitel/);
|
||||
it('shows actual localized HTML when changing languages, not a one-line summary', () => {
|
||||
const hr = localizedCategoryPromptExample('hr', 'description');
|
||||
const en = localizedCategoryPromptExample('en', 'description');
|
||||
assert.match(hr, /Tehničke specifikacije/);
|
||||
assert.match(en, /Technical specifications/);
|
||||
assert.ok(hr.includes('<h2>{') && hr.includes('<ul><li>{'));
|
||||
assert.notEqual(hr, en);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user