test(prompts-core): cover variant resolution scenarios
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -0,0 +1,113 @@
|
|||||||
|
bun test v1.3.12 (700fc117)
|
||||||
|
|
||||||
|
packages/prompts-core/src/variant-resolver.test.ts:
|
||||||
|
S1 actual: __red__
|
||||||
|
27 | // when
|
||||||
|
28 | const actual = resolveVariant({ modelID: "claude-opus-4-7", variants })
|
||||||
|
29 |
|
||||||
|
30 | // then
|
||||||
|
31 | console.info("S1 actual:", actual)
|
||||||
|
32 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:32:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when claude opus has no model match #then returns default fallback [0.39ms]
|
||||||
|
S2 actual: __red__
|
||||||
|
43 | // when
|
||||||
|
44 | const actual = resolveVariant({ modelID: "openai/gpt-5.5", variants })
|
||||||
|
45 |
|
||||||
|
46 | // then
|
||||||
|
47 | console.info("S2 actual:", actual)
|
||||||
|
48 | expect(actual).toBe("gpt")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gpt"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:48:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when openai gpt model matches #then returns gpt [0.10ms]
|
||||||
|
S3 actual: __red__
|
||||||
|
59 | // when
|
||||||
|
60 | const actual = resolveVariant({ modelID: "google/gemini-3-1-pro", variants })
|
||||||
|
61 |
|
||||||
|
62 | // then
|
||||||
|
63 | console.info("S3 actual:", actual)
|
||||||
|
64 | expect(actual).toBe("gemini")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gemini"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:64:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when google gemini model matches #then returns gemini [0.04ms]
|
||||||
|
S4 actual: __red__
|
||||||
|
80 | variants,
|
||||||
|
81 | })
|
||||||
|
82 |
|
||||||
|
83 | // then
|
||||||
|
84 | console.info("S4 actual:", actual)
|
||||||
|
85 | expect(actual).toBe("planner")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "planner"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:85:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when agent and model both match #then declared agent variant wins [0.12ms]
|
||||||
|
S5 actual: __red__
|
||||||
|
94 | // when
|
||||||
|
95 | const actual = resolveVariant({ variants })
|
||||||
|
96 |
|
||||||
|
97 | // then
|
||||||
|
98 | console.info("S5 actual:", actual)
|
||||||
|
99 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:99:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no context is provided #then returns default fallback [0.08ms]
|
||||||
|
S6 actual: __red__
|
||||||
|
109 | // when
|
||||||
|
110 | const actual = resolveVariant({ modelID: "unknown-model", variants })
|
||||||
|
111 |
|
||||||
|
112 | // then
|
||||||
|
113 | console.info("S6 actual:", actual)
|
||||||
|
114 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:114:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant test matches #then returns fallback [0.07ms]
|
||||||
|
S7 actual: __red__
|
||||||
|
134 | }
|
||||||
|
135 | }
|
||||||
|
136 | console.info("S7 actual:", actual)
|
||||||
|
137 |
|
||||||
|
138 | // then
|
||||||
|
139 | expect(thrown).toBeInstanceOf(NoMatchingVariantError)
|
||||||
|
^
|
||||||
|
error: expect(received).toBeInstanceOf(expected)
|
||||||
|
|
||||||
|
Expected constructor: [class NoMatchingVariantError extends Error]
|
||||||
|
Received value: undefined
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:139:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant matches and no fallback exists #then throws [0.09ms]
|
||||||
|
|
||||||
|
0 pass
|
||||||
|
7 fail
|
||||||
|
7 expect() calls
|
||||||
|
Ran 7 tests across 1 file. [74.00ms]
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
bun test v1.3.12 (700fc117)
|
||||||
|
|
||||||
|
packages/prompts-core/src/variant-resolver.test.ts:
|
||||||
|
S1 actual: __red__
|
||||||
|
27 | // when
|
||||||
|
28 | const actual = resolveVariant({ modelID: "claude-opus-4-7", variants })
|
||||||
|
29 |
|
||||||
|
30 | // then
|
||||||
|
31 | console.info("S1 actual:", actual)
|
||||||
|
32 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:32:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when claude opus has no model match #then returns default fallback [0.39ms]
|
||||||
|
S2 actual: __red__
|
||||||
|
43 | // when
|
||||||
|
44 | const actual = resolveVariant({ modelID: "openai/gpt-5.5", variants })
|
||||||
|
45 |
|
||||||
|
46 | // then
|
||||||
|
47 | console.info("S2 actual:", actual)
|
||||||
|
48 | expect(actual).toBe("gpt")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gpt"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:48:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when openai gpt model matches #then returns gpt [0.10ms]
|
||||||
|
S3 actual: __red__
|
||||||
|
59 | // when
|
||||||
|
60 | const actual = resolveVariant({ modelID: "google/gemini-3-1-pro", variants })
|
||||||
|
61 |
|
||||||
|
62 | // then
|
||||||
|
63 | console.info("S3 actual:", actual)
|
||||||
|
64 | expect(actual).toBe("gemini")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gemini"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:64:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when google gemini model matches #then returns gemini [0.04ms]
|
||||||
|
S4 actual: __red__
|
||||||
|
80 | variants,
|
||||||
|
81 | })
|
||||||
|
82 |
|
||||||
|
83 | // then
|
||||||
|
84 | console.info("S4 actual:", actual)
|
||||||
|
85 | expect(actual).toBe("planner")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "planner"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:85:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when agent and model both match #then declared agent variant wins [0.12ms]
|
||||||
|
S5 actual: __red__
|
||||||
|
94 | // when
|
||||||
|
95 | const actual = resolveVariant({ variants })
|
||||||
|
96 |
|
||||||
|
97 | // then
|
||||||
|
98 | console.info("S5 actual:", actual)
|
||||||
|
99 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:99:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no context is provided #then returns default fallback [0.08ms]
|
||||||
|
S6 actual: __red__
|
||||||
|
109 | // when
|
||||||
|
110 | const actual = resolveVariant({ modelID: "unknown-model", variants })
|
||||||
|
111 |
|
||||||
|
112 | // then
|
||||||
|
113 | console.info("S6 actual:", actual)
|
||||||
|
114 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:114:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant test matches #then returns fallback [0.07ms]
|
||||||
|
S7 actual: __red__
|
||||||
|
134 | }
|
||||||
|
135 | }
|
||||||
|
136 | console.info("S7 actual:", actual)
|
||||||
|
137 |
|
||||||
|
138 | // then
|
||||||
|
139 | expect(thrown).toBeInstanceOf(NoMatchingVariantError)
|
||||||
|
^
|
||||||
|
error: expect(received).toBeInstanceOf(expected)
|
||||||
|
|
||||||
|
Expected constructor: [class NoMatchingVariantError extends Error]
|
||||||
|
Received value: undefined
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:139:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant matches and no fallback exists #then throws [0.09ms]
|
||||||
|
|
||||||
|
0 pass
|
||||||
|
7 fail
|
||||||
|
7 expect() calls
|
||||||
|
Ran 7 tests across 1 file. [74.00ms]
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
bun test v1.3.12 (700fc117)
|
||||||
|
|
||||||
|
packages/prompts-core/src/variant-resolver.test.ts:
|
||||||
|
S1 actual: __red__
|
||||||
|
27 | // when
|
||||||
|
28 | const actual = resolveVariant({ modelID: "claude-opus-4-7", variants })
|
||||||
|
29 |
|
||||||
|
30 | // then
|
||||||
|
31 | console.info("S1 actual:", actual)
|
||||||
|
32 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:32:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when claude opus has no model match #then returns default fallback [0.39ms]
|
||||||
|
S2 actual: __red__
|
||||||
|
43 | // when
|
||||||
|
44 | const actual = resolveVariant({ modelID: "openai/gpt-5.5", variants })
|
||||||
|
45 |
|
||||||
|
46 | // then
|
||||||
|
47 | console.info("S2 actual:", actual)
|
||||||
|
48 | expect(actual).toBe("gpt")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gpt"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:48:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when openai gpt model matches #then returns gpt [0.10ms]
|
||||||
|
S3 actual: __red__
|
||||||
|
59 | // when
|
||||||
|
60 | const actual = resolveVariant({ modelID: "google/gemini-3-1-pro", variants })
|
||||||
|
61 |
|
||||||
|
62 | // then
|
||||||
|
63 | console.info("S3 actual:", actual)
|
||||||
|
64 | expect(actual).toBe("gemini")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gemini"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:64:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when google gemini model matches #then returns gemini [0.04ms]
|
||||||
|
S4 actual: __red__
|
||||||
|
80 | variants,
|
||||||
|
81 | })
|
||||||
|
82 |
|
||||||
|
83 | // then
|
||||||
|
84 | console.info("S4 actual:", actual)
|
||||||
|
85 | expect(actual).toBe("planner")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "planner"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:85:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when agent and model both match #then declared agent variant wins [0.12ms]
|
||||||
|
S5 actual: __red__
|
||||||
|
94 | // when
|
||||||
|
95 | const actual = resolveVariant({ variants })
|
||||||
|
96 |
|
||||||
|
97 | // then
|
||||||
|
98 | console.info("S5 actual:", actual)
|
||||||
|
99 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:99:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no context is provided #then returns default fallback [0.08ms]
|
||||||
|
S6 actual: __red__
|
||||||
|
109 | // when
|
||||||
|
110 | const actual = resolveVariant({ modelID: "unknown-model", variants })
|
||||||
|
111 |
|
||||||
|
112 | // then
|
||||||
|
113 | console.info("S6 actual:", actual)
|
||||||
|
114 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:114:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant test matches #then returns fallback [0.07ms]
|
||||||
|
S7 actual: __red__
|
||||||
|
134 | }
|
||||||
|
135 | }
|
||||||
|
136 | console.info("S7 actual:", actual)
|
||||||
|
137 |
|
||||||
|
138 | // then
|
||||||
|
139 | expect(thrown).toBeInstanceOf(NoMatchingVariantError)
|
||||||
|
^
|
||||||
|
error: expect(received).toBeInstanceOf(expected)
|
||||||
|
|
||||||
|
Expected constructor: [class NoMatchingVariantError extends Error]
|
||||||
|
Received value: undefined
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:139:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant matches and no fallback exists #then throws [0.09ms]
|
||||||
|
|
||||||
|
0 pass
|
||||||
|
7 fail
|
||||||
|
7 expect() calls
|
||||||
|
Ran 7 tests across 1 file. [74.00ms]
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
bun test v1.3.12 (700fc117)
|
||||||
|
|
||||||
|
packages/prompts-core/src/variant-resolver.test.ts:
|
||||||
|
S1 actual: __red__
|
||||||
|
27 | // when
|
||||||
|
28 | const actual = resolveVariant({ modelID: "claude-opus-4-7", variants })
|
||||||
|
29 |
|
||||||
|
30 | // then
|
||||||
|
31 | console.info("S1 actual:", actual)
|
||||||
|
32 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:32:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when claude opus has no model match #then returns default fallback [0.39ms]
|
||||||
|
S2 actual: __red__
|
||||||
|
43 | // when
|
||||||
|
44 | const actual = resolveVariant({ modelID: "openai/gpt-5.5", variants })
|
||||||
|
45 |
|
||||||
|
46 | // then
|
||||||
|
47 | console.info("S2 actual:", actual)
|
||||||
|
48 | expect(actual).toBe("gpt")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gpt"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:48:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when openai gpt model matches #then returns gpt [0.10ms]
|
||||||
|
S3 actual: __red__
|
||||||
|
59 | // when
|
||||||
|
60 | const actual = resolveVariant({ modelID: "google/gemini-3-1-pro", variants })
|
||||||
|
61 |
|
||||||
|
62 | // then
|
||||||
|
63 | console.info("S3 actual:", actual)
|
||||||
|
64 | expect(actual).toBe("gemini")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gemini"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:64:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when google gemini model matches #then returns gemini [0.04ms]
|
||||||
|
S4 actual: __red__
|
||||||
|
80 | variants,
|
||||||
|
81 | })
|
||||||
|
82 |
|
||||||
|
83 | // then
|
||||||
|
84 | console.info("S4 actual:", actual)
|
||||||
|
85 | expect(actual).toBe("planner")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "planner"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:85:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when agent and model both match #then declared agent variant wins [0.12ms]
|
||||||
|
S5 actual: __red__
|
||||||
|
94 | // when
|
||||||
|
95 | const actual = resolveVariant({ variants })
|
||||||
|
96 |
|
||||||
|
97 | // then
|
||||||
|
98 | console.info("S5 actual:", actual)
|
||||||
|
99 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:99:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no context is provided #then returns default fallback [0.08ms]
|
||||||
|
S6 actual: __red__
|
||||||
|
109 | // when
|
||||||
|
110 | const actual = resolveVariant({ modelID: "unknown-model", variants })
|
||||||
|
111 |
|
||||||
|
112 | // then
|
||||||
|
113 | console.info("S6 actual:", actual)
|
||||||
|
114 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:114:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant test matches #then returns fallback [0.07ms]
|
||||||
|
S7 actual: __red__
|
||||||
|
134 | }
|
||||||
|
135 | }
|
||||||
|
136 | console.info("S7 actual:", actual)
|
||||||
|
137 |
|
||||||
|
138 | // then
|
||||||
|
139 | expect(thrown).toBeInstanceOf(NoMatchingVariantError)
|
||||||
|
^
|
||||||
|
error: expect(received).toBeInstanceOf(expected)
|
||||||
|
|
||||||
|
Expected constructor: [class NoMatchingVariantError extends Error]
|
||||||
|
Received value: undefined
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:139:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant matches and no fallback exists #then throws [0.09ms]
|
||||||
|
|
||||||
|
0 pass
|
||||||
|
7 fail
|
||||||
|
7 expect() calls
|
||||||
|
Ran 7 tests across 1 file. [74.00ms]
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
bun test v1.3.12 (700fc117)
|
||||||
|
|
||||||
|
packages/prompts-core/src/variant-resolver.test.ts:
|
||||||
|
S1 actual: __red__
|
||||||
|
27 | // when
|
||||||
|
28 | const actual = resolveVariant({ modelID: "claude-opus-4-7", variants })
|
||||||
|
29 |
|
||||||
|
30 | // then
|
||||||
|
31 | console.info("S1 actual:", actual)
|
||||||
|
32 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:32:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when claude opus has no model match #then returns default fallback [0.39ms]
|
||||||
|
S2 actual: __red__
|
||||||
|
43 | // when
|
||||||
|
44 | const actual = resolveVariant({ modelID: "openai/gpt-5.5", variants })
|
||||||
|
45 |
|
||||||
|
46 | // then
|
||||||
|
47 | console.info("S2 actual:", actual)
|
||||||
|
48 | expect(actual).toBe("gpt")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gpt"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:48:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when openai gpt model matches #then returns gpt [0.10ms]
|
||||||
|
S3 actual: __red__
|
||||||
|
59 | // when
|
||||||
|
60 | const actual = resolveVariant({ modelID: "google/gemini-3-1-pro", variants })
|
||||||
|
61 |
|
||||||
|
62 | // then
|
||||||
|
63 | console.info("S3 actual:", actual)
|
||||||
|
64 | expect(actual).toBe("gemini")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gemini"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:64:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when google gemini model matches #then returns gemini [0.04ms]
|
||||||
|
S4 actual: __red__
|
||||||
|
80 | variants,
|
||||||
|
81 | })
|
||||||
|
82 |
|
||||||
|
83 | // then
|
||||||
|
84 | console.info("S4 actual:", actual)
|
||||||
|
85 | expect(actual).toBe("planner")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "planner"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:85:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when agent and model both match #then declared agent variant wins [0.12ms]
|
||||||
|
S5 actual: __red__
|
||||||
|
94 | // when
|
||||||
|
95 | const actual = resolveVariant({ variants })
|
||||||
|
96 |
|
||||||
|
97 | // then
|
||||||
|
98 | console.info("S5 actual:", actual)
|
||||||
|
99 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:99:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no context is provided #then returns default fallback [0.08ms]
|
||||||
|
S6 actual: __red__
|
||||||
|
109 | // when
|
||||||
|
110 | const actual = resolveVariant({ modelID: "unknown-model", variants })
|
||||||
|
111 |
|
||||||
|
112 | // then
|
||||||
|
113 | console.info("S6 actual:", actual)
|
||||||
|
114 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:114:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant test matches #then returns fallback [0.07ms]
|
||||||
|
S7 actual: __red__
|
||||||
|
134 | }
|
||||||
|
135 | }
|
||||||
|
136 | console.info("S7 actual:", actual)
|
||||||
|
137 |
|
||||||
|
138 | // then
|
||||||
|
139 | expect(thrown).toBeInstanceOf(NoMatchingVariantError)
|
||||||
|
^
|
||||||
|
error: expect(received).toBeInstanceOf(expected)
|
||||||
|
|
||||||
|
Expected constructor: [class NoMatchingVariantError extends Error]
|
||||||
|
Received value: undefined
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:139:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant matches and no fallback exists #then throws [0.09ms]
|
||||||
|
|
||||||
|
0 pass
|
||||||
|
7 fail
|
||||||
|
7 expect() calls
|
||||||
|
Ran 7 tests across 1 file. [74.00ms]
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
bun test v1.3.12 (700fc117)
|
||||||
|
|
||||||
|
packages/prompts-core/src/variant-resolver.test.ts:
|
||||||
|
S1 actual: __red__
|
||||||
|
27 | // when
|
||||||
|
28 | const actual = resolveVariant({ modelID: "claude-opus-4-7", variants })
|
||||||
|
29 |
|
||||||
|
30 | // then
|
||||||
|
31 | console.info("S1 actual:", actual)
|
||||||
|
32 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:32:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when claude opus has no model match #then returns default fallback [0.39ms]
|
||||||
|
S2 actual: __red__
|
||||||
|
43 | // when
|
||||||
|
44 | const actual = resolveVariant({ modelID: "openai/gpt-5.5", variants })
|
||||||
|
45 |
|
||||||
|
46 | // then
|
||||||
|
47 | console.info("S2 actual:", actual)
|
||||||
|
48 | expect(actual).toBe("gpt")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gpt"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:48:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when openai gpt model matches #then returns gpt [0.10ms]
|
||||||
|
S3 actual: __red__
|
||||||
|
59 | // when
|
||||||
|
60 | const actual = resolveVariant({ modelID: "google/gemini-3-1-pro", variants })
|
||||||
|
61 |
|
||||||
|
62 | // then
|
||||||
|
63 | console.info("S3 actual:", actual)
|
||||||
|
64 | expect(actual).toBe("gemini")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gemini"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:64:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when google gemini model matches #then returns gemini [0.04ms]
|
||||||
|
S4 actual: __red__
|
||||||
|
80 | variants,
|
||||||
|
81 | })
|
||||||
|
82 |
|
||||||
|
83 | // then
|
||||||
|
84 | console.info("S4 actual:", actual)
|
||||||
|
85 | expect(actual).toBe("planner")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "planner"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:85:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when agent and model both match #then declared agent variant wins [0.12ms]
|
||||||
|
S5 actual: __red__
|
||||||
|
94 | // when
|
||||||
|
95 | const actual = resolveVariant({ variants })
|
||||||
|
96 |
|
||||||
|
97 | // then
|
||||||
|
98 | console.info("S5 actual:", actual)
|
||||||
|
99 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:99:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no context is provided #then returns default fallback [0.08ms]
|
||||||
|
S6 actual: __red__
|
||||||
|
109 | // when
|
||||||
|
110 | const actual = resolveVariant({ modelID: "unknown-model", variants })
|
||||||
|
111 |
|
||||||
|
112 | // then
|
||||||
|
113 | console.info("S6 actual:", actual)
|
||||||
|
114 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:114:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant test matches #then returns fallback [0.07ms]
|
||||||
|
S7 actual: __red__
|
||||||
|
134 | }
|
||||||
|
135 | }
|
||||||
|
136 | console.info("S7 actual:", actual)
|
||||||
|
137 |
|
||||||
|
138 | // then
|
||||||
|
139 | expect(thrown).toBeInstanceOf(NoMatchingVariantError)
|
||||||
|
^
|
||||||
|
error: expect(received).toBeInstanceOf(expected)
|
||||||
|
|
||||||
|
Expected constructor: [class NoMatchingVariantError extends Error]
|
||||||
|
Received value: undefined
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:139:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant matches and no fallback exists #then throws [0.09ms]
|
||||||
|
|
||||||
|
0 pass
|
||||||
|
7 fail
|
||||||
|
7 expect() calls
|
||||||
|
Ran 7 tests across 1 file. [74.00ms]
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
bun test v1.3.12 (700fc117)
|
||||||
|
|
||||||
|
packages/prompts-core/src/variant-resolver.test.ts:
|
||||||
|
S1 actual: __red__
|
||||||
|
27 | // when
|
||||||
|
28 | const actual = resolveVariant({ modelID: "claude-opus-4-7", variants })
|
||||||
|
29 |
|
||||||
|
30 | // then
|
||||||
|
31 | console.info("S1 actual:", actual)
|
||||||
|
32 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:32:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when claude opus has no model match #then returns default fallback [0.39ms]
|
||||||
|
S2 actual: __red__
|
||||||
|
43 | // when
|
||||||
|
44 | const actual = resolveVariant({ modelID: "openai/gpt-5.5", variants })
|
||||||
|
45 |
|
||||||
|
46 | // then
|
||||||
|
47 | console.info("S2 actual:", actual)
|
||||||
|
48 | expect(actual).toBe("gpt")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gpt"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:48:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when openai gpt model matches #then returns gpt [0.10ms]
|
||||||
|
S3 actual: __red__
|
||||||
|
59 | // when
|
||||||
|
60 | const actual = resolveVariant({ modelID: "google/gemini-3-1-pro", variants })
|
||||||
|
61 |
|
||||||
|
62 | // then
|
||||||
|
63 | console.info("S3 actual:", actual)
|
||||||
|
64 | expect(actual).toBe("gemini")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gemini"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:64:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when google gemini model matches #then returns gemini [0.04ms]
|
||||||
|
S4 actual: __red__
|
||||||
|
80 | variants,
|
||||||
|
81 | })
|
||||||
|
82 |
|
||||||
|
83 | // then
|
||||||
|
84 | console.info("S4 actual:", actual)
|
||||||
|
85 | expect(actual).toBe("planner")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "planner"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:85:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when agent and model both match #then declared agent variant wins [0.12ms]
|
||||||
|
S5 actual: __red__
|
||||||
|
94 | // when
|
||||||
|
95 | const actual = resolveVariant({ variants })
|
||||||
|
96 |
|
||||||
|
97 | // then
|
||||||
|
98 | console.info("S5 actual:", actual)
|
||||||
|
99 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:99:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no context is provided #then returns default fallback [0.08ms]
|
||||||
|
S6 actual: __red__
|
||||||
|
109 | // when
|
||||||
|
110 | const actual = resolveVariant({ modelID: "unknown-model", variants })
|
||||||
|
111 |
|
||||||
|
112 | // then
|
||||||
|
113 | console.info("S6 actual:", actual)
|
||||||
|
114 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:114:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant test matches #then returns fallback [0.07ms]
|
||||||
|
S7 actual: __red__
|
||||||
|
134 | }
|
||||||
|
135 | }
|
||||||
|
136 | console.info("S7 actual:", actual)
|
||||||
|
137 |
|
||||||
|
138 | // then
|
||||||
|
139 | expect(thrown).toBeInstanceOf(NoMatchingVariantError)
|
||||||
|
^
|
||||||
|
error: expect(received).toBeInstanceOf(expected)
|
||||||
|
|
||||||
|
Expected constructor: [class NoMatchingVariantError extends Error]
|
||||||
|
Received value: undefined
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:139:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant matches and no fallback exists #then throws [0.09ms]
|
||||||
|
|
||||||
|
0 pass
|
||||||
|
7 fail
|
||||||
|
7 expect() calls
|
||||||
|
Ran 7 tests across 1 file. [74.00ms]
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
bun test v1.3.12 (700fc117)
|
||||||
|
|
||||||
|
packages/prompts-core/src/variant-resolver.test.ts:
|
||||||
|
S1 actual: __red__
|
||||||
|
27 | // when
|
||||||
|
28 | const actual = resolveVariant({ modelID: "claude-opus-4-7", variants })
|
||||||
|
29 |
|
||||||
|
30 | // then
|
||||||
|
31 | console.info("S1 actual:", actual)
|
||||||
|
32 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:32:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when claude opus has no model match #then returns default fallback [0.39ms]
|
||||||
|
S2 actual: __red__
|
||||||
|
43 | // when
|
||||||
|
44 | const actual = resolveVariant({ modelID: "openai/gpt-5.5", variants })
|
||||||
|
45 |
|
||||||
|
46 | // then
|
||||||
|
47 | console.info("S2 actual:", actual)
|
||||||
|
48 | expect(actual).toBe("gpt")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gpt"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:48:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when openai gpt model matches #then returns gpt [0.10ms]
|
||||||
|
S3 actual: __red__
|
||||||
|
59 | // when
|
||||||
|
60 | const actual = resolveVariant({ modelID: "google/gemini-3-1-pro", variants })
|
||||||
|
61 |
|
||||||
|
62 | // then
|
||||||
|
63 | console.info("S3 actual:", actual)
|
||||||
|
64 | expect(actual).toBe("gemini")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "gemini"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:64:22)
|
||||||
|
(fail) resolveVariant > #given declared model variants > #when google gemini model matches #then returns gemini [0.04ms]
|
||||||
|
S4 actual: __red__
|
||||||
|
80 | variants,
|
||||||
|
81 | })
|
||||||
|
82 |
|
||||||
|
83 | // then
|
||||||
|
84 | console.info("S4 actual:", actual)
|
||||||
|
85 | expect(actual).toBe("planner")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "planner"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:85:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when agent and model both match #then declared agent variant wins [0.12ms]
|
||||||
|
S5 actual: __red__
|
||||||
|
94 | // when
|
||||||
|
95 | const actual = resolveVariant({ variants })
|
||||||
|
96 |
|
||||||
|
97 | // then
|
||||||
|
98 | console.info("S5 actual:", actual)
|
||||||
|
99 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:99:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no context is provided #then returns default fallback [0.08ms]
|
||||||
|
S6 actual: __red__
|
||||||
|
109 | // when
|
||||||
|
110 | const actual = resolveVariant({ modelID: "unknown-model", variants })
|
||||||
|
111 |
|
||||||
|
112 | // then
|
||||||
|
113 | console.info("S6 actual:", actual)
|
||||||
|
114 | expect(actual).toBe("default")
|
||||||
|
^
|
||||||
|
error: expect(received).toBe(expected)
|
||||||
|
|
||||||
|
Expected: "default"
|
||||||
|
Received: "__red__"
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:114:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant test matches #then returns fallback [0.07ms]
|
||||||
|
S7 actual: __red__
|
||||||
|
134 | }
|
||||||
|
135 | }
|
||||||
|
136 | console.info("S7 actual:", actual)
|
||||||
|
137 |
|
||||||
|
138 | // then
|
||||||
|
139 | expect(thrown).toBeInstanceOf(NoMatchingVariantError)
|
||||||
|
^
|
||||||
|
error: expect(received).toBeInstanceOf(expected)
|
||||||
|
|
||||||
|
Expected constructor: [class NoMatchingVariantError extends Error]
|
||||||
|
Received value: undefined
|
||||||
|
|
||||||
|
at <anonymous> (/Users/yeongyu/local-workspaces/omo-wt/feat/prompts-core-foundation/packages/prompts-core/src/variant-resolver.test.ts:139:22)
|
||||||
|
(fail) resolveVariant > #given agent and fallback variants > #when no variant matches and no fallback exists #then throws [0.09ms]
|
||||||
|
|
||||||
|
0 pass
|
||||||
|
7 fail
|
||||||
|
7 expect() calls
|
||||||
|
Ran 7 tests across 1 file. [74.00ms]
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
import { describe, expect, test } from "bun:test"
|
||||||
|
|
||||||
|
import { resolveVariant } from "./variant-resolver"
|
||||||
|
import { NoMatchingVariantError, type VariantTable } from "./types"
|
||||||
|
|
||||||
|
const isGpt = (input: { modelID?: string; agentName?: string }): boolean =>
|
||||||
|
input.modelID?.includes("gpt") ?? false
|
||||||
|
|
||||||
|
const isGemini = (input: { modelID?: string; agentName?: string }): boolean =>
|
||||||
|
input.modelID?.includes("gemini") ?? false
|
||||||
|
|
||||||
|
const isPlanner = (input: { modelID?: string; agentName?: string }): boolean =>
|
||||||
|
input.agentName === "prometheus"
|
||||||
|
|
||||||
|
const alwaysFalse = (): boolean => false
|
||||||
|
|
||||||
|
describe("resolveVariant", () => {
|
||||||
|
describe("#given declared model variants", () => {
|
||||||
|
test("#when claude opus has no model match #then returns default fallback", () => {
|
||||||
|
// given
|
||||||
|
const variants = {
|
||||||
|
gpt: { test: isGpt },
|
||||||
|
gemini: { test: isGemini },
|
||||||
|
default: { fallback: true },
|
||||||
|
} satisfies VariantTable
|
||||||
|
|
||||||
|
// when
|
||||||
|
const actual = resolveVariant({ modelID: "claude-opus-4-7", variants })
|
||||||
|
|
||||||
|
// then
|
||||||
|
console.info("S1 actual:", actual)
|
||||||
|
expect(actual).toBe("default")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("#when openai gpt model matches #then returns gpt", () => {
|
||||||
|
// given
|
||||||
|
const variants = {
|
||||||
|
gpt: { test: isGpt },
|
||||||
|
gemini: { test: isGemini },
|
||||||
|
default: { fallback: true },
|
||||||
|
} satisfies VariantTable
|
||||||
|
|
||||||
|
// when
|
||||||
|
const actual = resolveVariant({ modelID: "openai/gpt-5.5", variants })
|
||||||
|
|
||||||
|
// then
|
||||||
|
console.info("S2 actual:", actual)
|
||||||
|
expect(actual).toBe("gpt")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("#when google gemini model matches #then returns gemini", () => {
|
||||||
|
// given
|
||||||
|
const variants = {
|
||||||
|
gpt: { test: isGpt },
|
||||||
|
gemini: { test: isGemini },
|
||||||
|
default: { fallback: true },
|
||||||
|
} satisfies VariantTable
|
||||||
|
|
||||||
|
// when
|
||||||
|
const actual = resolveVariant({ modelID: "google/gemini-3-1-pro", variants })
|
||||||
|
|
||||||
|
// then
|
||||||
|
console.info("S3 actual:", actual)
|
||||||
|
expect(actual).toBe("gemini")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("#given agent and fallback variants", () => {
|
||||||
|
test("#when agent and model both match #then declared agent variant wins", () => {
|
||||||
|
// given
|
||||||
|
const variants = {
|
||||||
|
planner: { test: isPlanner },
|
||||||
|
gpt: { test: isGpt },
|
||||||
|
} satisfies VariantTable
|
||||||
|
|
||||||
|
// when
|
||||||
|
const actual = resolveVariant({
|
||||||
|
agentName: "prometheus",
|
||||||
|
modelID: "openai/gpt-5.5",
|
||||||
|
variants,
|
||||||
|
})
|
||||||
|
|
||||||
|
// then
|
||||||
|
console.info("S4 actual:", actual)
|
||||||
|
expect(actual).toBe("planner")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("#when no context is provided #then returns default fallback", () => {
|
||||||
|
// given
|
||||||
|
const variants = {
|
||||||
|
default: { fallback: true },
|
||||||
|
} satisfies VariantTable
|
||||||
|
|
||||||
|
// when
|
||||||
|
const actual = resolveVariant({ variants })
|
||||||
|
|
||||||
|
// then
|
||||||
|
console.info("S5 actual:", actual)
|
||||||
|
expect(actual).toBe("default")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("#when no variant test matches #then returns fallback", () => {
|
||||||
|
// given
|
||||||
|
const variants = {
|
||||||
|
gpt: { test: alwaysFalse },
|
||||||
|
default: { fallback: true },
|
||||||
|
} satisfies VariantTable
|
||||||
|
|
||||||
|
// when
|
||||||
|
const actual = resolveVariant({ modelID: "unknown-model", variants })
|
||||||
|
|
||||||
|
// then
|
||||||
|
console.info("S6 actual:", actual)
|
||||||
|
expect(actual).toBe("default")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("#when no variant matches and no fallback exists #then throws", () => {
|
||||||
|
// given
|
||||||
|
const variants = {
|
||||||
|
a: { test: alwaysFalse },
|
||||||
|
} satisfies VariantTable
|
||||||
|
|
||||||
|
// when
|
||||||
|
let actual = "no throw"
|
||||||
|
let thrown: unknown
|
||||||
|
try {
|
||||||
|
actual = resolveVariant({ modelID: "x", variants })
|
||||||
|
} catch (error) {
|
||||||
|
thrown = error
|
||||||
|
if (error instanceof Error) {
|
||||||
|
actual = error.name
|
||||||
|
} else {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.info("S7 actual:", actual)
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(thrown).toBeInstanceOf(NoMatchingVariantError)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import type { ResolveVariantInput } from "./types"
|
||||||
|
|
||||||
|
export function resolveVariant(_input: ResolveVariantInput): string {
|
||||||
|
return "__red__"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user