Spaces:
Sleeping
Sleeping
File size: 3,141 Bytes
05c5ed5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | import { test, expect } from "@playwright/test";
test.describe("Model Selection", () => {
test.use({ storageState: "tests/.auth/admin.json" });
test("should persist selected model", async ({ page }) => {
await page.goto("/");
await page.waitForLoadState("networkidle");
// Verify that a model is selected (either from setup or default)
await expect(page.getByTestId("selected-model-name")).toBeVisible();
// Get the current model name
const modelName = await page
.getByTestId("selected-model-name")
.textContent();
expect(modelName).toBeTruthy();
// Refresh the page and verify the model persists
await page.reload();
await page.waitForLoadState("networkidle");
const modelNameAfterRefresh = await page
.getByTestId("selected-model-name")
.textContent();
expect(modelNameAfterRefresh).toBe(modelName);
});
test("should change model selection", async ({ page }) => {
await page.goto("/");
await page.waitForLoadState("networkidle");
// Get the current model
const currentModel = await page
.getByTestId("selected-model-name")
.textContent();
// Open model selector
await page.getByTestId("model-selector-button").click();
// Wait for popover to open
await expect(page.getByTestId("model-selector-popover")).toBeVisible();
// Find all model options and log them
const modelOptions = page.locator('[data-testid^="model-option-"]');
const optionCount = await modelOptions.count();
// Should have multiple models available
expect(optionCount).toBeGreaterThan(1);
// Find the first model option that doesn't have the selected-model-check icon
const selectedOption = page
.locator(
'[data-testid^="model-option-"]:not(:has([data-testid="selected-model-check"]))',
)
.first();
// Should have at least one unselected option
await expect(selectedOption).toBeVisible();
// Click on the unselected option
await selectedOption.click();
// Wait a moment for the change to take effect
await page.waitForTimeout(1000);
// Wait for popover to close
await expect(page.getByTestId("model-selector-popover")).not.toBeVisible();
// Verify the model changed
const newModel = await page
.getByTestId("selected-model-name")
.textContent();
expect(newModel).not.toBe(currentModel);
expect(newModel).toBeTruthy();
});
test("should use selected model in agent creation", async ({ page }) => {
await page.goto("/agent/new");
await page.waitForLoadState("networkidle");
await expect(page.getByTestId("agent-save-button")).toBeEnabled({
timeout: 10000,
});
// Check if Generate With AI button is available (requires valid model)
const generateButton = page.locator('button:has-text("Generate With AI")');
await expect(generateButton).toBeVisible();
await generateButton.click();
// The selected model should be available
const modelName = await page
.getByTestId("selected-model-name")
.textContent();
expect(modelName).toBeTruthy();
});
});
|