mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-24 04:01:10 -04:00
9e0d3976e1
Co-authored-by: Frank <frank@anoma.ly> Co-authored-by: Aarav Sareen <96787824+arvsrn@users.noreply.github.com> Co-authored-by: Brendan Allan <git@brendonovich.dev> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Jack <jack@anoma.ly> Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com> Co-authored-by: Shoubhit Dash <shoubhit2005@gmail.com> Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com> Co-authored-by: James Long <longster@gmail.com> Co-authored-by: Dustin Deus <deusdustin@gmail.com> Co-authored-by: starptech <starptech@starptechs-MBP.fritz.box> Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com> Co-authored-by: 𝓛𝓲𝓽𝓽𝓵𝓮 𝓕𝓻𝓪𝓷𝓴 <little-frank@opencord.local> Co-authored-by: Dax <mail@thdxr.com> Co-authored-by: usrnk1 <7547651+usrnk1@users.noreply.github.com> Co-authored-by: Jay <53023+jayair@users.noreply.github.com> Co-authored-by: runvip <164729189+runvip@users.noreply.github.com> Co-authored-by: opencode <opencode@sst.dev> Co-authored-by: Julian Coy <julian@ex-machina.co> Co-authored-by: Vladimir Glafirov <vglafirov@gitlab.com> Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com> Co-authored-by: Kit Langton <kit.langton@gmail.com> Co-authored-by: Simon Klee <hello@simonklee.dk> Co-authored-by: Jay <air@live.ca> Co-authored-by: David Hill <1879069+iamdavidhill@users.noreply.github.com>
84 lines
3.2 KiB
TypeScript
84 lines
3.2 KiB
TypeScript
import { expect, test } from "@playwright/test"
|
|
import { mockOpenCodeServer } from "../utils/mock-server"
|
|
import { expectAppVisible } from "../utils/waits"
|
|
|
|
const draftID = "draft_new_session_panel_corner"
|
|
const directory = "C:/OpenCode/NewSessionPanelCorner"
|
|
const server = `http://${process.env.PLAYWRIGHT_SERVER_HOST ?? "127.0.0.1"}:${process.env.PLAYWRIGHT_SERVER_PORT ?? "4096"}`
|
|
|
|
test.use({
|
|
viewport: { width: 935, height: 522 },
|
|
deviceScaleFactor: 1,
|
|
})
|
|
|
|
test("matches the rounded panel corners to the dark new-session background", async ({ page }, testInfo) => {
|
|
await mockOpenCodeServer(page, {
|
|
directory,
|
|
project: {
|
|
id: "proj_new_session_panel_corner",
|
|
worktree: directory,
|
|
vcs: "git",
|
|
name: "new-session-panel-corner",
|
|
time: { created: 1700000000000, updated: 1700000000000 },
|
|
sandboxes: [],
|
|
},
|
|
provider: { all: [], connected: [], default: {} },
|
|
sessions: [],
|
|
pageMessages: () => ({ items: [] }),
|
|
})
|
|
await page.addInitScript(
|
|
({ directory, draftID, server }) => {
|
|
localStorage.setItem("settings.v3", JSON.stringify({ general: { newLayoutDesigns: true } }))
|
|
localStorage.setItem("opencode-theme-id", "oc-2")
|
|
localStorage.setItem("opencode-color-scheme", "dark")
|
|
localStorage.setItem(
|
|
"opencode.global.dat:server",
|
|
JSON.stringify({
|
|
projects: { local: [{ worktree: directory, expanded: true }] },
|
|
lastProject: { local: directory },
|
|
}),
|
|
)
|
|
localStorage.setItem(
|
|
"opencode.window.browser.dat:tabs",
|
|
JSON.stringify([{ type: "draft", draftID, server, directory }]),
|
|
)
|
|
},
|
|
{ directory, draftID, server },
|
|
)
|
|
|
|
await page.goto(`/new-session?draftId=${draftID}`)
|
|
await expectAppVisible(page.locator('[data-component="prompt-input"]'))
|
|
await expect(page.locator("html")).toHaveAttribute("data-color-scheme", "dark")
|
|
const panel = page.locator('main div[class*="rounded-[10px]"][class*="overflow-hidden"]')
|
|
await expect(panel).toHaveCount(1)
|
|
const box = await panel.boundingBox()
|
|
if (!box) throw new Error("New-session panel bounds are unavailable")
|
|
|
|
const screenshot = await page.screenshot({ path: testInfo.outputPath("new-session-dark.png") })
|
|
const corners = await page.evaluate(
|
|
async ({ source, points }) => {
|
|
const image = new Image()
|
|
image.src = source
|
|
await image.decode()
|
|
const canvas = document.createElement("canvas")
|
|
canvas.width = image.naturalWidth
|
|
canvas.height = image.naturalHeight
|
|
const context = canvas.getContext("2d")
|
|
if (!context) throw new Error("2D canvas is unavailable")
|
|
context.drawImage(image, 0, 0)
|
|
return points.map((point) => Array.from(context.getImageData(point.x, point.y, 1, 1).data))
|
|
},
|
|
{
|
|
source: `data:image/png;base64,${screenshot.toString("base64")}`,
|
|
points: [
|
|
{ x: Math.floor(box.x), y: Math.floor(box.y) },
|
|
{ x: Math.ceil(box.x + box.width) - 1, y: Math.floor(box.y) },
|
|
{ x: Math.floor(box.x), y: Math.ceil(box.y + box.height) - 1 },
|
|
{ x: Math.ceil(box.x + box.width) - 1, y: Math.ceil(box.y + box.height) - 1 },
|
|
],
|
|
},
|
|
)
|
|
|
|
expect(corners.every(([red, green, blue, alpha]) => red <= 8 && green <= 8 && blue <= 8 && alpha === 255)).toBe(true)
|
|
})
|