2025-12-14 21:26:49 +00:00
|
|
|
import { expect, test } from "@playwright/test";
|
|
|
|
|
|
2026-03-20 09:37:02 +00:00
|
|
|
const MODEL_BUTTON_REGEX = /Kimi|Codestral|Mistral|DeepSeek|GPT|Grok/i;
|
2025-12-14 21:26:49 +00:00
|
|
|
|
2025-12-15 14:43:39 +00:00
|
|
|
test.describe("Model Selector", () => {
|
2025-12-14 21:26:49 +00:00
|
|
|
test.beforeEach(async ({ page }) => {
|
2025-12-15 14:43:39 +00:00
|
|
|
await page.goto("/");
|
2025-12-14 21:26:49 +00:00
|
|
|
});
|
|
|
|
|
|
2025-12-15 14:43:39 +00:00
|
|
|
test("displays a model button", async ({ page }) => {
|
2026-01-15 16:06:42 +00:00
|
|
|
const modelButton = page
|
|
|
|
|
.locator("button")
|
|
|
|
|
.filter({ hasText: MODEL_BUTTON_REGEX })
|
|
|
|
|
.first();
|
2025-12-14 21:26:49 +00:00
|
|
|
await expect(modelButton).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-15 14:43:39 +00:00
|
|
|
test("opens model selector popover on click", async ({ page }) => {
|
2026-01-15 16:06:42 +00:00
|
|
|
const modelButton = page
|
|
|
|
|
.locator("button")
|
|
|
|
|
.filter({ hasText: MODEL_BUTTON_REGEX })
|
|
|
|
|
.first();
|
2025-12-14 21:26:49 +00:00
|
|
|
await modelButton.click();
|
2025-12-15 14:43:39 +00:00
|
|
|
|
2025-12-14 21:26:49 +00:00
|
|
|
await expect(page.getByPlaceholder("Search models...")).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("can search for models", async ({ page }) => {
|
2026-01-15 16:06:42 +00:00
|
|
|
const modelButton = page
|
|
|
|
|
.locator("button")
|
|
|
|
|
.filter({ hasText: MODEL_BUTTON_REGEX })
|
|
|
|
|
.first();
|
2025-12-15 14:43:39 +00:00
|
|
|
await modelButton.click();
|
|
|
|
|
|
|
|
|
|
const searchInput = page.getByPlaceholder("Search models...");
|
2026-03-20 09:37:02 +00:00
|
|
|
await searchInput.fill("Mistral");
|
2025-12-15 14:43:39 +00:00
|
|
|
|
2026-03-20 09:37:02 +00:00
|
|
|
await expect(page.getByText("Mistral Small").first()).toBeVisible();
|
2025-12-15 14:43:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("can close model selector by clicking outside", async ({ page }) => {
|
2026-01-15 16:06:42 +00:00
|
|
|
const modelButton = page
|
|
|
|
|
.locator("button")
|
|
|
|
|
.filter({ hasText: MODEL_BUTTON_REGEX })
|
|
|
|
|
.first();
|
2025-12-15 14:43:39 +00:00
|
|
|
await modelButton.click();
|
|
|
|
|
|
|
|
|
|
await expect(page.getByPlaceholder("Search models...")).toBeVisible();
|
|
|
|
|
|
|
|
|
|
await page.keyboard.press("Escape");
|
|
|
|
|
|
|
|
|
|
await expect(page.getByPlaceholder("Search models...")).not.toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("shows model provider groups", async ({ page }) => {
|
2026-01-15 16:06:42 +00:00
|
|
|
const modelButton = page
|
|
|
|
|
.locator("button")
|
|
|
|
|
.filter({ hasText: MODEL_BUTTON_REGEX })
|
|
|
|
|
.first();
|
2025-12-14 21:26:49 +00:00
|
|
|
await modelButton.click();
|
2025-12-15 14:43:39 +00:00
|
|
|
|
2026-03-20 09:37:02 +00:00
|
|
|
await expect(page.getByText("Mistral")).toBeVisible();
|
|
|
|
|
await expect(page.getByText("Moonshot")).toBeVisible();
|
2025-12-14 21:26:49 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("can select a different model", async ({ page }) => {
|
2026-01-15 16:06:42 +00:00
|
|
|
const modelButton = page
|
|
|
|
|
.locator("button")
|
|
|
|
|
.filter({ hasText: MODEL_BUTTON_REGEX })
|
|
|
|
|
.first();
|
2025-12-14 21:26:49 +00:00
|
|
|
await modelButton.click();
|
|
|
|
|
|
2026-03-20 09:37:02 +00:00
|
|
|
await page.getByText("Mistral Small").first().click();
|
2025-12-14 21:26:49 +00:00
|
|
|
|
2025-12-15 14:43:39 +00:00
|
|
|
await expect(page.getByPlaceholder("Search models...")).not.toBeVisible();
|
|
|
|
|
|
2026-01-15 16:06:42 +00:00
|
|
|
await expect(
|
2026-03-20 09:37:02 +00:00
|
|
|
page.locator("button").filter({ hasText: "Mistral Small" }).first()
|
2026-01-15 16:06:42 +00:00
|
|
|
).toBeVisible();
|
2025-12-14 21:26:49 +00:00
|
|
|
});
|
|
|
|
|
});
|