mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 09:22:15 +00:00
feat(collections): show and edit the own notes of a saved place
A saved place has carried notes for a while (the API and the assistant write them), but neither the phone sheet nor the desktop detail showed them, so notes written there were invisible. Both now show them under the description when there are any, and edit them beside it, through the shared form hook. Addresses discussion #3168.
This commit is contained in:
@@ -176,6 +176,7 @@ describe('useCollectionPlaceForm', () => {
|
||||
expect(detail.props.onSave).toHaveBeenCalledWith({
|
||||
name: 'Louvre',
|
||||
description: 'Museum',
|
||||
notes: null,
|
||||
links: [{ label: 'Map', url: 'https://maps.example' }],
|
||||
category_id: 3,
|
||||
label_ids: [11],
|
||||
@@ -192,6 +193,7 @@ describe('useCollectionPlaceForm', () => {
|
||||
expect(sheet.props.onSave).toHaveBeenCalledWith({
|
||||
name: 'Louvre',
|
||||
description: 'Museum',
|
||||
notes: null,
|
||||
links: [{ label: 'Site', url: 'https://louvre.example' }],
|
||||
category_id: 3,
|
||||
label_ids: [10],
|
||||
@@ -199,6 +201,25 @@ describe('useCollectionPlaceForm', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('FE-COMP-COLPLACEHOOK-014: seeds, edits and saves the own notes on a saved place (#3168)', async () => {
|
||||
const sheet = setup({ place: place({ notes: 'Book a week ahead' }) });
|
||||
expect(sheet.result.current.notes).toBe('Book a week ahead');
|
||||
act(() => {
|
||||
sheet.result.current.setEditing(true);
|
||||
sheet.result.current.setNotes(' Closed on Tuesdays ');
|
||||
});
|
||||
await act(async () => {
|
||||
await sheet.result.current.save();
|
||||
});
|
||||
expect(sheet.props.onSave).toHaveBeenCalledWith(expect.objectContaining({ notes: 'Closed on Tuesdays' }));
|
||||
|
||||
act(() => sheet.result.current.setNotes(' '));
|
||||
await act(async () => {
|
||||
await sheet.result.current.save();
|
||||
});
|
||||
expect(sheet.props.onSave).toHaveBeenLastCalledWith(expect.objectContaining({ notes: null }));
|
||||
});
|
||||
|
||||
it('FE-COMP-COLPLACEHOOK-010: a failed save stays in edit mode and toasts', async () => {
|
||||
const onSave = vi.fn().mockRejectedValue({ response: { data: { error: 'Locked' } } });
|
||||
const { result } = setup({ onSave });
|
||||
|
||||
Reference in New Issue
Block a user