|
| 1 | +import { expect, test } from "@playwright/test" |
| 2 | +import { base64Encode } from "@opencode-ai/core/util/encode" |
| 3 | +import { mockOpenCodeServer } from "../utils/mock-server" |
| 4 | +import { expectAppVisible } from "../utils/waits" |
| 5 | + |
| 6 | +// Regression for #43295: on a narrow viewport the V2 composer's agent / model / variant controls used to run under |
| 7 | +// the send button. The controls must stay inside the composer and clear of the button; long labels ellipsize. |
| 8 | +const directory = "C:/OpenCode/PromptControlsNarrowRegression" |
| 9 | +const projectID = "proj_prompt_controls_narrow_regression" |
| 10 | +const sessionID = "ses_prompt_controls_narrow_regression" |
| 11 | + |
| 12 | +test("keeps the V2 prompt controls clear of the send button on a narrow viewport", async ({ page }) => { |
| 13 | + await page.setViewportSize({ width: 320, height: 800 }) |
| 14 | + await mockOpenCodeServer(page, { |
| 15 | + directory, |
| 16 | + project: { |
| 17 | + id: projectID, |
| 18 | + worktree: directory, |
| 19 | + vcs: "git", |
| 20 | + name: "prompt-controls-narrow-regression", |
| 21 | + time: { created: 1700000000000, updated: 1700000000000 }, |
| 22 | + sandboxes: [], |
| 23 | + }, |
| 24 | + provider: { |
| 25 | + all: [ |
| 26 | + { |
| 27 | + id: "opencode", |
| 28 | + name: "OpenCode", |
| 29 | + models: { |
| 30 | + "long-name-model": { |
| 31 | + id: "long-name-model", |
| 32 | + name: "A Deliberately Long Model Display Name For Narrow Layouts", |
| 33 | + limit: { context: 200_000 }, |
| 34 | + variants: { high: {} }, |
| 35 | + }, |
| 36 | + }, |
| 37 | + }, |
| 38 | + ], |
| 39 | + connected: ["opencode"], |
| 40 | + default: { providerID: "opencode", modelID: "long-name-model" }, |
| 41 | + }, |
| 42 | + sessions: [ |
| 43 | + { |
| 44 | + id: sessionID, |
| 45 | + slug: "prompt-controls-narrow-regression", |
| 46 | + projectID, |
| 47 | + directory, |
| 48 | + title: "Prompt controls narrow regression", |
| 49 | + version: "dev", |
| 50 | + time: { created: 1700000000000, updated: 1700000000000 }, |
| 51 | + }, |
| 52 | + ], |
| 53 | + pageMessages: () => ({ items: [] }), |
| 54 | + }) |
| 55 | + await page.addInitScript(() => { |
| 56 | + localStorage.setItem("settings.v3", JSON.stringify({ general: { newLayoutDesigns: true } })) |
| 57 | + }) |
| 58 | + |
| 59 | + await page.goto(`/${base64Encode(directory)}/session/${sessionID}`) |
| 60 | + const composer = page.locator('[data-component="prompt-input-v2"]') |
| 61 | + await expectAppVisible(composer) |
| 62 | + |
| 63 | + const controls = composer.locator('[data-slot="prompt-controls"]') |
| 64 | + const submit = composer.locator('[data-action="prompt-submit"]') |
| 65 | + const model = composer.locator('[data-action="prompt-model"]') |
| 66 | + const variant = composer.getByRole("button", { name: "Choose model variant" }) |
| 67 | + await expect(submit).toBeVisible() |
| 68 | + await expect(model).toBeVisible() |
| 69 | + await expect(variant).toBeVisible() |
| 70 | + |
| 71 | + const [controlsBox, submitBox, modelBox, variantBox] = await Promise.all([ |
| 72 | + controls.boundingBox(), |
| 73 | + submit.boundingBox(), |
| 74 | + model.boundingBox(), |
| 75 | + variant.boundingBox(), |
| 76 | + ]) |
| 77 | + expect(controlsBox).not.toBeNull() |
| 78 | + expect(submitBox).not.toBeNull() |
| 79 | + expect(modelBox).not.toBeNull() |
| 80 | + expect(variantBox).not.toBeNull() |
| 81 | + |
| 82 | + // the whole controls row ends where the send button starts, and nothing pokes past the viewport |
| 83 | + expect(controlsBox!.x + controlsBox!.width).toBeLessThanOrEqual(submitBox!.x + 1) |
| 84 | + expect(variantBox!.x + variantBox!.width).toBeLessThanOrEqual(submitBox!.x + 1) |
| 85 | + expect(modelBox!.x + modelBox!.width).toBeLessThanOrEqual(submitBox!.x + 1) |
| 86 | + expect(submitBox!.x + submitBox!.width).toBeLessThanOrEqual(320) |
| 87 | +}) |
0 commit comments