mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 02:56:10 +00:00
a3f6635633
Tags on the place form are pills in their own colour, with a palette under the dot that recolours a tag for the whole trip (PUT /trips/:id/tags/:id was there already, the client now reaches it through repo and store) and a custom colour field of its own instead of the system picker. A new tag is made in a colour picked the same way. Description, notes and the note for one day's visit sit in one card under a switch, each with a line on where the text shows up; the day tab is named after its day and is only there with one visit in context. Nothing about the three fields changes underneath. Opening hours get a switch for open around the clock next to closed. Google writes a place open all week as one period on Sunday that never closes; it read as Sunday open and every other day closed, and now opens every day. The phone form follows the desktop: category as one field with a list, tags in one field, the texts switch, and phone, e-mail and opening hours, which it did not have. The hours and the text tabs are shared hooks (usePlaceHours, usePlaceTextTabs). Files and costs on the phone sheets are drawn as fields like the rest, and the paste hint, a keyboard shortcut a phone has no use for, is gone with its key.
67 lines
3.0 KiB
TypeScript
67 lines
3.0 KiB
TypeScript
// FE-PLANNER-PLFORMTEXTS-001 to FE-PLANNER-PLFORMTEXTS-004: the place form's three texts in one card.
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
import { fireEvent, render, screen, within } from '../../../tests/helpers/render';
|
|
import { PlaceFormTexts } from './PlaceFormTexts';
|
|
|
|
const t = (key: string, params?: Record<string, string | number>) =>
|
|
params ? `${key}:${Object.values(params).join(',')}` : key;
|
|
|
|
function renderTexts(overrides: Partial<Parameters<typeof PlaceFormTexts>[0]> = {}) {
|
|
const onChange = vi.fn();
|
|
render(
|
|
<PlaceFormTexts
|
|
fieldId="f"
|
|
description="A tower"
|
|
notes=""
|
|
dayNotes={null}
|
|
onChange={onChange}
|
|
t={t}
|
|
{...overrides}
|
|
/>
|
|
);
|
|
return onChange;
|
|
}
|
|
|
|
const tabs = () => within(screen.getByRole('group', { name: 'places.notesKind' }));
|
|
|
|
describe('PlaceFormTexts', () => {
|
|
it('FE-PLANNER-PLFORMTEXTS-001: shows one text at a time, with the line on where it appears', () => {
|
|
renderTexts();
|
|
expect(tabs().getByRole('button', { name: 'places.notesTabAbout' })).toHaveAttribute('aria-pressed', 'true');
|
|
expect(screen.getByLabelText('places.formDescription')).toBeVisible();
|
|
expect(screen.getByLabelText('places.formNotes')).not.toBeVisible();
|
|
expect(screen.getByLabelText('places.formDescription')).toHaveAccessibleDescription('places.notesHintDescription');
|
|
|
|
fireEvent.click(tabs().getByRole('button', { name: 'places.formNotes' }));
|
|
expect(screen.getByLabelText('places.formNotes')).toBeVisible();
|
|
expect(screen.getByLabelText('places.formDescription')).not.toBeVisible();
|
|
});
|
|
|
|
it('FE-PLANNER-PLFORMTEXTS-002: each text writes its own field, and both keep their text while hidden', () => {
|
|
const onChange = renderTexts({ notes: 'Book ahead' });
|
|
fireEvent.change(screen.getByLabelText('places.formDescription'), { target: { value: 'A tall tower' } });
|
|
expect(onChange).toHaveBeenLastCalledWith('description', 'A tall tower');
|
|
expect(screen.getByLabelText('places.formNotes')).toHaveValue('Book ahead');
|
|
fireEvent.change(screen.getByLabelText('places.formNotes'), { target: { value: 'Book early' } });
|
|
expect(onChange).toHaveBeenLastCalledWith('notes', 'Book early');
|
|
});
|
|
|
|
it('FE-PLANNER-PLFORMTEXTS-003: the day tab is there only with a visit in context, named after its day', () => {
|
|
renderTexts();
|
|
expect(tabs().getAllByRole('button')).toHaveLength(2);
|
|
expect(screen.queryByLabelText('places.assignmentNotes')).not.toBeInTheDocument();
|
|
});
|
|
|
|
it('FE-PLANNER-PLFORMTEXTS-004: the day note is plain text under the tab of its day', () => {
|
|
const onChange = renderTexts({ dayNotes: 'Meet at 9', dayNumber: 3 });
|
|
const day = tabs().getByRole('button', { name: 'places.notesTabDayN:3' });
|
|
fireEvent.click(day);
|
|
const field = screen.getByLabelText('places.assignmentNotes');
|
|
expect(field).toBeVisible();
|
|
expect(field).toHaveValue('Meet at 9');
|
|
fireEvent.change(field, { target: { value: 'Meet at 10' } });
|
|
expect(onChange).toHaveBeenLastCalledWith('assignment_notes', 'Meet at 10');
|
|
});
|
|
});
|