test(agents): cover default-agent sort shim ordering
This commit is contained in:
@@ -3,6 +3,12 @@
|
|||||||
import { beforeAll, describe, expect, test } from "bun:test"
|
import { beforeAll, describe, expect, test } from "bun:test"
|
||||||
|
|
||||||
import { installAgentSortShim } from "./agent-sort-shim"
|
import { installAgentSortShim } from "./agent-sort-shim"
|
||||||
|
import { AGENT_DISPLAY_NAMES } from "./agent-display-names"
|
||||||
|
|
||||||
|
type AgentListItem = {
|
||||||
|
name: string
|
||||||
|
default_agent?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
describe("agent-sort-shim", () => {
|
describe("agent-sort-shim", () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
@@ -49,6 +55,32 @@ describe("agent-sort-shim", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("#given OpenCode Agent.list style sort with default agent priority", () => {
|
||||||
|
describe("#when toSorted compares default_agent first and then name", () => {
|
||||||
|
test("#then core agents stay in canonical order before non-core agents", () => {
|
||||||
|
// given
|
||||||
|
const sisyphus = { name: AGENT_DISPLAY_NAMES.sisyphus, default_agent: true }
|
||||||
|
const hephaestus = { name: AGENT_DISPLAY_NAMES.hephaestus }
|
||||||
|
const prometheus = { name: AGENT_DISPLAY_NAMES.prometheus }
|
||||||
|
const atlas = { name: AGENT_DISPLAY_NAMES.atlas }
|
||||||
|
const oracle = { name: AGENT_DISPLAY_NAMES.oracle }
|
||||||
|
const explore = { name: AGENT_DISPLAY_NAMES.explore }
|
||||||
|
const input: AgentListItem[] = [oracle, atlas, explore, prometheus, hephaestus, sisyphus]
|
||||||
|
|
||||||
|
// when
|
||||||
|
const result = input.toSorted((left, right) => {
|
||||||
|
const leftDefault = left.default_agent ? 1 : 0
|
||||||
|
const rightDefault = right.default_agent ? 1 : 0
|
||||||
|
if (leftDefault !== rightDefault) return rightDefault - leftDefault
|
||||||
|
return left.name.localeCompare(right.name)
|
||||||
|
})
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(result).toEqual([sisyphus, hephaestus, prometheus, atlas, explore, oracle])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("#given an array with only one core agent and several non-core agent-like objects", () => {
|
describe("#given an array with only one core agent and several non-core agent-like objects", () => {
|
||||||
describe("#when toSorted with case-sensitive string-comparison compareFn", () => {
|
describe("#when toSorted with case-sensitive string-comparison compareFn", () => {
|
||||||
test("#then activation predicate fails and result is ASCII-sensitive order with capital S before lowercase letters", () => {
|
test("#then activation predicate fails and result is ASCII-sensitive order with capital S before lowercase letters", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user