diff --git a/web/src/components/creator/WorksGallery.tsx b/web/src/components/creator/WorksGallery.tsx index bd35825..06a86d7 100644 --- a/web/src/components/creator/WorksGallery.tsx +++ b/web/src/components/creator/WorksGallery.tsx @@ -361,7 +361,7 @@ export default function WorksGallery({ sourceId, sourceType, emptyHint, extraFil ) : null} {work.body ? ( - + {work.body} ) : null} @@ -372,11 +372,9 @@ export default function WorksGallery({ sourceId, sourceType, emptyHint, extraFil {work.likes_growth != null || extraFilters?.growth_hours ? ( 24h 点赞增量 {work.likes_growth == null ? '—' : `+${work.likes_growth}`} diff --git a/web/tests/works-gallery-card.test.cjs b/web/tests/works-gallery-card.test.cjs index d3a4e80..c9fbbc8 100644 --- a/web/tests/works-gallery-card.test.cjs +++ b/web/tests/works-gallery-card.test.cjs @@ -44,6 +44,31 @@ test('卡片展示作品描述(body 省略两行)', () => { assert.match(body, /ellipsis=\{\{ rows: 2, tooltip: true \}\}/); }); +for (const [name, tag, content] of [ + ['作品简介', 'Typography.Paragraph', '{work.body}'], + ['24h 点赞增量', 'Typography.Text', 'work.likes_growth == null'], +]) { + test(`卡片${name}使用默认正文字体和字号`, () => { + const matches = []; + function visit(node) { + if (ts.isJsxElement(node) + && node.openingElement.tagName.getText(source) === tag + && node.children.some(child => child.getText(source).includes(content))) { + matches.push(node.openingElement); + } + ts.forEachChild(node, visit); + } + visit(source); + assert.equal(matches.length, 1, '应找到对应的卡片文字'); + const attributes = matches[0].attributes.properties; + for (const attribute of attributes) { + assert.ok(ts.isJsxAttribute(attribute), '文字不应通过展开属性覆盖默认样式'); + assert.ok(!['type', 'strong', 'italic'].includes(attribute.name.getText(source))); + } + assert.doesNotMatch(matches[0].attributes.getText(source), /fontSize|fontFamily|fontWeight|color/); + }); +} + function sourceText() { return source.getFullText(); }