feat(cv): structure custom section entries
CI and Deploy / test (pull_request) Failing after 1m32s
CI and Deploy / deploy (pull_request) Has been skipped

This commit is contained in:
cesnimda
2026-08-09 19:14:06 +02:00
parent df89a69306
commit a5b74e0ab8
2 changed files with 83 additions and 5 deletions
@@ -133,3 +133,43 @@ test('internal navigation warns and can be cancelled before discarding a pending
expect(screen.getByDisplayValue('Backend CV')).toBeInTheDocument();
confirm.mockRestore();
});
test('custom entries can be added, edited, reordered and deleted with confirmation', async () => {
routeGet(() => Promise.resolve({ data: variant } as any));
mockedApi.put.mockResolvedValue({ data: variant } as any);
const confirm = jest.spyOn(window, 'confirm');
renderAt(3);
await screen.findByLabelText('Headline override');
fireEvent.click(screen.getByRole('button', { name: 'Add' }));
fireEvent.change(screen.getByLabelText('Custom section title'), { target: { value: 'Selected projects' } });
fireEvent.click(screen.getByRole('button', { name: 'Add entry' }));
fireEvent.change(screen.getByLabelText('Entry 1'), { target: { value: 'First project' } });
fireEvent.click(screen.getByRole('button', { name: 'Add entry' }));
fireEvent.change(screen.getByLabelText('Entry 2'), { target: { value: 'Second project' } });
fireEvent.click(screen.getByRole('button', { name: 'Move custom entry 2 up' }));
expect(screen.getByLabelText('Entry 1')).toHaveValue('Second project');
expect(screen.getByLabelText('Entry 2')).toHaveValue('First project');
confirm.mockReturnValueOnce(false).mockReturnValueOnce(true);
fireEvent.click(screen.getByRole('button', { name: 'Delete custom entry 1' }));
expect(screen.getAllByLabelText(/^Entry /)).toHaveLength(2);
fireEvent.click(screen.getByRole('button', { name: 'Delete custom entry 1' }));
expect(screen.getAllByLabelText(/^Entry /)).toHaveLength(1);
fireEvent.click(screen.getByRole('button', { name: 'Save now' }));
expect(await screen.findByText('Saved')).toBeInTheDocument();
expect(mockedApi.put).toHaveBeenLastCalledWith('/cv/variants/3', expect.objectContaining({
settings: expect.objectContaining({
customSections: [expect.objectContaining({ title: 'Selected projects', items: ['First project'] })],
}),
}));
confirm.mockReturnValueOnce(false).mockReturnValueOnce(true);
fireEvent.click(screen.getByRole('button', { name: 'Remove custom section' }));
expect(screen.getByLabelText('Custom section title')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: 'Remove custom section' }));
expect(screen.queryByLabelText('Custom section title')).not.toBeInTheDocument();
confirm.mockRestore();
});