2026-10-22 23:28:02 +02:00
|
|
|
|
import { render, screen } from '@testing-library/react';
|
2026-10-22 23:34:42 +02:00
|
|
|
|
import { describe, it, expect } from 'vitest';
|
2026-10-22 23:28:02 +02:00
|
|
|
|
import { ExerciseEditor } from '../src/pages/plans/plan-editor/ExerciseEditor';
|
|
|
|
|
|
import type { EditorExercise } from '../src/pages/plans/plan-editor/types';
|
2026-10-22 23:40:53 +02:00
|
|
|
|
import type { Exercise } from '../src/api/types';
|
2026-10-22 23:28:02 +02:00
|
|
|
|
|
|
|
|
|
|
const LONG_NAME = 'Wiosłowanie sztangą nachwytem w pełnym opadzie tułowia';
|
|
|
|
|
|
|
|
|
|
|
|
const EXERCISE: EditorExercise = {
|
|
|
|
|
|
exerciseId: 'ex-1',
|
|
|
|
|
|
sets: [{ reps: '10', loadKg: '50', restSec: '90', rir: '2' }],
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-10-22 23:40:53 +02:00
|
|
|
|
const META = { id: 'ex-1', name: LONG_NAME, primaryMuscle: 'core' } as Exercise;
|
|
|
|
|
|
|
|
|
|
|
|
function renderEditor(exerciseMeta?: Exercise) {
|
2026-10-22 23:28:02 +02:00
|
|
|
|
return render(
|
|
|
|
|
|
<ExerciseEditor
|
|
|
|
|
|
exercise={EXERCISE}
|
2026-10-22 23:40:53 +02:00
|
|
|
|
exerciseMeta={exerciseMeta}
|
2026-10-22 23:28:02 +02:00
|
|
|
|
exerciseName={() => LONG_NAME}
|
|
|
|
|
|
isTraineeMode={false}
|
|
|
|
|
|
resultsOpen={false}
|
|
|
|
|
|
onToggleResults={() => {}}
|
|
|
|
|
|
onRemove={() => {}}
|
|
|
|
|
|
onMoveUp={() => {}}
|
|
|
|
|
|
onMoveDown={() => {}}
|
|
|
|
|
|
canMoveUp={false}
|
|
|
|
|
|
canMoveDown={false}
|
|
|
|
|
|
onSetField={() => {}}
|
|
|
|
|
|
onAddSetCopy={() => {}}
|
|
|
|
|
|
onRemoveSet={() => {}}
|
|
|
|
|
|
latest={undefined}
|
|
|
|
|
|
points={[]}
|
|
|
|
|
|
onPrefill={() => {}}
|
|
|
|
|
|
/>,
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-22 23:34:42 +02:00
|
|
|
|
describe('ExerciseEditor — długa nazwa ćwiczenia', () => {
|
|
|
|
|
|
it('nazwa i podsumowanie serii łamią się zamiast być przycinane', () => {
|
2026-10-22 23:28:02 +02:00
|
|
|
|
renderEditor();
|
|
|
|
|
|
|
2026-10-22 23:34:42 +02:00
|
|
|
|
const name = screen.getByText(LONG_NAME);
|
|
|
|
|
|
expect(name.tagName).toBe('STRONG');
|
|
|
|
|
|
expect(name).toHaveClass('break-words');
|
|
|
|
|
|
expect(name).not.toHaveClass('truncate');
|
2026-10-22 23:28:02 +02:00
|
|
|
|
|
2026-10-22 23:34:42 +02:00
|
|
|
|
const summary = screen.getByText('1×10 @ 50 kg · RIR 2');
|
2026-10-22 23:37:15 +02:00
|
|
|
|
expect(summary).toHaveClass('whitespace-nowrap');
|
2026-10-22 23:34:42 +02:00
|
|
|
|
expect(summary).not.toHaveClass('truncate');
|
2026-10-22 23:28:02 +02:00
|
|
|
|
});
|
2026-10-22 23:40:53 +02:00
|
|
|
|
|
|
|
|
|
|
it('badge mięśnia i podsumowanie tworzą jedną grupę łamaną razem', () => {
|
|
|
|
|
|
renderEditor(META);
|
|
|
|
|
|
|
|
|
|
|
|
const name = screen.getByText(LONG_NAME);
|
|
|
|
|
|
const badge = screen.getByText('Core');
|
|
|
|
|
|
const summary = screen.getByText('1×10 @ 50 kg · RIR 2');
|
|
|
|
|
|
expect(badge.parentElement).toBe(summary.parentElement);
|
|
|
|
|
|
expect(name.parentElement).not.toBe(summary.parentElement);
|
|
|
|
|
|
});
|
2026-10-22 23:28:02 +02:00
|
|
|
|
});
|