Trening: „Norma spelniona” otwiera od razu suwak trudnosci (brak reklickania w oknie serii)

This commit is contained in:
Tilumca
2026-10-14 21:19:48 +02:00
parent 50d4f1d950
commit edb21efb44
3 changed files with 32 additions and 8 deletions

View File

@@ -281,6 +281,9 @@ export function SetEditDialog({
reps: planned.reps?.toString() ?? '',
rir: planned.rir?.toString() ?? '',
}));
// wygoda: norma to wpis z automatu, trudnośc ocenia sam trenujący —
// od razu otwieramy suwak, zamiast kazać przeklikiwac sie rece
setEditingField('difficulty');
};
return (

View File

@@ -261,6 +261,16 @@ async function openActiveDay(user: userEvent.User) {
expect(await screen.findByText('W trakcie')).toBeInTheDocument();
}
/**
* „Norma spełniona” wypełnia powtórzenia/RIR i od razu otwiera suwak trudności —
* helper zatwierdza suwak („Wpisz”), żeby wrócić do okna serii przed „Zapisz”.
*/
async function fillNormAndConfirmSlider(user: userEvent.User) {
await user.click(screen.getByRole('button', { name: 'Norma spełniona' }));
await screen.findByRole('heading', { name: 'Trudność' });
await user.click(screen.getByRole('button', { name: 'Wpisz' }));
}
beforeEach(async () => {
await new Promise((r) => setTimeout(r, 25));
setAccessToken(null);
@@ -414,7 +424,11 @@ describe('Kolejka serii w sesji', () => {
expect(normBtn).toBeInTheDocument();
// kliknięcie wypełnia wartości z planu (powt. 8, RIR 2)
// i od razu otwiera suwak trudności — bez ręcznego przeklikiwania się do niego
await user.click(normBtn);
await screen.findByRole('heading', { name: 'Trudność' });
expect(screen.getByRole('slider', { name: 'Trudność (suwak)' })).toBeInTheDocument();
await user.click(screen.getByRole('button', { name: 'Wpisz' }));
expect(screen.getByRole('button', { name: /Powtórzenia/ })).toHaveTextContent('8');
expect(screen.getByRole('button', { name: /RIR/ })).toHaveTextContent('2');
});
@@ -463,7 +477,7 @@ describe('Kolejka serii w sesji', () => {
// ss-2 jest pusta — uzupełnij ją („Norma spełniona” wypełnia wartości) i zapisz
await user.click(screen.getAllByRole('button', { name: 'Uzupełnij serię' })[0]);
await screen.findByRole('heading', { name: 'Uzupełnij serię 2' });
await user.click(screen.getByRole('button', { name: 'Norma spełniona' }));
await fillNormAndConfirmSlider(user);
await user.click(screen.getByRole('button', { name: 'Zapisz' }));
// odliczanie startuje: format mm:ss + przycisk „Zakończ”
@@ -480,7 +494,7 @@ describe('Kolejka serii w sesji', () => {
// uzupełnij ss-1 i zapisz — startuje odliczanie przerwy (90 s z planu)
await user.click(screen.getAllByRole('button', { name: 'Uzupełnij serię' })[0]);
await screen.findByRole('heading', { name: 'Uzupełnij serię 1' });
await user.click(screen.getByRole('button', { name: 'Norma spełniona' }));
await fillNormAndConfirmSlider(user);
await user.click(screen.getByRole('button', { name: 'Zapisz' }));
expect(await screen.findByRole('button', { name: 'Zakończ' })).toBeInTheDocument();
@@ -502,7 +516,7 @@ describe('Kolejka serii w sesji', () => {
// uzupełnij ss-1 i zapisz — startuje odliczanie przerwy
await user.click(screen.getAllByRole('button', { name: 'Uzupełnij serię' })[0]);
await screen.findByRole('heading', { name: 'Uzupełnij serię 1' });
await user.click(screen.getByRole('button', { name: 'Norma spełniona' }));
await fillNormAndConfirmSlider(user);
await user.click(screen.getByRole('button', { name: 'Zapisz' }));
expect(await screen.findByRole('button', { name: 'Zakończ' })).toBeInTheDocument();
@@ -523,7 +537,7 @@ describe('Kolejka serii w sesji', () => {
// uzupełnij ss-1 i zapisz — startuje odliczanie przerwy (rodzic re-renderuje co sekundę)
await user.click(screen.getAllByRole('button', { name: 'Uzupełnij serię' })[0]);
await screen.findByRole('heading', { name: 'Uzupełnij serię 1' });
await user.click(screen.getByRole('button', { name: 'Norma spełniona' }));
await fillNormAndConfirmSlider(user);
await user.click(screen.getByRole('button', { name: 'Zapisz' }));
expect(await screen.findByRole('button', { name: 'Zakończ' })).toBeInTheDocument();
@@ -549,7 +563,7 @@ describe('Kolejka serii w sesji', () => {
await user.click(screen.getAllByRole('button', { name: 'Uzupełnij serię' })[0]);
await screen.findByRole('heading', { name: 'Uzupełnij serię 1' });
await user.click(screen.getByRole('button', { name: 'Norma spełniona' }));
await fillNormAndConfirmSlider(user);
// „Norma spełniona” nie czyści komentarza
await user.type(screen.getByRole('textbox', { name: 'Komentarz do serii' }), 'ostatnia seria ciężka');
await user.click(screen.getByRole('button', { name: 'Zapisz' }));
@@ -615,7 +629,7 @@ describe('Kolejka serii w sesji', () => {
await user.click(screen.getAllByRole('button', { name: 'Uzupełnij serię' })[0]);
await screen.findByRole('heading', { name: 'Uzupełnij serię 1' });
await user.click(screen.getByRole('button', { name: 'Norma spełniona' }));
await fillNormAndConfirmSlider(user);
await user.click(screen.getByRole('button', { name: 'Zapisz' }));
// odliczanie widoczne mimo nierozstrzygniętego żądania
@@ -630,7 +644,7 @@ describe('Kolejka serii w sesji', () => {
await user.click(screen.getAllByRole('button', { name: 'Uzupełnij serię' })[0]);
await screen.findByRole('heading', { name: 'Uzupełnij serię 1' });
await user.click(screen.getByRole('button', { name: 'Norma spełniona' }));
await fillNormAndConfirmSlider(user);
await user.click(screen.getByRole('button', { name: 'Zapisz' }));
expect(await screen.findByText('awaria serwera')).toBeInTheDocument();
@@ -646,7 +660,7 @@ describe('Kolejka serii w sesji', () => {
await user.click(screen.getAllByRole('button', { name: 'Uzupełnij serię' })[0]);
await screen.findByRole('heading', { name: 'Uzupełnij serię 1' });
await user.click(screen.getByRole('button', { name: 'Norma spełniona' }));
await fillNormAndConfirmSlider(user);
await user.click(screen.getByRole('button', { name: 'Zapisz' }));
expect(await screen.findByRole('button', { name: 'Zakończ' })).toBeInTheDocument();

View File

@@ -78,6 +78,9 @@ test('okno „Uzupełnij serię” pokazuje timer trwającej przerwy', async ({
// uzupełnij ss-1 i zapisz — startuje odliczanie przerwy (rest 90 s z planu)
await page.getByRole('button', { name: 'Uzupełnij serię' }).first().click();
await page.getByRole('button', { name: 'Norma spełniona' }).click();
// norma od razu otwiera suwak trudności — zatwierdź go przed zapisem
await expect(page.getByRole('heading', { name: 'Trudność' })).toBeVisible();
await page.getByRole('button', { name: 'Wpisz' }).click();
await page.getByRole('button', { name: 'Zapisz' }).click();
await expect(page.getByRole('button', { name: 'Zakończ' })).toBeVisible();
@@ -130,7 +133,11 @@ test('przycisk „Norma spełniona” wypełnia wartości z planu', async ({ pag
await expect(page.getByRole('heading', { name: 'Uzupełnij serię 1' })).toBeVisible();
// przycisk „Norma spełniona” wypełnia powtórzenia z planu
// i od razu otwiera suwak trudności (bez ręcznego przeklikiwania)
await page.getByRole('button', { name: 'Norma spełniona' }).click();
await expect(page.getByRole('heading', { name: 'Trudność' })).toBeVisible();
await expect(page.getByRole('slider', { name: 'Trudność (suwak)' })).toBeVisible();
await page.getByRole('button', { name: 'Wpisz' }).click();
await expect(page.getByRole('button', { name: /Powtórzenia/ })).toContainText('10');
});