AI-native design editor. Open-source Figma alternative.
import { expect, test } from '@playwright/test'
import { CanvasHelper } from '#tests/helpers/canvas'
test('the font settings gear opens Settings › Fonts without desktop-only cache actions', async ({
page
}) => {
await page.goto('/?test')
const canvas = new CanvasHelper(page)
await canvas.waitForInit()
await page.evaluate(() => {
const store = window.openPencil?.getStore?.()
if (!store) throw new Error('OpenPencil store not initialized')
const id = store.createShape('TEXT', 120, 120, 240, 40)
store.updateNode(id, {
text: 'Font settings smoke',
fontFamily: 'Missing Test Sans'
})
store.select([id])
})
const typography = page.getByRole('region', { name: 'Typography' })
await expect(typography).toBeVisible()
await expect(
typography.getByRole('img', { name: /Missing font: Missing Test Sans/ })
).toBeVisible()
const fontBanner = page.getByTestId('font-status-banner')
await expect(fontBanner).toContainText('1 font face is unavailable or substituted')
await page.getByTestId('font-status-toggle').click()
await expect(page.getByTestId('font-status-issue')).toContainText(
'Missing Test Sans Regular → Inter'
)
await page.getByTestId('font-status-select').click()
await expect(page.getByTestId('font-status-banner')).toBeVisible()
const selected = await page.evaluate(() => {
const store = window.openPencil?.getStore?.()
return store ? [...store.state.selectedIds] : []
})
expect(selected).toHaveLength(1)
const fontSettings = page.getByRole('button', { name: 'Font settings' })
await expect(fontSettings).toHaveAttribute('data-test-id', 'font-settings-trigger')
await fontSettings.hover()
await expect(page.locator('[role=tooltip]').filter({ hasText: 'Font settings' })).toBeVisible()
await fontSettings.click()
await expect(page.locator('[role=tooltip]').filter({ hasText: 'Font settings' })).toHaveCount(0)
const panel = page.getByTestId('font-settings-panel')
await expect(panel).toBeVisible()
await expect(page.getByTestId('settings-section-fonts')).toHaveAttribute('aria-selected', 'true')
await expect(panel.getByText('Allow browser access to local fonts')).toBeVisible()
await expect(page.getByTestId('font-settings-request-access')).toBeVisible()
const online = panel.getByRole('switch', { name: 'Online fonts', exact: true })
const provider = (name: string) => panel.getByRole('switch', { name, exact: true })
await expect(online).toBeChecked()
await expect(provider('Google Fonts')).toBeChecked()
await expect(provider('Fontsource')).toBeChecked()
await expect(provider('Bunny Fonts')).not.toBeChecked()
await expect(provider('Fontshare')).not.toBeChecked()
await online.click()
await expect(online).not.toBeChecked()
await expect(provider('Google Fonts')).toBeDisabled()
await online.click()
await expect(online).toBeChecked()
await expect(page.getByTestId('font-settings-download-fallbacks')).toHaveCount(0)
await expect(page.getByTestId('font-settings-refresh-cache')).toHaveCount(0)
await expect(page.getByTestId('font-settings-clear-cache')).toHaveCount(0)
await expect(page.getByText('Download CJK and Arabic fallbacks')).toHaveCount(0)
await page.keyboard.press('Escape')
await expect(panel).toBeHidden()
await expect(typography).toBeVisible()
})