feat(calls): "Call ended · 41 min · connection was good" toast (#143)
One line in the existing toast style when a call you were in ends: the duration from our own join clock, plus the fork's io.lotus.call_summary readout (fork ≥ 0.25.0-lotus.10) when it arrives — "connection was good", "3 reconnects", "connection was poor for 4 min". Nothing is stored or sent; the summary is one postMessage at hangup. Without the fork summary the toast still shows the duration. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import { describe, it } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { describeCallDuration, describeCallEnd } from './callSummary';
|
||||
|
||||
describe('describeCallDuration', () => {
|
||||
it('picks the unit', () => {
|
||||
assert.equal(describeCallDuration(40_000), '40 s');
|
||||
assert.equal(describeCallDuration(41 * 60_000), '41 min');
|
||||
assert.equal(describeCallDuration(65 * 60_000), '1 h 05 min');
|
||||
});
|
||||
});
|
||||
|
||||
describe('describeCallEnd', () => {
|
||||
const min = 60_000;
|
||||
it('without a summary shows just the duration', () => {
|
||||
assert.equal(describeCallEnd(41 * min), 'Call ended · 41 min');
|
||||
});
|
||||
it('good / unknown', () => {
|
||||
assert.equal(
|
||||
describeCallEnd(41 * min, {
|
||||
durationMs: 41 * min,
|
||||
reconnects: 1,
|
||||
poorMs: 0,
|
||||
verdict: 'good',
|
||||
}),
|
||||
'Call ended · 41 min · connection was good',
|
||||
);
|
||||
assert.equal(
|
||||
describeCallEnd(2 * min, {
|
||||
durationMs: 2 * min,
|
||||
reconnects: 0,
|
||||
poorMs: 0,
|
||||
verdict: 'unknown',
|
||||
}),
|
||||
'Call ended · 2 min',
|
||||
);
|
||||
});
|
||||
it('reconnects and poor spells', () => {
|
||||
assert.equal(
|
||||
describeCallEnd(41 * min, {
|
||||
durationMs: 41 * min,
|
||||
reconnects: 3,
|
||||
poorMs: 0,
|
||||
verdict: 'fair',
|
||||
}),
|
||||
'Call ended · 41 min · 3 reconnects',
|
||||
);
|
||||
assert.equal(
|
||||
describeCallEnd(12 * min, {
|
||||
durationMs: 12 * min,
|
||||
reconnects: 1,
|
||||
poorMs: 4 * min,
|
||||
verdict: 'poor',
|
||||
}),
|
||||
'Call ended · 12 min · 1 reconnect, connection was poor for 4 min',
|
||||
);
|
||||
assert.equal(
|
||||
describeCallEnd(12 * min, {
|
||||
durationMs: 12 * min,
|
||||
reconnects: 0,
|
||||
poorMs: 2_000,
|
||||
verdict: 'fair',
|
||||
}),
|
||||
'Call ended · 12 min · connection was fair',
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user