fix(client): give the desktop halves the same fixes their mobile twins got

Several of the fixes in this branch landed on a mobile screen while the
desktop component with the identical bug sat in another package and was left
alone, which leaves the two disagreeing about the same handler.

So: the appearance tab flushes its debounced write on unmount, the journey
share copy guards navigator.clipboard (undefined on a plain-HTTP self-hosted
install), the admin collab toggle rolls back from a scoped snapshot instead
of a stale one, the reservation modal parses metadata through the guarded
helper rather than a bare JSON.parse that takes the route down, and the
notification toggle surfaces its failures and stops racing concurrent
toggles.

The Journey components reached the memories provider-status endpoint with a
raw fetch(), past every apiClient interceptor; they go through a small
memoriesApi now. And the server half of the OSM menu_url finding: the client
renders it through safeHttpUrl, so place-enrichment should not be handing a
javascript: value out in the first place.

The share section hides itself when the server says the link is not this
user's to manage, rather than offering a create button that 403s.
This commit is contained in:
Maurice
2026-08-23 10:38:23 +02:00
committed by Maurice
parent e72338bbbc
commit 3e0bfbbb29
22 changed files with 435 additions and 76 deletions
@@ -755,6 +755,54 @@ describe('NotificationsTab', () => {
expect(screen.getByText('Connection refused')).toBeInTheDocument();
});
});
it('FE-COMP-NOTIFICATIONS-030: a failing toggle surfaces the generic error', async () => {
const user = userEvent.setup();
server.use(
http.put('/api/notifications/preferences', () => HttpResponse.json({ error: 'nope' }, { status: 500 })),
);
render(<><NotificationsTab /><ToastContainer /></>);
await waitFor(() => expect(screen.queryByText('Loading...')).not.toBeInTheDocument());
const toggles = await screen.findAllByRole('button');
await user.click(toggles[0]);
expect(await screen.findByText('Error')).toBeInTheDocument();
});
it('FE-COMP-NOTIFICATIONS-031: a failing toggle leaves a later toggle alone', async () => {
const user = userEvent.setup();
let rejectEmail!: () => void;
server.use(
http.put('/api/notifications/preferences', async ({ request }) => {
const body = (await request.json()) as Record<string, Record<string, boolean>>;
// The first write is the email flip; in-app is still untouched there.
if (body.trip_invite.inapp === true) {
return new Promise<Response>(resolve => {
rejectEmail = () => resolve(HttpResponse.json({ error: 'nope' }, { status: 500 }) as unknown as Response);
});
}
return HttpResponse.json({ success: true });
}),
);
render(<><NotificationsTab /><ToastContainer /></>);
await waitFor(() => expect(screen.queryByText('Loading...')).not.toBeInTheDocument());
// Email is off in this matrix, in-app is on.
const [email, inapp] = await screen.findAllByRole('button');
await user.click(email);
await waitFor(() => expect(screen.getAllByRole('button')[0]).toHaveAttribute('aria-pressed', 'true'));
// Flipped while the email write is still hanging.
await user.click(inapp);
await waitFor(() => expect(screen.getAllByRole('button')[1]).toHaveAttribute('aria-pressed', 'false'));
rejectEmail();
await waitFor(() => expect(screen.getAllByRole('button')[0]).toHaveAttribute('aria-pressed', 'false'));
// The in-app toggle the user made meanwhile is not undone.
expect(screen.getAllByRole('button')[1]).toHaveAttribute('aria-pressed', 'false');
});
});
// ─────────────────────────────────────────────────────────────────────────────