feat(frontend): i18n MITRE components (matrix modal, picker, field, tag)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Knacky
2026-06-21 23:41:32 +02:00
parent 284494cee8
commit bdda02b07a
8 changed files with 69 additions and 60 deletions

View File

@@ -124,7 +124,7 @@ describe('MitreMatrixModal', () => {
);
await user.click(t1078Btn!);
await user.click(screen.getByRole('button', { name: /Apply/i }));
await user.click(screen.getByRole('button', { name: /Appliquer/i }));
expect(onApply).toHaveBeenCalledWith(
expect.objectContaining({
@@ -148,7 +148,7 @@ describe('MitreMatrixModal', () => {
/>,
);
await user.click(screen.getByRole('button', { name: /Cancel/i }));
await user.click(screen.getByRole('button', { name: /Fermer/i }));
expect(onCancel).toHaveBeenCalled();
expect(onApply).not.toHaveBeenCalled();
@@ -202,7 +202,7 @@ describe('MitreMatrixModal', () => {
await waitFor(() => screen.getByText('T1078'));
const searchInput = screen.getByPlaceholderText(/Filter techniques/i);
const searchInput = screen.getByPlaceholderText(/Filtrer/i);
await user.type(searchInput, 'T1059');
expect(screen.queryByText('T1078')).toBeNull();
@@ -242,7 +242,7 @@ describe('MitreMatrixModal', () => {
);
await waitFor(() => {
expect(screen.getByRole('button', { name: /Apply 1 item/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /Appliquer \(1 élément\)/i })).toBeInTheDocument();
});
});
@@ -259,11 +259,11 @@ describe('MitreMatrixModal', () => {
await waitFor(() => screen.getByText('T1078'));
const applyBtn = screen.getByRole('button', { name: /Clear all/i });
const applyBtn = screen.getByRole('button', { name: /Tout effacer/i });
expect(applyBtn).toBeDisabled();
});
it('Apply button shows "Clear all" and is enabled when initial selection is deselected', async () => {
it('Apply button shows "Tout effacer" and is enabled when initial selection is deselected', async () => {
const onApply = vi.fn();
const user = userEvent.setup();
@@ -284,7 +284,7 @@ describe('MitreMatrixModal', () => {
);
await user.click(t1078Btn!);
const applyBtn = screen.getByRole('button', { name: /Clear all/i });
const applyBtn = screen.getByRole('button', { name: /Tout effacer/i });
expect(applyBtn).not.toBeDisabled();
await user.click(applyBtn);
expect(onApply).toHaveBeenCalledWith(

View File

@@ -30,7 +30,7 @@ describe('MitreTechniquePicker', () => {
vi.useRealTimers();
renderWithProviders(<MitreTechniquePicker onSelect={vi.fn()} />);
expect(screen.getByRole('combobox')).toBeInTheDocument();
expect(screen.getByPlaceholderText(/Search by ID or name/i)).toBeInTheDocument();
expect(screen.getByPlaceholderText(/Rechercher une technique/i)).toBeInTheDocument();
});
it('is disabled when disabled prop is true', () => {

View File

@@ -23,7 +23,7 @@ describe('MitreTechniqueTag', () => {
renderWithProviders(
<MitreTechniqueTag technique={TECHNIQUE} onRemove={vi.fn()} />,
);
expect(screen.getByRole('button', { name: /Remove T1059/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /Retirer T1059/i })).toBeInTheDocument();
});
it('clicking × calls onRemove', async () => {
@@ -32,7 +32,7 @@ describe('MitreTechniqueTag', () => {
renderWithProviders(
<MitreTechniqueTag technique={TECHNIQUE} onRemove={onRemove} />,
);
await user.click(screen.getByRole('button', { name: /Remove T1059/i }));
await user.click(screen.getByRole('button', { name: /Retirer T1059/i }));
expect(onRemove).toHaveBeenCalledOnce();
});
@@ -40,7 +40,7 @@ describe('MitreTechniqueTag', () => {
renderWithProviders(
<MitreTechniqueTag technique={TECHNIQUE} onRemove={vi.fn()} disabled />,
);
expect(screen.queryByRole('button', { name: /Remove/i })).toBeNull();
expect(screen.queryByRole('button', { name: /Retirer/i })).toBeNull();
});
});
@@ -57,7 +57,7 @@ describe('MitreTacticTag', () => {
renderWithProviders(
<MitreTacticTag tactic={TACTIC} onRemove={vi.fn()} />,
);
expect(screen.getByRole('button', { name: /Remove TA0007/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /Retirer TA0007/i })).toBeInTheDocument();
});
it('clicking × calls onRemove', async () => {
@@ -66,7 +66,7 @@ describe('MitreTacticTag', () => {
renderWithProviders(
<MitreTacticTag tactic={TACTIC} onRemove={onRemove} />,
);
await user.click(screen.getByRole('button', { name: /Remove TA0007/i }));
await user.click(screen.getByRole('button', { name: /Retirer TA0007/i }));
expect(onRemove).toHaveBeenCalledOnce();
});
@@ -74,6 +74,6 @@ describe('MitreTacticTag', () => {
renderWithProviders(
<MitreTacticTag tactic={TACTIC} onRemove={vi.fn()} disabled />,
);
expect(screen.queryByRole('button', { name: /Remove/i })).toBeNull();
expect(screen.queryByRole('button', { name: /Retirer/i })).toBeNull();
});
});

View File

@@ -48,7 +48,7 @@ describe('MitreTechniquesField', () => {
renderWithProviders(
<MitreTechniquesField value={[]} tactics={[]} simulationId={7} engagementId={42} />,
);
expect(screen.getByText(/No techniques selected/i)).toBeInTheDocument();
expect(screen.getByText(/Aucune technique associée/i)).toBeInTheDocument();
});
it('renders technique tags for each technique', () => {
@@ -72,16 +72,16 @@ describe('MitreTechniquesField', () => {
renderWithProviders(
<MitreTechniquesField value={[]} tactics={[]} simulationId={7} engagementId={42} />,
);
expect(screen.getByRole('button', { name: /Open MITRE matrix/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /Ouvrir la matrice/i })).toBeInTheDocument();
// The search placeholder button
expect(screen.getByRole('button', { name: /Search technique/i })).toBeInTheDocument();
expect(screen.getByRole('button', { name: /Rechercher une technique/i })).toBeInTheDocument();
});
it('hides input row when disabled', () => {
renderWithProviders(
<MitreTechniquesField value={[T1059]} tactics={[]} simulationId={7} engagementId={42} disabled />,
);
expect(screen.queryByRole('button', { name: /Open MITRE matrix/i })).toBeNull();
expect(screen.queryByRole('button', { name: /Ouvrir la matrice/i })).toBeNull();
});
it('× button on technique tag calls PATCH with technique removed', async () => {
@@ -94,7 +94,7 @@ describe('MitreTechniquesField', () => {
<MitreTechniquesField value={[T1059, T1078]} tactics={[]} simulationId={7} engagementId={42} />,
);
const removeBtn = screen.getByRole('button', { name: /Remove T1059/i });
const removeBtn = screen.getByRole('button', { name: /Retirer T1059/i });
await user.click(removeBtn);
await waitFor(() => {
@@ -115,7 +115,7 @@ describe('MitreTechniquesField', () => {
<MitreTechniquesField value={[T1059]} tactics={[TA0007]} simulationId={7} engagementId={42} />,
);
const removeBtn = screen.getByRole('button', { name: /Remove TA0007/i });
const removeBtn = screen.getByRole('button', { name: /Retirer TA0007/i });
await user.click(removeBtn);
await waitFor(() => {
@@ -131,7 +131,7 @@ describe('MitreTechniquesField', () => {
renderWithProviders(
<MitreTechniquesField value={[]} tactics={[]} simulationId={7} engagementId={42} />,
);
await user.click(screen.getByRole('button', { name: /Search technique/i }));
await user.click(screen.getByRole('button', { name: /Rechercher une technique/i }));
expect(screen.getByRole('combobox')).toBeInTheDocument();
});
@@ -142,7 +142,7 @@ describe('MitreTechniquesField', () => {
<MitreTechniquesField value={[T1059]} tactics={[]} simulationId={7} engagementId={42} />,
);
await user.click(screen.getByRole('button', { name: /Search technique/i }));
await user.click(screen.getByRole('button', { name: /Rechercher une technique/i }));
const combobox = screen.getByRole('combobox');
await user.type(combobox, 'T1059');
@@ -161,7 +161,7 @@ describe('MitreTechniquesField', () => {
renderWithProviders(
<MitreTechniquesField value={[]} tactics={[]} simulationId={7} engagementId={42} />,
);
await user.click(screen.getByRole('button', { name: /Open MITRE matrix/i }));
await user.click(screen.getByRole('button', { name: /Ouvrir la matrice/i }));
expect(screen.getByRole('dialog')).toBeInTheDocument();
});
});