diff --git a/tests/detect-antipatterns-fixtures.test.mjs b/tests/detect-antipatterns-fixtures.test.mjs index da85b0653..814f259b4 100644 --- a/tests/detect-antipatterns-fixtures.test.mjs +++ b/tests/detect-antipatterns-fixtures.test.mjs @@ -633,6 +633,21 @@ describe('detectHtml — static HTML/CSS fixtures', () => { assert.equal(f.length, 0); }); + it('overused-font: flags named primaries and skips system-stack Roboto', async () => { + const f = await detectHtml(path.join(FIXTURES, 'overused-font.html')); + const snippets = f.filter(r => r.antipattern === 'overused-font').map(r => r.snippet).join(' | '); + for (const font of ['inter', 'geist', 'montserrat', 'lato']) { + assert.match(snippets, new RegExp(`Primary font: ${font}`), `expected flag for ${font}: ${snippets}`); + } + assert.doesNotMatch(snippets, /roboto/i, `system-stack Roboto must not be primary: ${snippets}`); + assert.doesNotMatch(snippets, /arial/i, `system-stack Arial must not be primary: ${snippets}`); + assert.equal( + f.some(r => r.antipattern === 'flat-type-hierarchy'), + false, + `overused-font fixture should not contain incidental type findings: ${f.map(r => `${r.antipattern}:${r.snippet}`).join('; ')}`, + ); + }); + it('design-system: flags only values outside the provided DESIGN.md tokens', async () => { const designSystem = normalizeDesignSystem({ frontmatter: { diff --git a/tests/detect-antipatterns.test.js b/tests/detect-antipatterns.test.js index 6fdb8427b..e5cab77a1 100644 --- a/tests/detect-antipatterns.test.js +++ b/tests/detect-antipatterns.test.js @@ -675,44 +675,6 @@ describe('detectText — overused fonts', () => { }); describe('detectHtml — overused fonts system stack', () => { - const systemStackCss = `body { font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; } - h1 { font-size: 34px; } - p { font-size: 15px; } - small { font-size: 12px; }`; - const systemStackPage = `

Hello

world

meta`; - - test('font shorthand system stack does not flag Roboto as overused', async () => { - await withStaticFixture({ 'index.html': systemStackPage }, async ({ file }) => { - const f = await detectHtml(file); - expect(f.filter(r => r.antipattern === 'overused-font')).toHaveLength(0); - }); - }); - - test('font-family system stack does not flag Roboto as overused', async () => { - const page = `

Hello

world

meta`; - await withStaticFixture({ 'index.html': page }, async ({ file }) => { - const f = await detectHtml(file); - expect(f.filter(r => r.antipattern === 'overused-font')).toHaveLength(0); - }); - }); - - test('Inter before system stack still flags overused-font', async () => { - const page = `

Hello

world

`; - await withStaticFixture({ 'index.html': page }, async ({ file }) => { - const f = await detectHtml(file); - expect(f.some(r => r.antipattern === 'overused-font' && /inter/i.test(r.snippet))).toBe(true); - }); - }); - test('checkPageTypography regex path skips Roboto in system stack', () => { const html = ` + + +

Overused Font

+
+
+

Should flag

+
+

Overused Inter

+

Inter is the primary face on this block, so overused-font should name it.

+
+
+

Overused Geist

+

Geist is the primary face on this block, so overused-font should name it.

+
+
+

Overused Montserrat

+

Montserrat is the primary face on this block, so overused-font should name it.

+
+
+

Overused Lato

+

Lato is the primary face on this block, so overused-font should name it.

+
+
+

Inter Before System Stack

+

Inter ahead of -apple-system is still the primary face, so overused-font should name it.

+
+
+
+

Should pass

+
+

Canonical System Stack

+

Roboto sits after Apple and Segoe UI faces in this stack, so it is a fallback, not the primary.

+
+
+

Font Family System Stack

+

The same stack written as font-family must also leave Roboto unflagged.

+
+
+

System UI Only

+

system-ui with a generic fallback is a platform face, not an overused web font.

+
+
+

Segoe UI Lead

+

Segoe UI in the lead position keeps Roboto as a later platform fallback.

+
+
+

Ui Sans Lead

+

ui-sans-serif in the lead position keeps Roboto as a later platform fallback.

+
+
+
+ + +