fix(dayplan): the delete question asks inside the day dialog, and its buttons stay small

Deleting a day no longer stacks a second dialog over the reorder dialog. The
dialog swaps its list for the question at the same size and in the same place;
Cancel and Escape bring the list back with the focus on the row asked about.
The foot is one row of normal sized buttons with the hint line above it, the
undated day is labelled "Without date" in every language, and the dialog is a
step wider so no label breaks. The list of what goes with a day is quieter: a
cancelled stay tints its whole row, a day with nothing on it is one plain line.
On the phone the add buttons are two pills under the scrolling list, and the
confirm sheet moves a long label to its own row instead of breaking it.
This commit is contained in:
Maurice
2026-09-23 21:41:05 +02:00
parent f3ca0b1a4c
commit 83be759c49
44 changed files with 625 additions and 315 deletions
@@ -2,7 +2,7 @@ import { describe, it, expect, vi } from 'vitest'
import { fireEvent, render, screen } from '@testing-library/react'
import MConfirmSheet from '../../../../src/mobile/screens/settings/MConfirmSheet'
// FE-MOB-CONFIRM-001 to FE-MOB-CONFIRM-003
// FE-MOB-CONFIRM-001 to FE-MOB-CONFIRM-004
describe('MConfirmSheet', () => {
it('FE-MOB-CONFIRM-001: a long list scrolls between the title and the buttons, which stay in reach', () => {
@@ -43,4 +43,11 @@ describe('MConfirmSheet', () => {
render(<MConfirmSheet open onClose={vi.fn()} title="Heads up" message="Nothing to confirm." cancelLabel="OK" />)
expect(screen.getAllByRole('button').map(b => b.textContent)).toEqual(['OK'])
})
it('FE-MOB-CONFIRM-004: a long label never wraps inside its button; the row makes room instead', () => {
render(<MConfirmSheet open onClose={vi.fn()} title="Remove days?" message="Saving removes these days:" confirmLabel="Retirer les jours et enregistrer" cancelLabel="Annuler" danger onConfirm={vi.fn()} />)
const confirm = screen.getByRole('button', { name: 'Retirer les jours et enregistrer' })
expect(confirm).toHaveClass('whitespace-nowrap')
expect(screen.getByRole('button', { name: 'Annuler' })).toHaveClass('whitespace-nowrap')
expect(confirm.parentElement).toHaveClass('flex-wrap')
})
})
@@ -6,7 +6,7 @@ import { buildPlanner, buildShell } from '../../../helpers/mobileTrip'
import { resetAllStores } from '../../../helpers/store'
import { cleanup, fireEvent, render, screen } from '../../../helpers/render'
// FE-MOB-DAYSS-001 to FE-MOB-DAYSS-019
// FE-MOB-DAYSS-001 to FE-MOB-DAYSS-020
//
// The sheet reads its copy from the real TranslationProvider (useTranslation),
// not from planner.t — assertions therefore go against the English strings.
@@ -148,46 +148,61 @@ describe('MDaysSheet', () => {
const dayAdd = (overrides: Partial<TripPlanner['dayAdd']> = {}): TripPlanner['dayAdd'] => ({
nextDate: '2026-10-13', blocked: null, datedBlocked: null, busy: false, onAddDated: vi.fn(), ...overrides,
})
const datedTile = () => screen.getByRole('button', { name: /^Add .*Oct 13/ })
const undatedTile = () => screen.getByRole('button', { name: /^Add day without date/ })
const datedButton = () => screen.getByRole('button', { name: /^Add .*Oct 13/ })
const undatedButton = () => screen.getByRole('button', { name: 'Without date' })
it('FE-MOB-DAYSS-016: two tiles, the next date and a day without one, each with what it does', () => {
it('FE-MOB-DAYSS-016: two buttons, the next date and a day without one, under a line saying what the dated one does', () => {
const { planner } = renderSheet({ dayAdd: dayAdd() })
// formatDate adds the year once the date lies outside the current year.
expect(datedTile()).toHaveTextContent(/Extends the trip by one day, until .*Oct 13(, \d{4})?\./)
expect(undatedTile()).toHaveTextContent('The trip dates stay as they are.')
expect(screen.getByText(/^Extends the trip by one day, until .*Oct 13(, \d{4})?\.$/)).toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'Add day' })).not.toBeInTheDocument()
fireEvent.click(datedTile())
fireEvent.click(datedButton())
expect(planner.dayAdd.onAddDated).toHaveBeenCalledTimes(1)
expect(planner.handleAddDay).not.toHaveBeenCalled()
fireEvent.click(undatedTile())
fireEvent.click(undatedButton())
expect(planner.handleAddDay).toHaveBeenCalledTimes(1)
})
it('FE-MOB-DAYSS-017: a read-only member gets neither tile', () => {
it('FE-MOB-DAYSS-017: a read-only member gets neither button', () => {
renderSheet({ can: vi.fn(() => false), dayAdd: dayAdd() })
expect(screen.queryByRole('button', { name: /^Add/ })).not.toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'Without date' })).not.toBeInTheDocument()
})
it('FE-MOB-DAYSS-018: busy or offline turns both off, and the offline sentence is said once', () => {
renderSheet({ dayAdd: dayAdd({ busy: true }) })
expect(datedTile()).toBeDisabled()
expect(undatedTile()).toBeDisabled()
expect(datedButton()).toBeDisabled()
expect(undatedButton()).toBeDisabled()
cleanup()
const offline = 'Changing days needs a connection'
renderSheet({ deleteDayBlocked: offline, dayAdd: dayAdd({ blocked: offline }) })
expect(datedTile()).toBeDisabled()
expect(undatedTile()).toBeDisabled()
expect(datedButton()).toBeDisabled()
expect(undatedButton()).toBeDisabled()
expect(screen.getAllByText(offline)).toHaveLength(1)
// The offline sentence stands in for the dated line, not beside it.
expect(screen.queryByText(/^Extends the trip/)).not.toBeInTheDocument()
})
it('FE-MOB-DAYSS-019: a trip at the day limit keeps the undated tile and says why the dated one is off', () => {
it('FE-MOB-DAYSS-019: a trip at the day limit keeps the undated button and says why the dated one is off', () => {
renderSheet({ dayAdd: dayAdd({ datedBlocked: 'A trip can span at most 999 days' }) })
expect(datedTile()).toBeDisabled()
expect(datedTile()).toHaveTextContent('A trip can span at most 999 days')
expect(undatedTile()).toBeEnabled()
expect(datedButton()).toBeDisabled()
expect(screen.getByText('A trip can span at most 999 days')).toBeInTheDocument()
expect(undatedButton()).toBeEnabled()
})
it('FE-MOB-DAYSS-020: the add buttons stay in reach below the list, which scrolls on its own', () => {
renderSheet({ dayAdd: dayAdd() })
const list = screen.getByText('Old Town').closest('.overflow-y-auto')
expect(list).not.toBeNull()
expect(list).not.toContainElement(datedButton())
expect(list).not.toContainElement(undatedButton())
// One tap size for both, and a label that never wraps inside its button.
for (const button of [datedButton(), undatedButton()]) {
expect(button).toHaveClass('h-11')
expect(button).toHaveClass('whitespace-nowrap')
}
})
})
})