69 lines
1.9 KiB
Markdown
69 lines
1.9 KiB
Markdown
|
|
# Task ID: 63
|
||
|
|
|
||
|
|
**Title:** Add unit tests for prompt priority and link CRUD
|
||
|
|
|
||
|
|
**Status:** done
|
||
|
|
|
||
|
|
**Dependencies:** 40 ✓, 41 ✓
|
||
|
|
|
||
|
|
**Priority:** high
|
||
|
|
|
||
|
|
**Description:** Create comprehensive unit tests for all prompt CRUD operations with the new priority and linkTarget fields.
|
||
|
|
|
||
|
|
**Details:**
|
||
|
|
|
||
|
|
1. Add tests in `/src/mcpd/tests/services/prompt-service.test.ts`:
|
||
|
|
```typescript
|
||
|
|
describe('Prompt Priority', () => {
|
||
|
|
it('creates prompt with explicit priority', async () => {
|
||
|
|
const prompt = await service.createPrompt({ ...data, priority: 8 });
|
||
|
|
expect(prompt.priority).toBe(8);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('uses default priority 5 when not specified', async () => {
|
||
|
|
const prompt = await service.createPrompt(data);
|
||
|
|
expect(prompt.priority).toBe(5);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('validates priority range 1-10', async () => {
|
||
|
|
await expect(service.createPrompt({ ...data, priority: 11 }))
|
||
|
|
.rejects.toThrow();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('updates priority', async () => {
|
||
|
|
const updated = await service.updatePrompt(id, { priority: 3 });
|
||
|
|
expect(updated.priority).toBe(3);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
describe('Prompt Links', () => {
|
||
|
|
it('creates linked prompt', async () => {
|
||
|
|
const prompt = await service.createPrompt({
|
||
|
|
...data,
|
||
|
|
linkTarget: 'project/server:uri'
|
||
|
|
});
|
||
|
|
expect(prompt.linkTarget).toBe('project/server:uri');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('rejects invalid link format', async () => {
|
||
|
|
await expect(service.createPrompt({
|
||
|
|
...data,
|
||
|
|
linkTarget: 'invalid'
|
||
|
|
})).rejects.toThrow();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('linkTarget is immutable on update', async () => {
|
||
|
|
// linkTarget not accepted in update schema
|
||
|
|
});
|
||
|
|
});
|
||
|
|
```
|
||
|
|
|
||
|
|
**Test Strategy:**
|
||
|
|
|
||
|
|
This task IS the test implementation. Verify:
|
||
|
|
- All priority CRUD tests pass
|
||
|
|
- All link CRUD tests pass
|
||
|
|
- Validation tests cover edge cases
|
||
|
|
- Tests use proper mocking patterns
|
||
|
|
- Coverage meets project standards
|