Co-authored-by: rfc1437 <774975+rfc1437@users.noreply.github.com>
This commit is contained in:
@@ -472,6 +472,20 @@ describe('MetaEngine', () => {
|
||||
expect(parsed.description).toBe('Test description');
|
||||
});
|
||||
|
||||
it('should not persist dataPath to filesystem project metadata', async () => {
|
||||
await metaEngine.setProjectMetadata({
|
||||
name: 'Test Project',
|
||||
dataPath: '/custom/project/path',
|
||||
});
|
||||
|
||||
const metaDir = metaEngine.getMetaDir();
|
||||
const projectPath = normalizePath(`${metaDir}/project.json`);
|
||||
const content = mockFiles.get(projectPath);
|
||||
const parsed = JSON.parse(content!);
|
||||
|
||||
expect(parsed.dataPath).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should load project metadata from filesystem', async () => {
|
||||
const metaDir = metaEngine.getMetaDir();
|
||||
const projectPath = normalizePath(`${metaDir}/project.json`);
|
||||
@@ -757,7 +771,7 @@ describe('MetaEngine', () => {
|
||||
expect(normalizePath(metaDir)).toContain(normalizePath(customDataDir));
|
||||
});
|
||||
|
||||
it('should sync dataPath from database to project.json if different', async () => {
|
||||
it('should ignore and remove dataPath from project.json during syncOnStartup', async () => {
|
||||
const metaDir = metaEngine.getMetaDir();
|
||||
const oldPath = path.join('old', 'path', 'from', 'file');
|
||||
const newPath = path.join('new', 'path', 'from', 'database');
|
||||
@@ -783,7 +797,7 @@ describe('MetaEngine', () => {
|
||||
const savedProjectJson = mockFiles.get(normalizePath(`${metaDir}/project.json`));
|
||||
expect(savedProjectJson).toBeDefined();
|
||||
const parsed = JSON.parse(savedProjectJson!);
|
||||
expect(normalizePath(parsed.dataPath)).toBe(normalizePath(newPath));
|
||||
expect(parsed.dataPath).toBeUndefined();
|
||||
expect(mockLocalDb.update).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ type PostEngineLike = {
|
||||
};
|
||||
|
||||
type SettingsEngineLike = {
|
||||
getProjectMetadata: () => Promise<{ maxPostsPerPage?: number } | null>;
|
||||
getProjectMetadata: () => Promise<{ maxPostsPerPage?: number; mainLanguage?: string } | null>;
|
||||
setProjectContext: (projectId: string, dataDir?: string) => void;
|
||||
};
|
||||
|
||||
@@ -335,6 +335,30 @@ describe('PreviewServer', () => {
|
||||
expect(html).not.toContain('<title>Blog Preview</title>');
|
||||
});
|
||||
|
||||
it('uses mainLanguage from metadata for html lang attribute', async () => {
|
||||
server = new PreviewServer({
|
||||
postEngine: makeEngine([makePost()]),
|
||||
settingsEngine: {
|
||||
setProjectContext: vi.fn(),
|
||||
async getProjectMetadata() {
|
||||
return {
|
||||
name: 'My Great Blog',
|
||||
mainLanguage: 'de',
|
||||
maxPostsPerPage: 50,
|
||||
};
|
||||
},
|
||||
},
|
||||
getActiveProjectContext: async () => ({ projectId: 'default' }),
|
||||
});
|
||||
|
||||
await server.start(0);
|
||||
|
||||
const response = await fetch(`${server.getBaseUrl()}/`);
|
||||
expect(response.status).toBe(200);
|
||||
const html = await response.text();
|
||||
expect(html).toContain('<html lang="de">');
|
||||
});
|
||||
|
||||
it('falls back to active project name in page title when metadata is unavailable', async () => {
|
||||
server = new PreviewServer({
|
||||
postEngine: makeEngine([makePost()]),
|
||||
@@ -587,4 +611,4 @@ describe('PreviewServer', () => {
|
||||
|
||||
expect(getPost).toHaveBeenCalledTimes(50);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user