fix(cv): restore distinct responsive templates

This commit is contained in:
cesnimda
2026-09-01 08:54:03 +02:00
parent 9252e43ad4
commit c8b4c33acd
8 changed files with 161 additions and 23 deletions
@@ -172,6 +172,50 @@ test('professional editor starts with templates and combines design and layout c
expect(screen.getByText('Check spelling and grammar')).toBeInTheDocument();
});
test('choosing a template restores its own structure instead of inheriting the previous template layout', async () => {
const customizedVariant = {
...variant,
settings: {
...emptyCvVariantSettings(),
themeId: 'minimal',
layout: 'single',
headerStyle: 'plain',
headingStyle: 'plain',
sidebarWidthMm: 72,
sidebarSections: ['skills'],
accentColor: '#123456',
},
};
mockedApi.get.mockImplementation((url: string) => {
if (url === '/cv/variants/3') return Promise.resolve({ data: customizedVariant } as any);
if (url === '/cv/themes') return Promise.resolve({ data: [
{ id: 'minimal', name: 'Minimal', category: 'ATS', description: 'Quiet single column', layout: 'single', available: true, swatches: ['#111827', '#fff', '#fff'] },
{ id: 'technical', name: 'Technical', category: 'Technical', description: 'Structured sidebar', layout: 'sidebar-left', available: true, swatches: ['#0f4c5c', '#0f4c5c', '#fff'] },
] } as any);
if (url === '/cv/outline') return Promise.resolve({ data: { sections: [] } } as any);
if (url.startsWith('/cv/themes/')) return Promise.resolve({ data: { themeId: url.includes('technical') ? 'technical' : 'minimal', html: '<p>preview</p>', suggestedFileName: 'preview.pdf' } } as any);
return Promise.resolve({ data: [] } as any);
});
mockedApi.put.mockResolvedValue({ data: customizedVariant } as any);
renderAt(3);
await screen.findByDisplayValue('Backend CV');
fireEvent.click(screen.getByRole('button', { name: /Technical/ }));
fireEvent.click(screen.getByRole('button', { name: 'Save now' }));
await waitFor(() => expect(mockedApi.put).toHaveBeenCalledWith('/cv/variants/3', expect.objectContaining({
settings: expect.objectContaining({
themeId: 'technical',
layout: null,
headerStyle: null,
headingStyle: null,
sidebarWidthMm: null,
sidebarSections: null,
accentColor: '#123456',
}),
})));
});
test('editor sections, design controls and document settings render in Bokmål', async () => {
window.localStorage.setItem('uiLanguage', 'nb');
routeGet(() => Promise.resolve({ data: variant } as any));