Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TestGru] Add unit test for app/lib/common/prompts/optimized.ts #4

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions app/lib/common/prompts/optimized.test.ts
Original file line number Diff line number Diff line change
@@ -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('`<modify>`');
});

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('<system_constraints>');
expect(result).toContain('<code_formatting_info>');
expect(result).toContain('<message_formatting_info>');
expect(result).toContain('<diff_spec>');
expect(result).toContain('<chain_of_thought_instructions>');
expect(result).toContain('<artifact_info>');
expect(result).toContain('<examples>');
});

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');
});
});
Loading