mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-21 20:04:27 +00:00
feat(project): add icon_url_override field to projects (#23955)
This commit is contained in:
@@ -278,6 +278,31 @@ describe("Project.discover", () => {
|
||||
expect(updated).toBeDefined()
|
||||
expect(updated!.icon).toBeUndefined()
|
||||
})
|
||||
|
||||
test("should not discover favicon when override is set", async () => {
|
||||
await using tmp = await tmpdir({ git: true })
|
||||
const { project } = await run((svc) => svc.fromDirectory(tmp.path))
|
||||
|
||||
await run((svc) =>
|
||||
svc.update({
|
||||
projectID: project.id,
|
||||
icon: { override: "data:image/png;base64,override" },
|
||||
}),
|
||||
)
|
||||
|
||||
const updatedProject = await run((svc) => svc.get(project.id))
|
||||
if (!updatedProject) throw new Error("Project not found")
|
||||
|
||||
const pngData = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])
|
||||
await Bun.write(path.join(tmp.path, "favicon.png"), pngData)
|
||||
|
||||
await run((svc) => svc.discover(updatedProject))
|
||||
|
||||
const updated = Project.get(project.id)
|
||||
expect(updated).toBeDefined()
|
||||
expect(updated!.icon?.override).toBe("data:image/png;base64,override")
|
||||
expect(updated!.icon?.url).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe("Project.update", () => {
|
||||
@@ -332,6 +357,23 @@ describe("Project.update", () => {
|
||||
expect(fromDb?.icon?.color).toBe("#ff0000")
|
||||
})
|
||||
|
||||
test("should update icon override", async () => {
|
||||
await using tmp = await tmpdir({ git: true })
|
||||
const { project } = await run((svc) => svc.fromDirectory(tmp.path))
|
||||
|
||||
const updated = await run((svc) =>
|
||||
svc.update({
|
||||
projectID: project.id,
|
||||
icon: { override: "data:image/png;base64,abc123" },
|
||||
}),
|
||||
)
|
||||
|
||||
expect(updated.icon?.override).toBe("data:image/png;base64,abc123")
|
||||
|
||||
const fromDb = Project.get(project.id)
|
||||
expect(fromDb?.icon?.override).toBe("data:image/png;base64,abc123")
|
||||
})
|
||||
|
||||
test("should update commands", async () => {
|
||||
await using tmp = await tmpdir({ git: true })
|
||||
const { project } = await run((svc) => svc.fromDirectory(tmp.path))
|
||||
@@ -389,13 +431,14 @@ describe("Project.update", () => {
|
||||
svc.update({
|
||||
projectID: project.id,
|
||||
name: "Multi Update",
|
||||
icon: { url: "https://example.com/favicon.ico", color: "#00ff00" },
|
||||
icon: { url: "https://example.com/favicon.ico", override: "data:image/png;base64,abc123", color: "#00ff00" },
|
||||
commands: { start: "make start" },
|
||||
}),
|
||||
)
|
||||
|
||||
expect(updated.name).toBe("Multi Update")
|
||||
expect(updated.icon?.url).toBe("https://example.com/favicon.ico")
|
||||
expect(updated.icon?.override).toBe("data:image/png;base64,abc123")
|
||||
expect(updated.icon?.color).toBe("#00ff00")
|
||||
expect(updated.commands?.start).toBe("make start")
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user