Skip to content

Commit efee2e1

Browse files
committed
test(regression-test): bundle Lato font for deterministic visual baselines
1 parent 0969a00 commit efee2e1

4 files changed

Lines changed: 26 additions & 2 deletions

File tree

regression-test/cypress/support/e2e.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ afterEach(function () {
5656
cy.location('pathname', { log: false }).then((pagePath) => {
5757
cy.task('recordMeta', { name, pagePath }, { log: false })
5858
})
59+
// Wait until web fonts have finished loading before capturing. Otherwise the
60+
// screenshot can be taken mid-load, when text is still rendered in a fallback
61+
// font with different metrics — producing inconsistent, flaky baselines.
62+
cy.document({ log: false }).then((doc) => doc.fonts.ready)
5963
cy.screenshot(name, {
6064
capture: 'fullPage',
6165
overwrite: true,

regression-test/package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

regression-test/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
"axe-core": "4.12.1",
2222
"cypress": "15.18.0",
2323
"cypress-axe": "1.7.0",
24-
"typescript": "6.0.3",
25-
"http-server": "14.1.1"
24+
"http-server": "14.1.1",
25+
"typescript": "6.0.3"
2626
},
2727
"dependencies": {
28+
"@fontsource/lato": "^5.2.7",
2829
"@instructure/ui": "file:../packages/ui",
2930
"@instructure/ui-icons": "file:../packages/ui-icons",
3031
"@instructure/ui-scripts": "file:../packages/ui-scripts",

regression-test/src/app/layout.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424
'use client'
2525
import React from 'react'
2626
import { Inter } from 'next/font/google'
27+
// Self-host Lato so InstUI's `LatoWeb, Lato, ...` font stack resolves to a real,
28+
// bundled font in every environment. Without this the stack falls back to
29+
// whatever sans-serif the OS provides (Helvetica Neue locally, DejaVu Sans in
30+
// the Linux CI container), which changes text metrics and makes layout-driven
31+
// components render at different heights — breaking the visual baseline.
32+
// InstUI uses weights 300/400/700.
33+
import '@fontsource/lato/300.css'
34+
import '@fontsource/lato/400.css'
35+
import '@fontsource/lato/700.css'
2736
import './globals.css'
2837
import { InstUISettingsProvider } from '@instructure/ui/latest'
2938

0 commit comments

Comments
 (0)