From f81d322aa5a47c52597081479d3fac7bf4f6850f Mon Sep 17 00:00:00 2001 From: "gru-agent[bot]" <185149714+gru-agent[bot]@users.noreply.github.com> Date: Wed, 22 Jan 2025 16:12:25 +0000 Subject: [PATCH] Add unit tests for optimizedPrompt function in optimized.test.ts --- app/lib/common/prompts/optimized.test.ts | 66 ++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 app/lib/common/prompts/optimized.test.ts diff --git a/app/lib/common/prompts/optimized.test.ts b/app/lib/common/prompts/optimized.test.ts new file mode 100644 index 000000000..daee12cae --- /dev/null +++ b/app/lib/common/prompts/optimized.test.ts @@ -0,0 +1,66 @@ +import { describe, it, expect } from 'vitest'; +import optimizedPrompt from './optimized'; +import type { PromptOptions } from '~/lib/common/prompt-library'; + +describe('optimizedPrompt', () => { + it('should generate prompt with provided options', () => { + const options: PromptOptions = { + cwd: '/test/path', + allowedHtmlElements: ['div', 'span'], + modificationTagName: 'modify', + }; + + const result = optimizedPrompt(options); + + expect(result).toContain('Current working directory: `/test/path `'); + expect(result).toContain('Available HTML elements: div, span'); + expect(result).toContain('``'); + }); + + it('should handle empty allowed HTML elements array', () => { + const options: PromptOptions = { + cwd: '/test/path', + allowedHtmlElements: [], + modificationTagName: 'modify', + }; + + const result = optimizedPrompt(options); + + expect(result).toContain('Available HTML elements: '); + }); + + it('should include all required sections', () => { + const options: PromptOptions = { + cwd: '/test/path', + allowedHtmlElements: ['div'], + modificationTagName: 'modify', + }; + + const result = optimizedPrompt(options); + + expect(result).toContain(''); + expect(result).toContain(''); + expect(result).toContain(''); + expect(result).toContain(''); + expect(result).toContain(''); + expect(result).toContain(''); + expect(result).toContain(''); + }); + + it('should include critical rules section', () => { + const options: PromptOptions = { + cwd: '/test/path', + allowedHtmlElements: ['div'], + modificationTagName: 'modify', + }; + + const result = optimizedPrompt(options); + + expect(result).toContain('# CRITICAL RULES - NEVER IGNORE'); + expect(result).toContain('## File and Command Handling'); + expect(result).toContain('## Response Format'); + expect(result).toContain('## Development Process'); + expect(result).toContain('## Coding Standards'); + expect(result).toContain('## Artifact Usage'); + }); +});