summaryrefslogtreecommitdiffhomepage
path: root/packages/app/e2e/settings
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-02-11 09:11:41 -0600
committeropencode <[email protected]>2026-02-11 15:12:28 +0000
commitfc88dde63f1c4a7f547bbe0634c68c5ce9fc787c (patch)
tree4e6aaad7afb646348c3b676a6269455dac63a7d8 /packages/app/e2e/settings
parent4619e9d183d036f2f7234046927ec2f72d426168 (diff)
downloadopencode-fc88dde63f1c4a7f547bbe0634c68c5ce9fc787c.tar.gz
opencode-fc88dde63f1c4a7f547bbe0634c68c5ce9fc787c.zip
test(app): more e2e tests (#13162)
Diffstat (limited to 'packages/app/e2e/settings')
-rw-r--r--packages/app/e2e/settings/settings-keybinds.spec.ts74
-rw-r--r--packages/app/e2e/settings/settings.spec.ts162
2 files changed, 235 insertions, 1 deletions
diff --git a/packages/app/e2e/settings/settings-keybinds.spec.ts b/packages/app/e2e/settings/settings-keybinds.spec.ts
index a8e7f3352..5e98bd158 100644
--- a/packages/app/e2e/settings/settings-keybinds.spec.ts
+++ b/packages/app/e2e/settings/settings-keybinds.spec.ts
@@ -9,7 +9,7 @@ test("changing sidebar toggle keybind works", async ({ page, gotoSession }) => {
const dialog = await openSettings(page)
await dialog.getByRole("tab", { name: "Shortcuts" }).click()
- const keybindButton = dialog.locator(keybindButtonSelector("sidebar.toggle"))
+ const keybindButton = dialog.locator(keybindButtonSelector("sidebar.toggle")).first()
await expect(keybindButton).toBeVisible()
const initialKeybind = await keybindButton.textContent()
@@ -51,6 +51,40 @@ test("changing sidebar toggle keybind works", async ({ page, gotoSession }) => {
expect(finalClosed).toBe(initiallyClosed)
})
+test("sidebar toggle keybind guards against shortcut conflicts", async ({ page, gotoSession }) => {
+ await gotoSession()
+
+ const dialog = await openSettings(page)
+ await dialog.getByRole("tab", { name: "Shortcuts" }).click()
+
+ const keybindButton = dialog.locator(keybindButtonSelector("sidebar.toggle"))
+ await expect(keybindButton).toBeVisible()
+
+ const initialKeybind = await keybindButton.textContent()
+ expect(initialKeybind).toContain("B")
+
+ await keybindButton.click()
+ await expect(keybindButton).toHaveText(/press/i)
+
+ await page.keyboard.press(`${modKey}+Shift+KeyP`)
+ await page.waitForTimeout(100)
+
+ const toast = page.locator('[data-component="toast"]').last()
+ await expect(toast).toBeVisible()
+ await expect(toast).toContainText(/already/i)
+
+ await keybindButton.click()
+ await expect(keybindButton).toContainText("B")
+
+ const stored = await page.evaluate(() => {
+ const raw = localStorage.getItem("settings.v3")
+ return raw ? JSON.parse(raw) : null
+ })
+ expect(stored?.keybinds?.["sidebar.toggle"]).toBeUndefined()
+
+ await closeDialog(page, dialog)
+})
+
test("resetting all keybinds to defaults works", async ({ page, gotoSession }) => {
await page.addInitScript(() => {
localStorage.setItem("settings.v3", JSON.stringify({ keybinds: { "sidebar.toggle": "mod+shift+x" } }))
@@ -277,6 +311,44 @@ test("changing terminal toggle keybind works", async ({ page, gotoSession }) =>
await expect(terminal).not.toBeVisible()
})
+test("terminal toggle keybind persists after reload", async ({ page, gotoSession }) => {
+ await gotoSession()
+
+ const dialog = await openSettings(page)
+ await dialog.getByRole("tab", { name: "Shortcuts" }).click()
+
+ const keybindButton = dialog.locator(keybindButtonSelector("terminal.toggle"))
+ await expect(keybindButton).toBeVisible()
+
+ await keybindButton.click()
+ await expect(keybindButton).toHaveText(/press/i)
+
+ await page.keyboard.press(`${modKey}+Shift+KeyY`)
+ await page.waitForTimeout(100)
+
+ await expect(keybindButton).toContainText("Y")
+ await closeDialog(page, dialog)
+
+ await page.reload()
+
+ await expect
+ .poll(async () => {
+ return await page.evaluate(() => {
+ const raw = localStorage.getItem("settings.v3")
+ if (!raw) return
+ const parsed = JSON.parse(raw)
+ return parsed?.keybinds?.["terminal.toggle"]
+ })
+ })
+ .toBe("mod+shift+y")
+
+ const reloaded = await openSettings(page)
+ await reloaded.getByRole("tab", { name: "Shortcuts" }).click()
+ const reloadedKeybind = reloaded.locator(keybindButtonSelector("terminal.toggle")).first()
+ await expect(reloadedKeybind).toContainText("Y")
+ await closeDialog(page, reloaded)
+})
+
test("changing command palette keybind works", async ({ page, gotoSession }) => {
await gotoSession()
diff --git a/packages/app/e2e/settings/settings.spec.ts b/packages/app/e2e/settings/settings.spec.ts
index 2865419f0..42534968b 100644
--- a/packages/app/e2e/settings/settings.spec.ts
+++ b/packages/app/e2e/settings/settings.spec.ts
@@ -9,6 +9,8 @@ import {
settingsNotificationsPermissionsSelector,
settingsReleaseNotesSelector,
settingsSoundsAgentSelector,
+ settingsSoundsErrorsSelector,
+ settingsSoundsPermissionsSelector,
settingsThemeSelector,
settingsUpdatesStartupSelector,
} from "../selectors"
@@ -139,6 +141,105 @@ test("changing font persists in localStorage and updates CSS variable", async ({
expect(newFontFamily).not.toBe(initialFontFamily)
})
+test("color scheme and font rehydrate after reload", async ({ page, gotoSession }) => {
+ await gotoSession()
+
+ const dialog = await openSettings(page)
+
+ const colorSchemeSelect = dialog.locator(settingsColorSchemeSelector)
+ await expect(colorSchemeSelect).toBeVisible()
+ await colorSchemeSelect.locator('[data-slot="select-select-trigger"]').click()
+ 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 initialFontFamily = await page.evaluate(() => {
+ return getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").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 fontItems = page.locator('[data-slot="select-select-item"]')
+ expect(await fontItems.count()).toBeGreaterThan(1)
+
+ if (currentFont) {
+ await fontItems.filter({ hasNotText: currentFont }).first().click()
+ }
+ if (!currentFont) {
+ await fontItems.nth(1).click()
+ }
+
+ await expect
+ .poll(async () => {
+ return await page.evaluate((key) => {
+ const raw = localStorage.getItem(key)
+ return raw ? JSON.parse(raw) : null
+ }, settingsKey)
+ })
+ .toMatchObject({
+ appearance: {
+ font: expect.any(String),
+ },
+ })
+
+ const updatedSettings = await page.evaluate((key) => {
+ const raw = localStorage.getItem(key)
+ 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)
+
+ await closeDialog(page, dialog)
+ await page.reload()
+
+ await expect(page.locator("html")).toHaveAttribute("data-color-scheme", "dark")
+
+ await expect
+ .poll(async () => {
+ return await page.evaluate((key) => {
+ const raw = localStorage.getItem(key)
+ return raw ? JSON.parse(raw) : null
+ }, settingsKey)
+ })
+ .toMatchObject({
+ appearance: {
+ font: updatedSettings?.appearance?.font,
+ },
+ })
+
+ const rehydratedSettings = await page.evaluate((key) => {
+ const raw = localStorage.getItem(key)
+ return raw ? JSON.parse(raw) : null
+ }, settingsKey)
+
+ await expect
+ .poll(async () => {
+ return await page.evaluate(() => {
+ return getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono").trim()
+ })
+ })
+ .not.toBe(initialFontFamily)
+
+ 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)
+})
+
test("toggling notification agent switch updates localStorage", async ({ page, gotoSession }) => {
await gotoSession()
@@ -234,6 +335,67 @@ test("changing sound agent selection persists in localStorage", async ({ page, g
expect(stored?.sounds?.agent).not.toBe("staplebops-01")
})
+test("changing permissions and errors sounds updates localStorage", async ({ page, gotoSession }) => {
+ await gotoSession()
+
+ const dialog = await openSettings(page)
+ const permissionsSelect = dialog.locator(settingsSoundsPermissionsSelector)
+ const errorsSelect = dialog.locator(settingsSoundsErrorsSelector)
+ await expect(permissionsSelect).toBeVisible()
+ await expect(errorsSelect).toBeVisible()
+
+ const initial = await page.evaluate((key) => {
+ const raw = localStorage.getItem(key)
+ return raw ? JSON.parse(raw) : null
+ }, settingsKey)
+
+ const permissionsCurrent =
+ (await permissionsSelect.locator('[data-slot="select-select-trigger-value"]').textContent())?.trim() ?? ""
+ await permissionsSelect.locator('[data-slot="select-select-trigger"]').click()
+ const permissionItems = page.locator('[data-slot="select-select-item"]')
+ expect(await permissionItems.count()).toBeGreaterThan(1)
+ if (permissionsCurrent) {
+ await permissionItems.filter({ hasNotText: permissionsCurrent }).first().click()
+ }
+ if (!permissionsCurrent) {
+ await permissionItems.nth(1).click()
+ }
+
+ const errorsCurrent =
+ (await errorsSelect.locator('[data-slot="select-select-trigger-value"]').textContent())?.trim() ?? ""
+ await errorsSelect.locator('[data-slot="select-select-trigger"]').click()
+ const errorItems = page.locator('[data-slot="select-select-item"]')
+ expect(await errorItems.count()).toBeGreaterThan(1)
+ if (errorsCurrent) {
+ await errorItems.filter({ hasNotText: errorsCurrent }).first().click()
+ }
+ if (!errorsCurrent) {
+ await errorItems.nth(1).click()
+ }
+
+ await expect
+ .poll(async () => {
+ return await page.evaluate((key) => {
+ const raw = localStorage.getItem(key)
+ return raw ? JSON.parse(raw) : null
+ }, settingsKey)
+ })
+ .toMatchObject({
+ sounds: {
+ permissions: expect.any(String),
+ errors: expect.any(String),
+ },
+ })
+
+ const stored = await page.evaluate((key) => {
+ const raw = localStorage.getItem(key)
+ return raw ? JSON.parse(raw) : null
+ }, settingsKey)
+
+ expect(stored?.sounds?.permissions).not.toBe(initial?.sounds?.permissions)
+ expect(stored?.sounds?.errors).not.toBe(initial?.sounds?.errors)
+})
+
test("toggling updates startup switch updates localStorage", async ({ page, gotoSession }) => {
await gotoSession()