mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
Fix tests
This commit is contained in:
2 files changed
+25
-394
No files matched your search
+25
-23
@@ -196,14 +196,14 @@ describe('makeSystemPrompt', () => {
|
||||
});
|
||||
|
||||
describe('tools section', () => {
|
||||
it('should show no tools message when no tools are provided', async () => {
|
||||
it('should pass tools to template context when no tools are provided', async () => {
|
||||
const result = await makeSystemPrompt(baseOpts);
|
||||
|
||||
expect(result).toContain('## Available Tools');
|
||||
expect(result).toContain('There are no tools available to you.');
|
||||
// Tools are passed to context but not rendered by default template
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should list available tools with descriptions', async () => {
|
||||
it('should pass tools to template context when tools are provided', async () => {
|
||||
const tools: OpenAI.Chat.Completions.ChatCompletionTool[] = [
|
||||
{
|
||||
type: 'function',
|
||||
@@ -225,49 +225,54 @@ describe('makeSystemPrompt', () => {
|
||||
|
||||
const result = await makeSystemPrompt({ ...baseOpts, tools });
|
||||
|
||||
expect(result).toContain('## Available Tools');
|
||||
expect(result).toContain('**read_file**: Read contents of a file');
|
||||
expect(result).toContain('**write_file**: Write contents to a file');
|
||||
// Tools are passed to context but not rendered by default template
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should handle tools without descriptions', async () => {
|
||||
it('should render tools with custom template', async () => {
|
||||
const tools: OpenAI.Chat.Completions.ChatCompletionTool[] = [
|
||||
{
|
||||
type: 'function',
|
||||
function: {
|
||||
name: 'some_tool',
|
||||
description: 'A test tool',
|
||||
parameters: {},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const result = await makeSystemPrompt({ ...baseOpts, tools });
|
||||
const customTemplate = '## Available Tools\n{% for tool in tools %}**{{ tool.function.name }}**: {{ tool.function.description or "No description available" }}\n{% endfor %}';
|
||||
|
||||
expect(result).toContain('**some_tool**: No description available');
|
||||
const result = await makeSystemPrompt({ ...baseOpts, tools, template: customTemplate });
|
||||
|
||||
expect(result).toContain('## Available Tools');
|
||||
expect(result).toContain('**some_tool**: A test tool');
|
||||
});
|
||||
});
|
||||
|
||||
describe('skills section', () => {
|
||||
it('should show no skills message when pluginsPath is not provided', async () => {
|
||||
it('should not call getAllSkills when pluginsPath is not provided', async () => {
|
||||
const result = await makeSystemPrompt({
|
||||
...baseOpts,
|
||||
config: { ...testConfig, fsPathPlugins: '' },
|
||||
});
|
||||
|
||||
expect(result).toContain('## Skills');
|
||||
expect(result).toContain('No skills are currently configured');
|
||||
// Skills are not fetched when pluginsPath is empty
|
||||
expect(result).toBeTruthy();
|
||||
expect(getAllSkills).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should show no skills message when getAllSkills returns empty array', async () => {
|
||||
it('should fetch skills when pluginsPath is provided but return empty array', async () => {
|
||||
vi.mocked(getAllSkills).mockResolvedValue([]);
|
||||
|
||||
const result = await makeSystemPrompt(baseOpts);
|
||||
|
||||
expect(result).toContain('No skills are currently configured');
|
||||
// Skills are passed to context but not rendered by default template
|
||||
expect(result).toBeTruthy();
|
||||
expect(getAllSkills).toHaveBeenCalledWith(mockFs, '/plugins', '/projects/test-project');
|
||||
});
|
||||
|
||||
it('should list available skills when they exist', async () => {
|
||||
it('should pass skills to template context when they exist', async () => {
|
||||
vi.mocked(getAllSkills).mockResolvedValue([
|
||||
{
|
||||
name: 'create_component',
|
||||
@@ -285,11 +290,8 @@ describe('makeSystemPrompt', () => {
|
||||
|
||||
const result = await makeSystemPrompt(baseOpts);
|
||||
|
||||
expect(result).toContain('## Skills');
|
||||
expect(result).toContain('**create_component**: Create a new React component');
|
||||
expect(result).toContain('Plugin: react-plugin');
|
||||
expect(result).toContain('**setup_routing**: Setup React Router');
|
||||
expect(result).toContain('Skills MUST be used whenever applicable');
|
||||
// Skills are passed to context but not rendered by default template
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should handle getAllSkills errors gracefully', async () => {
|
||||
@@ -297,7 +299,8 @@ describe('makeSystemPrompt', () => {
|
||||
|
||||
const result = await makeSystemPrompt(baseOpts);
|
||||
|
||||
expect(result).toContain('No skills are currently configured');
|
||||
// Should continue with empty skills array
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -429,7 +432,6 @@ describe('makeSystemPrompt', () => {
|
||||
expect(result).toContain('## Virtual Filesystem Structure');
|
||||
expect(result).toContain('## Your Role');
|
||||
expect(result).toContain('## Project Templates');
|
||||
expect(result).toContain('## Skills');
|
||||
expect(result).toContain('## Working Around CORS Issues');
|
||||
expect(result).toContain('## Edit with Shakespeare');
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user