import assert from 'node:assert/strict'; import test from 'node:test'; import { MINDSPACE_PAGE_TAG_ATTR, MINDSPACE_PAGE_TAG_PLATFORM_BRAND, ensurePlatformBrandFooter, ensurePlatformBrandPageTags, injectPlatformBrandVisibilityStyle, normalizePlatformBrandHtml, PLATFORM_BRAND_STYLE_ID, prepareHtmlPageBrandMarkers, } from './mindspace-page-tag.mjs'; test('normalizePlatformBrandHtml rewrites tkmind.ai to tkmind.cn', () => { const html = '馃摟 contact@tkmind.ai'; const result = normalizePlatformBrandHtml(html); assert.match(result, /TKMind 路 鏅鸿叮/); assert.doesNotMatch(result, /tkmind\.ai/i); assert.doesNotMatch(result, /contact@tkmind\.cn/i); }); test('ensurePlatformBrandPageTags adds platform-brand marker to contact line', () => { const html = ''; const result = ensurePlatformBrandPageTags(html); assert.match(result, new RegExp(`${MINDSPACE_PAGE_TAG_ATTR}="${MINDSPACE_PAGE_TAG_PLATFORM_BRAND}"`)); assert.match(result, /TKMind 路 鏅鸿叮/); }); test('prepareHtmlPageBrandMarkers keeps existing marker', () => { const html = `

TKMind 路 鏅鸿叮

`; const result = prepareHtmlPageBrandMarkers(html); assert.equal(result.match(new RegExp(MINDSPACE_PAGE_TAG_ATTR, 'g'))?.length, 1); }); test('injectPlatformBrandVisibilityStyle adds readable brand css', () => { const html = '' + `

TKMind 路 鏅鸿叮

`; const result = injectPlatformBrandVisibilityStyle(html); assert.match(result, new RegExp(`id="${PLATFORM_BRAND_STYLE_ID}"`)); assert.match(result, /opacity:\s*1 !important/); assert.match(result, /font-family:.*PingFang SC/); }); test('ensurePlatformBrandFooter appends brand line when marker is missing', () => { const html = '
content
'; const result = ensurePlatformBrandFooter(html); assert.match(result, /data-mindspace-page-tag="platform-brand"/); assert.match(result, /TKMind 路 鏅鸿叮/); });