summaryrefslogtreecommitdiffhomepage
path: root/packages/app/e2e/settings
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-03-26 14:02:01 -0500
committerGitHub <[email protected]>2026-03-26 14:02:01 -0500
commitb8fb75a94adbd9f0175e29403cd85fde55cc2793 (patch)
tree696c2e6764766a3cf4ac74e31c968c1236d66696 /packages/app/e2e/settings
parent98a31e30ccc5efed528db5cb7afe9eb00f5aa2d2 (diff)
downloadopencode-b8fb75a94adbd9f0175e29403cd85fde55cc2793.tar.gz
opencode-b8fb75a94adbd9f0175e29403cd85fde55cc2793.zip
fix(app): don't bundle fonts (#19329)
Diffstat (limited to 'packages/app/e2e/settings')
-rw-r--r--packages/app/e2e/settings/settings.spec.ts295
1 files changed, 242 insertions, 53 deletions
diff --git a/packages/app/e2e/settings/settings.spec.ts b/packages/app/e2e/settings/settings.spec.ts
index f25e91a31..0602e95c7 100644
--- a/packages/app/e2e/settings/settings.spec.ts
+++ b/packages/app/e2e/settings/settings.spec.ts
@@ -2,7 +2,7 @@ import { test, expect, settingsKey } from "../fixtures"
import { closeDialog, openSettings } from "../actions"
import {
settingsColorSchemeSelector,
- settingsFontSelector,
+ settingsCodeFontSelector,
settingsLanguageSelectSelector,
settingsNotificationsAgentSelector,
settingsNotificationsErrorsSelector,
@@ -12,6 +12,7 @@ import {
settingsSoundsErrorsSelector,
settingsSoundsPermissionsSelector,
settingsThemeSelector,
+ settingsUIFontSelector,
settingsUpdatesStartupSelector,
} from "../selectors"
@@ -152,39 +153,199 @@ test("legacy oc-1 theme migrates to oc-2", async ({ page, gotoSession }) => {
.toBeNull()
})
-test("changing font persists in localStorage and updates CSS variable", async ({ page, gotoSession }) => {
+test("typing a code font with spaces persists and updates CSS variable", async ({ page, gotoSession }) => {
await gotoSession()
const dialog = await openSettings(page)
- const select = dialog.locator(settingsFontSelector)
- await expect(select).toBeVisible()
-
- const initialFontFamily = await page.evaluate(() => {
- return getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono")
- })
+ const input = dialog.locator(settingsCodeFontSelector)
+ await expect(input).toBeVisible()
+ await expect(input).toHaveAttribute("placeholder", "IBM Plex Mono")
+
+ const initialFontFamily = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").trim(),
+ )
+ const initialUIFamily = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-sans").trim(),
+ )
expect(initialFontFamily).toContain("IBM Plex Mono")
- await select.locator('[data-slot="select-select-trigger"]').click()
+ const next = "Test Mono"
- const items = page.locator('[data-slot="select-select-item"]')
- await items.nth(2).click()
+ await input.click()
+ await input.clear()
+ await input.pressSequentially(next)
+ await expect(input).toHaveValue(next)
- await page.waitForTimeout(100)
+ await expect
+ .poll(async () => {
+ return await page.evaluate((key) => {
+ const raw = localStorage.getItem(key)
+ return raw ? JSON.parse(raw) : null
+ }, settingsKey)
+ })
+ .toMatchObject({
+ appearance: {
+ font: next,
+ },
+ })
- const stored = await page.evaluate((key) => {
- const raw = localStorage.getItem(key)
- return raw ? JSON.parse(raw) : null
- }, settingsKey)
+ const newFontFamily = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").trim(),
+ )
+ const newUIFamily = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-sans").trim(),
+ )
+ expect(newFontFamily).toContain(next)
+ expect(newFontFamily).not.toBe(initialFontFamily)
+ expect(newUIFamily).toBe(initialUIFamily)
+})
- expect(stored?.appearance?.font).not.toBe("ibm-plex-mono")
+test("typing a UI font with spaces persists and updates CSS variable", async ({ page, gotoSession }) => {
+ await gotoSession()
- const newFontFamily = await page.evaluate(() => {
- return getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono")
- })
+ const dialog = await openSettings(page)
+ const input = dialog.locator(settingsUIFontSelector)
+ await expect(input).toBeVisible()
+ await expect(input).toHaveAttribute("placeholder", "Inter")
+
+ const initialFontFamily = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-sans").trim(),
+ )
+ const initialCodeFamily = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").trim(),
+ )
+ expect(initialFontFamily).toContain("Inter")
+
+ const next = "Test Sans"
+
+ await input.click()
+ await input.clear()
+ await input.pressSequentially(next)
+ await expect(input).toHaveValue(next)
+
+ await expect
+ .poll(async () => {
+ return await page.evaluate((key) => {
+ const raw = localStorage.getItem(key)
+ return raw ? JSON.parse(raw) : null
+ }, settingsKey)
+ })
+ .toMatchObject({
+ appearance: {
+ uiFont: next,
+ },
+ })
+
+ const newFontFamily = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-sans").trim(),
+ )
+ const newCodeFamily = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").trim(),
+ )
+ expect(newFontFamily).toContain(next)
expect(newFontFamily).not.toBe(initialFontFamily)
+ expect(newCodeFamily).toBe(initialCodeFamily)
})
-test("color scheme and font rehydrate after reload", async ({ page, gotoSession }) => {
+test("clearing the code font field restores the default placeholder and stack", async ({ page, gotoSession }) => {
+ await gotoSession()
+
+ const dialog = await openSettings(page)
+ const input = dialog.locator(settingsCodeFontSelector)
+ await expect(input).toBeVisible()
+
+ await input.click()
+ await input.clear()
+ await input.pressSequentially("Reset Mono")
+
+ await expect
+ .poll(async () => {
+ return await page.evaluate((key) => {
+ const raw = localStorage.getItem(key)
+ return raw ? JSON.parse(raw) : null
+ }, settingsKey)
+ })
+ .toMatchObject({
+ appearance: {
+ font: "Reset Mono",
+ },
+ })
+
+ await input.clear()
+ await input.press("Space")
+ await expect(input).toHaveValue("")
+ await expect(input).toHaveAttribute("placeholder", "IBM Plex Mono")
+
+ await expect
+ .poll(async () => {
+ return await page.evaluate((key) => {
+ const raw = localStorage.getItem(key)
+ return raw ? JSON.parse(raw) : null
+ }, settingsKey)
+ })
+ .toMatchObject({
+ appearance: {
+ font: "",
+ },
+ })
+
+ const fontFamily = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").trim(),
+ )
+ expect(fontFamily).toContain("IBM Plex Mono")
+ expect(fontFamily).not.toContain("Reset Mono")
+})
+
+test("clearing the UI font field restores the default placeholder and stack", async ({ page, gotoSession }) => {
+ await gotoSession()
+
+ const dialog = await openSettings(page)
+ const input = dialog.locator(settingsUIFontSelector)
+ await expect(input).toBeVisible()
+
+ await input.click()
+ await input.clear()
+ await input.pressSequentially("Reset Sans")
+
+ await expect
+ .poll(async () => {
+ return await page.evaluate((key) => {
+ const raw = localStorage.getItem(key)
+ return raw ? JSON.parse(raw) : null
+ }, settingsKey)
+ })
+ .toMatchObject({
+ appearance: {
+ uiFont: "Reset Sans",
+ },
+ })
+
+ await input.clear()
+ await input.press("Space")
+ await expect(input).toHaveValue("")
+ await expect(input).toHaveAttribute("placeholder", "Inter")
+
+ await expect
+ .poll(async () => {
+ return await page.evaluate((key) => {
+ const raw = localStorage.getItem(key)
+ return raw ? JSON.parse(raw) : null
+ }, settingsKey)
+ })
+ .toMatchObject({
+ appearance: {
+ uiFont: "",
+ },
+ })
+
+ const fontFamily = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-sans").trim(),
+ )
+ expect(fontFamily).toContain("Inter")
+ expect(fontFamily).not.toContain("Reset Sans")
+})
+
+test("color scheme, code font, and UI font rehydrate after reload", async ({ page, gotoSession }) => {
await gotoSession()
const dialog = await openSettings(page)
@@ -195,31 +356,35 @@ test("color scheme and font rehydrate after reload", async ({ page, gotoSession
await page.locator('[data-slot="select-select-item"]').filter({ hasText: "Dark" }).click()
await expect(page.locator("html")).toHaveAttribute("data-color-scheme", "dark")
- const fontSelect = dialog.locator(settingsFontSelector)
- await expect(fontSelect).toBeVisible()
+ const code = dialog.locator(settingsCodeFontSelector)
+ const ui = dialog.locator(settingsUIFontSelector)
+ await expect(code).toBeVisible()
+ await expect(ui).toBeVisible()
- const initialFontFamily = await page.evaluate(() => {
- return getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").trim()
- })
+ const initialMono = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").trim(),
+ )
+ const initialSans = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-sans").trim(),
+ )
const initialSettings = await page.evaluate((key) => {
const raw = localStorage.getItem(key)
return raw ? JSON.parse(raw) : null
}, settingsKey)
- const currentFont =
- (await fontSelect.locator('[data-slot="select-select-trigger-value"]').textContent())?.trim() ?? ""
- await fontSelect.locator('[data-slot="select-select-trigger"]').click()
+ const mono = initialSettings?.appearance?.font === "Reload Mono" ? "Reload Mono 2" : "Reload Mono"
+ const sans = initialSettings?.appearance?.uiFont === "Reload Sans" ? "Reload Sans 2" : "Reload Sans"
- const fontItems = page.locator('[data-slot="select-select-item"]')
- expect(await fontItems.count()).toBeGreaterThan(1)
+ await code.click()
+ await code.clear()
+ await code.pressSequentially(mono)
+ await expect(code).toHaveValue(mono)
- if (currentFont) {
- await fontItems.filter({ hasNotText: currentFont }).first().click()
- }
- if (!currentFont) {
- await fontItems.nth(1).click()
- }
+ await ui.click()
+ await ui.clear()
+ await ui.pressSequentially(sans)
+ await expect(ui).toHaveValue(sans)
await expect
.poll(async () => {
@@ -230,7 +395,8 @@ test("color scheme and font rehydrate after reload", async ({ page, gotoSession
})
.toMatchObject({
appearance: {
- font: expect.any(String),
+ font: mono,
+ uiFont: sans,
},
})
@@ -239,11 +405,18 @@ test("color scheme and font rehydrate after reload", async ({ page, gotoSession
return raw ? JSON.parse(raw) : null
}, settingsKey)
- const updatedFontFamily = await page.evaluate(() => {
- return getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").trim()
- })
- expect(updatedFontFamily).not.toBe(initialFontFamily)
- expect(updatedSettings?.appearance?.font).not.toBe(initialSettings?.appearance?.font)
+ const updatedMono = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").trim(),
+ )
+ const updatedSans = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-sans").trim(),
+ )
+ expect(updatedMono).toContain(mono)
+ expect(updatedMono).not.toBe(initialMono)
+ expect(updatedSans).toContain(sans)
+ expect(updatedSans).not.toBe(initialSans)
+ expect(updatedSettings?.appearance?.font).toBe(mono)
+ expect(updatedSettings?.appearance?.uiFont).toBe(sans)
await closeDialog(page, dialog)
await page.reload()
@@ -259,7 +432,8 @@ test("color scheme and font rehydrate after reload", async ({ page, gotoSession
})
.toMatchObject({
appearance: {
- font: updatedSettings?.appearance?.font,
+ font: mono,
+ uiFont: sans,
},
})
@@ -270,17 +444,32 @@ test("color scheme and font rehydrate after reload", async ({ page, gotoSession
await expect
.poll(async () => {
- return await page.evaluate(() => {
- return getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").trim()
- })
+ return await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").trim(),
+ )
})
- .not.toBe(initialFontFamily)
+ .toContain(mono)
- const rehydratedFontFamily = await page.evaluate(() => {
- return getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").trim()
- })
- expect(rehydratedFontFamily).not.toBe(initialFontFamily)
- expect(rehydratedSettings?.appearance?.font).toBe(updatedSettings?.appearance?.font)
+ await expect
+ .poll(async () => {
+ return await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-sans").trim(),
+ )
+ })
+ .toContain(sans)
+
+ const rehydratedMono = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").trim(),
+ )
+ const rehydratedSans = await page.evaluate(() =>
+ getComputedStyle(document.documentElement).getPropertyValue("--font-family-sans").trim(),
+ )
+ expect(rehydratedMono).toContain(mono)
+ expect(rehydratedMono).not.toBe(initialMono)
+ expect(rehydratedSans).toContain(sans)
+ expect(rehydratedSans).not.toBe(initialSans)
+ expect(rehydratedSettings?.appearance?.font).toBe(mono)
+ expect(rehydratedSettings?.appearance?.uiFont).toBe(sans)
})
test("toggling notification agent switch updates localStorage", async ({ page, gotoSession }) => {