fix(frontend): sprint 5 — correct API path /simulation-templates → /templates

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Knacky
2026-05-28 06:43:33 +02:00
parent 90fc5bab6c
commit 2b700115e8
5 changed files with 30 additions and 30 deletions

View File

@@ -129,7 +129,7 @@ describe('SimulationList — admin/redteam', () => {
it('opens TemplatePickerModal when "From template…" is clicked', async () => {
mock.onGet('/engagements/42/simulations').reply(200, SIMULATIONS);
mock.onGet('/simulation-templates').reply(200, []);
mock.onGet('/templates').reply(200, []);
const user = userEvent.setup();
renderWithProviders(<SimulationList engagementId={42} />);
await waitFor(() => {

View File

@@ -112,7 +112,7 @@ describe('TemplateFormPage — new mode', () => {
});
it('submits POST when name is filled', async () => {
mock.onPost('/simulation-templates').reply(201, { ...TEMPLATE, id: 99 });
mock.onPost('/templates').reply(201, { ...TEMPLATE, id: 99 });
const user = userEvent.setup();
renderNew();
await user.type(screen.getByLabelText(/Name/i), 'My Template');
@@ -125,7 +125,7 @@ describe('TemplateFormPage — new mode', () => {
});
it('shows backend error on name conflict (409)', async () => {
mock.onPost('/simulation-templates').reply(409, { error: 'template name already exists' });
mock.onPost('/templates').reply(409, { error: 'template name already exists' });
const user = userEvent.setup();
renderNew();
await user.type(screen.getByLabelText(/Name/i), 'Duplicate');
@@ -153,7 +153,7 @@ describe('TemplateFormPage — edit mode', () => {
});
it('loads existing template data into form', async () => {
mock.onGet('/simulation-templates/5').reply(200, TEMPLATE);
mock.onGet('/templates/5').reply(200, TEMPLATE);
renderEdit(5);
await waitFor(() => {
expect(screen.getByDisplayValue('Mimikatz LSASS Dump')).toBeInTheDocument();
@@ -162,7 +162,7 @@ describe('TemplateFormPage — edit mode', () => {
});
it('shows technique and tactic chips from existing template', async () => {
mock.onGet('/simulation-templates/5').reply(200, TEMPLATE);
mock.onGet('/templates/5').reply(200, TEMPLATE);
renderEdit(5);
await waitFor(() => {
expect(screen.getByTitle('T1003 — OS Credential Dumping')).toBeInTheDocument();
@@ -171,7 +171,7 @@ describe('TemplateFormPage — edit mode', () => {
});
it('shows Delete button in edit mode', async () => {
mock.onGet('/simulation-templates/5').reply(200, TEMPLATE);
mock.onGet('/templates/5').reply(200, TEMPLATE);
renderEdit(5);
await waitFor(() => {
expect(screen.getByDisplayValue('Mimikatz LSASS Dump')).toBeInTheDocument();
@@ -180,8 +180,8 @@ describe('TemplateFormPage — edit mode', () => {
});
it('submits PATCH on save', async () => {
mock.onGet('/simulation-templates/5').reply(200, TEMPLATE);
mock.onPatch('/simulation-templates/5').reply(200, { ...TEMPLATE, name: 'Updated' });
mock.onGet('/templates/5').reply(200, TEMPLATE);
mock.onPatch('/templates/5').reply(200, { ...TEMPLATE, name: 'Updated' });
const user = userEvent.setup();
renderEdit(5);
await waitFor(() => {
@@ -196,8 +196,8 @@ describe('TemplateFormPage — edit mode', () => {
});
it('opens delete confirm dialog and calls DELETE on confirm', async () => {
mock.onGet('/simulation-templates/5').reply(200, TEMPLATE);
mock.onDelete('/simulation-templates/5').reply(204);
mock.onGet('/templates/5').reply(200, TEMPLATE);
mock.onDelete('/templates/5').reply(204);
const user = userEvent.setup();
renderEdit(5);
await waitFor(() => {

View File

@@ -51,7 +51,7 @@ describe('TemplatePickerModal', () => {
});
it('shows loading state while fetching', () => {
mock.onGet('/simulation-templates').reply(() => new Promise(() => {}));
mock.onGet('/templates').reply(() => new Promise(() => {}));
renderWithProviders(
<TemplatePickerModal
engagementId={1}
@@ -64,7 +64,7 @@ describe('TemplatePickerModal', () => {
});
it('shows empty state when no templates', async () => {
mock.onGet('/simulation-templates').reply(200, []);
mock.onGet('/templates').reply(200, []);
renderWithProviders(
<TemplatePickerModal
engagementId={1}
@@ -80,7 +80,7 @@ describe('TemplatePickerModal', () => {
});
it('lists templates with name and MITRE count', async () => {
mock.onGet('/simulation-templates').reply(200, TEMPLATES);
mock.onGet('/templates').reply(200, TEMPLATES);
renderWithProviders(
<TemplatePickerModal
engagementId={1}
@@ -99,7 +99,7 @@ describe('TemplatePickerModal', () => {
});
it('calls onSelectTemplate when a template row is clicked', async () => {
mock.onGet('/simulation-templates').reply(200, TEMPLATES);
mock.onGet('/templates').reply(200, TEMPLATES);
const user = userEvent.setup();
renderWithProviders(
<TemplatePickerModal
@@ -117,7 +117,7 @@ describe('TemplatePickerModal', () => {
});
it('calls onClose when Cancel is clicked', async () => {
mock.onGet('/simulation-templates').reply(200, TEMPLATES);
mock.onGet('/templates').reply(200, TEMPLATES);
const user = userEvent.setup();
renderWithProviders(
<TemplatePickerModal
@@ -135,7 +135,7 @@ describe('TemplatePickerModal', () => {
});
it('shows error state on fetch failure', async () => {
mock.onGet('/simulation-templates').reply(500, { error: 'Server error' });
mock.onGet('/templates').reply(500, { error: 'Server error' });
renderWithProviders(
<TemplatePickerModal
engagementId={1}

View File

@@ -59,13 +59,13 @@ describe('TemplatesListPage', () => {
});
it('shows loading state initially', () => {
mock.onGet('/simulation-templates').reply(() => new Promise(() => {}));
mock.onGet('/templates').reply(() => new Promise(() => {}));
renderWithProviders(<TemplatesListPage />);
expect(screen.getByTestId('loading-state')).toBeInTheDocument();
});
it('shows error state on failure', async () => {
mock.onGet('/simulation-templates').reply(500, { error: 'Server error' });
mock.onGet('/templates').reply(500, { error: 'Server error' });
renderWithProviders(<TemplatesListPage />);
await waitFor(() => {
expect(screen.getByTestId('error-state')).toBeInTheDocument();
@@ -73,7 +73,7 @@ describe('TemplatesListPage', () => {
});
it('shows empty state when no templates', async () => {
mock.onGet('/simulation-templates').reply(200, []);
mock.onGet('/templates').reply(200, []);
renderWithProviders(<TemplatesListPage />);
await waitFor(() => {
expect(screen.getByTestId('empty-state')).toBeInTheDocument();
@@ -81,7 +81,7 @@ describe('TemplatesListPage', () => {
});
it('renders template list with name, MITRE count, created by', async () => {
mock.onGet('/simulation-templates').reply(200, TEMPLATES);
mock.onGet('/templates').reply(200, TEMPLATES);
renderWithProviders(<TemplatesListPage />);
await waitFor(() => {
expect(screen.getByText('Mimikatz LSASS Dump')).toBeInTheDocument();
@@ -95,7 +95,7 @@ describe('TemplatesListPage', () => {
});
it('shows New button', async () => {
mock.onGet('/simulation-templates').reply(200, TEMPLATES);
mock.onGet('/templates').reply(200, TEMPLATES);
renderWithProviders(<TemplatesListPage />);
await waitFor(() => {
expect(screen.getByText('Mimikatz LSASS Dump')).toBeInTheDocument();
@@ -104,7 +104,7 @@ describe('TemplatesListPage', () => {
});
it('shows Edit and Delete actions', async () => {
mock.onGet('/simulation-templates').reply(200, TEMPLATES);
mock.onGet('/templates').reply(200, TEMPLATES);
renderWithProviders(<TemplatesListPage />);
await waitFor(() => {
expect(screen.getByText('Mimikatz LSASS Dump')).toBeInTheDocument();
@@ -114,10 +114,10 @@ describe('TemplatesListPage', () => {
});
it('calls delete endpoint on confirm', async () => {
mock.onGet('/simulation-templates').reply(200, TEMPLATES);
mock.onDelete('/simulation-templates/1').reply(204);
mock.onGet('/templates').reply(200, TEMPLATES);
mock.onDelete('/templates/1').reply(204);
// After delete, refetch returns updated list
mock.onGet('/simulation-templates').reply(200, [TEMPLATES[1]]);
mock.onGet('/templates').reply(200, [TEMPLATES[1]]);
const user = userEvent.setup();
const confirmSpy = vi.spyOn(window, 'confirm').mockReturnValue(true);