feat(web): no_recipient toast copy arm (#18)

buildCallUndeliverableToast renders "{peerLabel} couldn't ring anyone."
for the single-failure terminal case; multi-failure + non-terminal paths
fall through to existing lines (which already fold the new reason in by
peer label). TDD — four new assertions.
This commit is contained in:
Jannis Braun
2026-04-24 21:15:21 +02:00
parent 26a4925032
commit b16ece93b8
2 changed files with 38 additions and 0 deletions
@@ -54,4 +54,40 @@ describe('buildCallUndeliverableToast', () => {
expect(msg.toLowerCase()).toContain('orbit'); expect(msg.toLowerCase()).toContain('orbit');
expect(msg.toLowerCase()).toContain('peered'); expect(msg.toLowerCase()).toContain('peered');
}); });
it('renders no_recipient single-failure terminal copy', () => {
const fail = (peerLabel = 'Orbit') => ({
reason: 'no_recipient',
peerOrigin: 'https://orbit.local',
peerLabel,
});
expect(buildCallUndeliverableToast([fail()], true, 'start'))
.toBe("Orbit couldn't ring anyone.");
});
it('no_recipient falls back to origin when peerLabel missing', () => {
const fail = {
reason: 'no_recipient',
peerOrigin: 'https://orbit.local',
};
expect(buildCallUndeliverableToast([fail], true, 'start'))
.toMatch(/orbit\.local couldn't ring anyone\./);
});
it('no_recipient in a multi-failure terminal falls back to multi-instance copy', () => {
const failures = [
{ reason: 'no_recipient', peerOrigin: 'https://orbit.local', peerLabel: 'Orbit' },
{ reason: 'peer_transient_failure', peerOrigin: 'https://nova.local', peerLabel: 'Nova' },
];
expect(buildCallUndeliverableToast(failures, true, 'start'))
.toMatch(/Could not reach 2 instances: Orbit, Nova/);
});
it('no_recipient non-terminal uses the existing "Some participants" line', () => {
const failures = [
{ reason: 'no_recipient', peerOrigin: 'https://orbit.local', peerLabel: 'Orbit' },
];
expect(buildCallUndeliverableToast(failures, false, 'start'))
.toMatch(/Some participants could not be reached: Orbit/);
});
}); });
@@ -76,6 +76,8 @@ export function buildCallUndeliverableToast(
return `Could not reach ${label}. Try again in a moment.`; return `Could not reach ${label}. Try again in a moment.`;
case 'livekit_unavailable': case 'livekit_unavailable':
return 'Voice is not configured on this instance.'; return 'Voice is not configured on this instance.';
case 'no_recipient':
return `${label} couldn't ring anyone.`;
default: default:
return `Call to ${label} could not be placed.`; return `Call to ${label} could not be placed.`;
} }