Skip to content

Commit 48baa4d

Browse files
committed
Fixing system unicode fonts
#1634
1 parent f3b2d34 commit 48baa4d

8 files changed

Lines changed: 20 additions & 3 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ Snapshots are used by end-to-end tests to visually verify the output. Snapshots
112112

113113
Once you are satisfied with the snapshots and everything is passing locally, you need to use the docker image to update snapshots for CI (unless you are running the same platform as CI (Ubuntu)). Run `npm run e2e:update-ci-snapshots` to update the CI snapshots. The snapshots will be written to your local directories. The Linux snapshots should be committed to git (non-Linux snapshots should be automatically ignored by git).
114114

115+
### Differences in CI vs Local Docker Environments
116+
Note that while both the GH actions and docker configuration use Ubuntu 22.04 images, their configurations are not identical. One known difference is the available system fonts. In some cases this can cause snapshots to differ when running locally vs in CI such as when rendering unicode characters. To mitigate this, some of our e2e tests have been configured to ensure a consistent unicode font fallback.
117+
118+
- The `DejaVu Sans` font gets installed via the [Dockerfile](tests/docker-scripts/Dockerfile). It already exists in the CI environment.
119+
- Font family stacks that involve unicode characters can explicitly fallback to `DejaVu Sans` if they impact snapshots. e.g We do so in [Grids.tsx](packages/code-studio/src/styleguide/Grids.tsx) by setting the canvas font to `12px Arial, "DejaVu Sans", sans-serif`
120+
115121
### Local
116122

117123
These scripts are recommended while developing your tests as they will be quicker to iterate and offer headed mode for debugging. You will need to run `npx playwright install` before using these scripts. You may also need to update the browsers with the same command any time the Playwright version is updated. See [Playwright Browsers](https://playwright.dev/docs/browsers) for more details.

packages/code-studio/src/styleguide/Grids.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ function Grids(): ReactElement {
2828
autoSelectRow: true,
2929
});
3030
const [contextTheme] = useState<Partial<GridThemeType>>({
31+
// Unicode characters '⊟' and '⊞' used by the Grid tree don't exist in Arial
32+
// font, so we fallback to DejaVu Sans which should exist on both the CI and
33+
// the local Docker environments. Otherwise the sans-serif fallback is at the
34+
// mercy of the OS and whatever installed fonts are available which is not
35+
// the same in the 2 environments.
36+
font: '12px Arial, "DejaVu Sans", sans-serif',
3137
rowHeight: 40,
3238
});
3339
return (

tests/docker-scripts/Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
FROM mcr.microsoft.com/playwright:v1.37.1-jammy AS playwright
55
WORKDIR /work/
66

7-
# Update packages list and install some build tools
7+
# Update packages list and install some build tools.
8+
# Installing fonts-dejavu-core so we have some common fonts with the GH actions
9+
# runner that can be used to render unicode fonts. See README for more info.
810
RUN set -eux; \
911
apt-get update; \
10-
apt-get install build-essential --yes;
12+
apt-get install build-essential --yes; \
13+
apt-get install fonts-dejavu-core --yes;
14+
15+
RUN fc-list : family;
1116

1217
# Copy just the .nvmrc first and install nvm/node/npm first as these will change the least often
1318
# https://docs.docker.com/build/cache/

tests/styleguide.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test.afterEach(async () => {
2727
});
2828

2929
// Iterate over all sample sections and take a screenshot of each one.
30-
test('UI regression test', async () => {
30+
test('UI regression test - Styleguide sections', async () => {
3131
const sampleSectionCount = await sampleSections.count();
3232

3333
for (let i = 0; i < sampleSectionCount; i += 1) {
1 Byte
Loading
420 Bytes
Loading
365 Bytes
Loading
985 Bytes
Loading

0 commit comments

Comments
 (0)