meld
Version:
Meld: A template language for LLM prompts
55 lines (47 loc) • 1.95 kB
text/typescript
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { main } from '@api/index.js';
import { TestContext } from '@tests/utils/TestContext.js';
describe('Embed Directive Variable Path Prefix Fix', () => {
let context: TestContext;
beforeEach(async () => {
context = new TestContext();
await context.initialize();
});
afterEach(async () => {
await context.cleanup();
});
it('should fix the path prefixing issue with data variable embeds', async () => {
// Create a test file that resembles examples/output.meld
await context.fs.writeFile('variable-output.meld',
'@data role = {\n' +
' "architect": "You are a senior architect skilled in TypeScript.",\n' +
' "ux": "You are a UX designer with experience in user testing."\n' +
'}\n\n' +
'@data task = {\n' +
' "code_review": "Review the code quality and suggest improvements.",\n' +
' "ux_review": "Review the user experience and suggest improvements."\n' +
'}\n\n' +
'## Role\n' +
'@embed {{role.architect}}\n\n' +
'## Task\n' +
'@embed {{task.code_review}}'
);
// Test with transformation
const result = await main('variable-output.meld', {
fs: context.fs,
services: context.services,
transformation: true,
format: 'markdown'
});
// Verify no prefixing issues
expect(result).toContain('You are a senior architect skilled in TypeScript.');
expect(result).toContain('Review the code quality and suggest improvements.');
// Make sure no "examples/" or other folder prefixes appear
expect(result).not.toContain('examples/');
expect(result).not.toContain('/');
// Also verify the @embed directive is properly replaced
expect(result).not.toContain('@embed');
expect(result).not.toContain('{{role.architect}}');
expect(result).not.toContain('{{task.code_review}}');
});
});