fix(web): the agenda shows the server sentence when a skip needs the deadline owner

The resolve error handler mapped deadline_owner_required to the generic
"Could not update this occurrence" copy. It now shows the server message
and leaves the button enabled.

Claude-Session: https://claude.ai/code/session_0191CBGVXJK96MbcBvtEV8Y2
This commit is contained in:
xarmian
2026-11-09 07:49:41 +00:00
parent 418db8db76
commit fe54d87d39
2 changed files with 9 additions and 1 deletions
+4 -1
View File
@@ -151,7 +151,10 @@
const code = (error as { code?: string })?.code;
const stale = code === 'stale' || (viewing && code === 'not_found');
const forbidden = code === 'forbidden' || code === 'permission_denied';
actionError = stale ? staleCopy : forbidden ? permissionCopy : genericCopy;
const message = (error as { message?: unknown })?.message;
// The server's own sentence says who may skip before a hard deadline; the entry is unchanged, so no reload.
const ownerRequired = code === 'deadline_owner_required' && typeof message === 'string' && message !== '';
actionError = ownerRequired ? message : stale ? staleCopy : forbidden ? permissionCopy : genericCopy;
if (stale || forbidden) await load(day, zone, true);
} finally {
if (sameIdentity()) pending = { ...pending, [key]: false };
@@ -192,6 +192,11 @@ describe('resolve identity and dialogs', () => {
if (code !== 'internal') await waitFor(() => expect(h.agenda).toHaveBeenCalledTimes(2));
expect(h.resolve).toHaveBeenCalledTimes(source === 'view' ? 0 : 1);
});
it('shows the server sentence when a skip before a hard deadline needs the owner, and keeps the button', async () => {
const sentence = 'Only the assignee or a workspace owner can skip this occurrence before its hard deadline.';
h.resolve.mockRejectedValue({ code: 'deadline_owner_required', message: sentence }); await mount(); await fireEvent.click(screen.getByRole('button', { name: 'Done EX-30' })); await screen.findByText(sentence);
expect(h.agenda).toHaveBeenCalledTimes(1); expect((screen.getByRole('button', { name: 'Done EX-30' }) as HTMLButtonElement).disabled).toBe(false);
});
it('keeps rows on quiet refresh and retries only the read after a successful write', async () => {
const refresh = deferred<AgendaResponse>(); h.agenda.mockResolvedValueOnce(response()).mockReturnValueOnce(refresh.promise); await mount();
await fireEvent.click(screen.getByRole('button', { name: 'Done EX-30' })); await screen.findByText('Updating agenda…'); expect(screen.getByText('First item')).toBeTruthy();