summaryrefslogtreecommitdiffhomepage
path: root/packages/app/e2e/settings/settings-models.spec.ts
diff options
context:
space:
mode:
authorFilip <[email protected]>2026-01-31 21:01:21 +0100
committerGitHub <[email protected]>2026-01-31 14:01:21 -0600
commit33252a65b408ddec45bcd063c535c2170ce413c6 (patch)
tree46c340bf6f5b852ba49b0add37ef09b66af5abfe /packages/app/e2e/settings/settings-models.spec.ts
parente70d984320571597f89421d85c2f74009951027c (diff)
downloadopencode-33252a65b408ddec45bcd063c535c2170ce413c6.tar.gz
opencode-33252a65b408ddec45bcd063c535c2170ce413c6.zip
test(app): general settings, shortcuts, providers and status popover (#11517)
Diffstat (limited to 'packages/app/e2e/settings/settings-models.spec.ts')
-rw-r--r--packages/app/e2e/settings/settings-models.spec.ts122
1 files changed, 122 insertions, 0 deletions
diff --git a/packages/app/e2e/settings/settings-models.spec.ts b/packages/app/e2e/settings/settings-models.spec.ts
new file mode 100644
index 000000000..f7397abe8
--- /dev/null
+++ b/packages/app/e2e/settings/settings-models.spec.ts
@@ -0,0 +1,122 @@
+import { test, expect } from "../fixtures"
+import { promptSelector } from "../selectors"
+import { closeDialog, openSettings } from "../actions"
+
+test("hiding a model removes it from the model picker", async ({ page, gotoSession }) => {
+ await gotoSession()
+
+ await page.locator(promptSelector).click()
+ await page.keyboard.type("/model")
+
+ const command = page.locator('[data-slash-id="model.choose"]')
+ await expect(command).toBeVisible()
+ await command.hover()
+ await page.keyboard.press("Enter")
+
+ const picker = page.getByRole("dialog")
+ await expect(picker).toBeVisible()
+
+ const target = picker.locator('[data-slot="list-item"]').first()
+ await expect(target).toBeVisible()
+
+ const key = await target.getAttribute("data-key")
+ if (!key) throw new Error("Failed to resolve model key from list item")
+
+ const name = (await target.locator("span").first().innerText()).trim()
+ if (!name) throw new Error("Failed to resolve model name from list item")
+
+ await page.keyboard.press("Escape")
+ await expect(picker).toHaveCount(0)
+
+ const settings = await openSettings(page)
+
+ await settings.getByRole("tab", { name: "Models" }).click()
+ const search = settings.getByPlaceholder("Search models")
+ await expect(search).toBeVisible()
+ await search.fill(name)
+
+ const toggle = settings.locator('[data-component="switch"]').filter({ hasText: name }).first()
+ const input = toggle.locator('[data-slot="switch-input"]')
+ await expect(toggle).toBeVisible()
+ await expect(input).toHaveAttribute("aria-checked", "true")
+ await toggle.locator('[data-slot="switch-control"]').click()
+ await expect(input).toHaveAttribute("aria-checked", "false")
+
+ await closeDialog(page, settings)
+
+ await page.locator(promptSelector).click()
+ await page.keyboard.type("/model")
+ await expect(command).toBeVisible()
+ await command.hover()
+ await page.keyboard.press("Enter")
+
+ const pickerAgain = page.getByRole("dialog")
+ await expect(pickerAgain).toBeVisible()
+ await expect(pickerAgain.locator('[data-slot="list-item"]').first()).toBeVisible()
+
+ await expect(pickerAgain.locator(`[data-slot="list-item"][data-key="${key}"]`)).toHaveCount(0)
+
+ await page.keyboard.press("Escape")
+ await expect(pickerAgain).toHaveCount(0)
+})
+
+test("showing a hidden model restores it to the model picker", async ({ page, gotoSession }) => {
+ await gotoSession()
+
+ await page.locator(promptSelector).click()
+ await page.keyboard.type("/model")
+
+ const command = page.locator('[data-slash-id="model.choose"]')
+ await expect(command).toBeVisible()
+ await command.hover()
+ await page.keyboard.press("Enter")
+
+ const picker = page.getByRole("dialog")
+ await expect(picker).toBeVisible()
+
+ const target = picker.locator('[data-slot="list-item"]').first()
+ await expect(target).toBeVisible()
+
+ const key = await target.getAttribute("data-key")
+ if (!key) throw new Error("Failed to resolve model key from list item")
+
+ const name = (await target.locator("span").first().innerText()).trim()
+ if (!name) throw new Error("Failed to resolve model name from list item")
+
+ await page.keyboard.press("Escape")
+ await expect(picker).toHaveCount(0)
+
+ const settings = await openSettings(page)
+
+ await settings.getByRole("tab", { name: "Models" }).click()
+ const search = settings.getByPlaceholder("Search models")
+ await expect(search).toBeVisible()
+ await search.fill(name)
+
+ const toggle = settings.locator('[data-component="switch"]').filter({ hasText: name }).first()
+ const input = toggle.locator('[data-slot="switch-input"]')
+ await expect(toggle).toBeVisible()
+ await expect(input).toHaveAttribute("aria-checked", "true")
+
+ await toggle.locator('[data-slot="switch-control"]').click()
+ await expect(input).toHaveAttribute("aria-checked", "false")
+
+ await toggle.locator('[data-slot="switch-control"]').click()
+ await expect(input).toHaveAttribute("aria-checked", "true")
+
+ await closeDialog(page, settings)
+
+ await page.locator(promptSelector).click()
+ await page.keyboard.type("/model")
+ await expect(command).toBeVisible()
+ await command.hover()
+ await page.keyboard.press("Enter")
+
+ const pickerAgain = page.getByRole("dialog")
+ await expect(pickerAgain).toBeVisible()
+
+ await expect(pickerAgain.locator(`[data-slot="list-item"][data-key="${key}"]`)).toBeVisible()
+
+ await page.keyboard.press("Escape")
+ await expect(pickerAgain).toHaveCount(0)
+})