mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-13 19:46:16 +03:00
test(app): update palette fixture for server projects
This commit is contained in:
@@ -3,26 +3,35 @@ import type { Project } from "@/runtime/server/types"
|
||||
import type { SessionInfo } from "@opencode/client/promise"
|
||||
import { createRoot } from "solid-js"
|
||||
import { createServerSessionEntries } from "@/shell/commands/palette"
|
||||
import type { LocalProject } from "@/shell/state/layout"
|
||||
import { ServerConnection } from "@/runtime/server/registry"
|
||||
import { getProjectAvatarSource } from "@opencode/ui/project-avatar"
|
||||
|
||||
const stored: Project = {
|
||||
const project: Project = {
|
||||
id: "project-1",
|
||||
name: "Palette project",
|
||||
icon: { override: "home-project-avatar" },
|
||||
worktree: "/workspace/project",
|
||||
worktrees: [],
|
||||
sandboxes: [],
|
||||
time: { created: 1, updated: 1 },
|
||||
time: { created: 1, updated: 1, active: 1 },
|
||||
}
|
||||
|
||||
const other: Project = {
|
||||
...project,
|
||||
id: "project-2",
|
||||
name: "Other project",
|
||||
icon: { url: "other-project-avatar" },
|
||||
worktree: "/workspace/other",
|
||||
}
|
||||
|
||||
const session: SessionInfo = {
|
||||
id: "session-1",
|
||||
projectID: stored.id,
|
||||
projectID: project.id,
|
||||
agent: "build",
|
||||
model: { id: "model-1", providerID: "provider-1" },
|
||||
cost: 0,
|
||||
tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
|
||||
location: { directory: stored.worktree },
|
||||
location: { directory: project.worktree },
|
||||
title: "Palette session",
|
||||
time: { created: 1, updated: 2 },
|
||||
}
|
||||
@@ -31,12 +40,6 @@ describe("command palette sessions", () => {
|
||||
test("uses the home project avatar and cancels superseded searches", async () => {
|
||||
const server = ServerConnection.Key.make("selected-server")
|
||||
|
||||
const opened: LocalProject = {
|
||||
...stored,
|
||||
icon: { override: "home-project-avatar" },
|
||||
expanded: true,
|
||||
}
|
||||
|
||||
const searches: string[] = []
|
||||
const gets: string[] = []
|
||||
|
||||
@@ -45,8 +48,7 @@ describe("command palette sessions", () => {
|
||||
createRoot((dispose) => {
|
||||
const search = createServerSessionEntries({
|
||||
server,
|
||||
opened: () => [opened],
|
||||
stored: () => [{ ...stored, icon: { url: "stored-project-avatar" } }],
|
||||
projects: () => [other, project],
|
||||
load: async (text) => {
|
||||
searches.push(text)
|
||||
|
||||
@@ -61,6 +63,7 @@ describe("command palette sessions", () => {
|
||||
},
|
||||
untitled: () => "Untitled",
|
||||
category: () => "Sessions",
|
||||
recentCategory: () => "Recent sessions",
|
||||
})
|
||||
|
||||
const first = search("palette")
|
||||
@@ -83,8 +86,8 @@ describe("command palette sessions", () => {
|
||||
expect(result[0]).toMatchObject({
|
||||
server,
|
||||
sessionID: session.id,
|
||||
description: stored.name,
|
||||
project: { id: stored.id, icon: opened.icon },
|
||||
description: project.name,
|
||||
project: { id: project.id, icon: project.icon },
|
||||
})
|
||||
})
|
||||
|
||||
@@ -97,8 +100,7 @@ describe("command palette sessions", () => {
|
||||
createRoot((dispose) => {
|
||||
const search = createServerSessionEntries({
|
||||
server: ServerConnection.Key.make("selected-server"),
|
||||
opened: () => [],
|
||||
stored: () => [stored],
|
||||
projects: () => [project],
|
||||
load: async () => ({ data: [] }),
|
||||
get: async (sessionID) => {
|
||||
gets.push(sessionID)
|
||||
@@ -107,6 +109,7 @@ describe("command palette sessions", () => {
|
||||
},
|
||||
untitled: () => "Untitled",
|
||||
category: () => "Sessions",
|
||||
recentCategory: () => "Recent sessions",
|
||||
})
|
||||
|
||||
search(exact.id).then(resolve, reject).finally(dispose)
|
||||
|
||||
Reference in New Issue
Block a user