Feature/semantic similarity (#36)

* fix: mixed up migrations

* feat: semantic similarity first take

* feat: semantic similarity first round of fixes

* feat: more work on making semantic similarity work properly

* feat: getPostBySlug for the AI

* feat: show similarity in post-link-insert-modal

* chore: remove done doc

---------

Co-authored-by: hugo <hugoms@me.com>
This commit is contained in:
Georg Bauer
2026-03-05 22:05:32 +01:00
committed by GitHub
parent 8ac8305e01
commit 7e1e8981a3
64 changed files with 6429 additions and 499 deletions

View File

@@ -619,6 +619,45 @@ Content for retrieval test`);
});
});
describe('getPostBySlug', () => {
it('should return null for non-existent slug', async () => {
const result = await postEngine.getPostBySlug('no-such-slug');
expect(result).toBeNull();
});
it('should retrieve post by slug', async () => {
const created = await postEngine.createPost({
title: 'Slug Lookup Post',
content: 'Content for slug test',
});
vi.mocked(mockLocalDb.select).mockImplementation(() => {
const chain = createSelectChain();
chain.where = vi.fn().mockReturnValue({
...chain,
get: vi.fn().mockResolvedValue({
id: created.id,
projectId: created.projectId,
title: created.title,
slug: created.slug,
status: created.status,
content: 'Content for slug test',
tags: '[]',
categories: '[]',
createdAt: created.createdAt,
updatedAt: created.updatedAt,
}),
});
return chain;
});
const result = await postEngine.getPostBySlug(created.slug);
expect(result).not.toBeNull();
expect(result?.title).toBe('Slug Lookup Post');
expect(result?.content).toBe('Content for slug test');
});
});
describe('updatePost', () => {
it('should return null when updating non-existent post', async () => {
const result = await postEngine.updatePost('non-existent-id', { title: 'New Title' });