summaryrefslogtreecommitdiffhomepage
path: root/packages/app/e2e/models
diff options
context:
space:
mode:
authorFilip <[email protected]>2026-01-30 19:04:02 +0100
committerGitHub <[email protected]>2026-01-30 18:04:02 +0000
commitf48e2e56c95a7b96648176f1f783929dc4f33b37 (patch)
tree106a32d8955e3ec5f10b80d1d6dbbae01d22626a /packages/app/e2e/models
parentfe66ca163cbb9d689cf296c4c2f7a63414c1cf45 (diff)
downloadopencode-f48e2e56c95a7b96648176f1f783929dc4f33b37.tar.gz
opencode-f48e2e56c95a7b96648176f1f783929dc4f33b37.zip
test(app): change language test (#11295)
Diffstat (limited to 'packages/app/e2e/models')
-rw-r--r--packages/app/e2e/models/model-picker.spec.ts43
-rw-r--r--packages/app/e2e/models/models-visibility.spec.ts86
2 files changed, 129 insertions, 0 deletions
diff --git a/packages/app/e2e/models/model-picker.spec.ts b/packages/app/e2e/models/model-picker.spec.ts
new file mode 100644
index 000000000..a0c70aabe
--- /dev/null
+++ b/packages/app/e2e/models/model-picker.spec.ts
@@ -0,0 +1,43 @@
+import { test, expect } from "../fixtures"
+import { promptSelector } from "../utils"
+
+test("smoke model selection updates prompt footer", 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 dialog = page.getByRole("dialog")
+ await expect(dialog).toBeVisible()
+
+ const input = dialog.getByRole("textbox").first()
+
+ const selected = dialog.locator('[data-slot="list-item"][data-selected="true"]').first()
+ await expect(selected).toBeVisible()
+
+ const other = dialog.locator('[data-slot="list-item"]:not([data-selected="true"])').first()
+ const target = (await other.count()) > 0 ? other : selected
+
+ 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()
+ const model = key.split(":").slice(1).join(":")
+
+ await input.fill(model)
+
+ const item = dialog.locator(`[data-slot="list-item"][data-key="${key}"]`)
+ await expect(item).toBeVisible()
+ await item.click()
+
+ await expect(dialog).toHaveCount(0)
+
+ const form = page.locator(promptSelector).locator("xpath=ancestor::form[1]")
+ await expect(form.locator('[data-component="button"]').filter({ hasText: name }).first()).toBeVisible()
+})
diff --git a/packages/app/e2e/models/models-visibility.spec.ts b/packages/app/e2e/models/models-visibility.spec.ts
new file mode 100644
index 000000000..0db7580c2
--- /dev/null
+++ b/packages/app/e2e/models/models-visibility.spec.ts
@@ -0,0 +1,86 @@
+import { test, expect } from "../fixtures"
+import { modKey, promptSelector } from "../utils"
+
+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 = page.getByRole("dialog")
+
+ await page.keyboard.press(`${modKey}+Comma`).catch(() => undefined)
+ const opened = await settings
+ .waitFor({ state: "visible", timeout: 3000 })
+ .then(() => true)
+ .catch(() => false)
+
+ if (!opened) {
+ await page.getByRole("button", { name: "Settings" }).first().click()
+ await expect(settings).toBeVisible()
+ }
+
+ 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 page.keyboard.press("Escape")
+ const closed = await settings
+ .waitFor({ state: "detached", timeout: 1500 })
+ .then(() => true)
+ .catch(() => false)
+ if (!closed) {
+ await page.keyboard.press("Escape")
+ const closedSecond = await settings
+ .waitFor({ state: "detached", timeout: 1500 })
+ .then(() => true)
+ .catch(() => false)
+ if (!closedSecond) {
+ await page.locator('[data-component="dialog-overlay"]').click({ position: { x: 5, y: 5 } })
+ await expect(settings).toHaveCount(0)
+ }
+ }
+
+ 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)
+})