Desktop: - Search lists chats whose own name matches first, so a named group isn't pushed out of the top 8 by chats that merely include a member. Android (Rabbit R1) app, 0.2.0: - Pull the chat list past its top for a search box (name, person, number, then group members; archived chats too; Back clears it). - Swipe right to left marks a chat unread / read over a magenta band; left to right still archives (SwipeActions replaces SwipeArchive). - Google Voice chats don't offer voice notes in the paperclip bubble. - Chats open with their newest 60 messages, then the full history; marking read (and the Google Voice network call) waits until they're on screen. Cached pictures show at once, and one slow download no longer blocks the other images. Fixed a contacts reload race. - Sandbox data gains filler chats, a named group and a 4,000-message chat. Also: the Android app, Google Voice support, media, export, emoji and the other work since the first commit, and a CLAUDE.md carrying the privacy rule.
46 lines
2.3 KiB
TypeScript
46 lines
2.3 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { classifySendError, fixVoipDst, parseVoipDate, sendErrorMessage, VoipMsError } from '../src/main/voipms'
|
|
|
|
describe('parseVoipDate', () => {
|
|
// Real cases checked against the live API (timezone=0).
|
|
it('undoes the extra hour voip.ms adds during US daylight time', () => {
|
|
// Sent 2026-09-18 06:35:47 UTC; voip.ms reported 07:35:47.
|
|
expect(parseVoipDate('2026-09-18 07:35:47')).toBe(Date.UTC(2026, 8, 18, 6, 35, 47))
|
|
// March 12 2026: US DST (from Mar 8) but not UK summer time (from Mar 29).
|
|
expect(parseVoipDate('2026-03-12 19:16:41')).toBe(Date.UTC(2026, 2, 12, 18, 16, 41))
|
|
})
|
|
it('leaves winter times alone', () => {
|
|
expect(parseVoipDate('2026-01-20 02:44:49')).toBe(Date.UTC(2026, 0, 20, 2, 44, 49))
|
|
expect(fixVoipDst(Date.UTC(2025, 11, 25, 12))).toBe(Date.UTC(2025, 11, 25, 12))
|
|
})
|
|
})
|
|
|
|
const netError = (code: string): Error => Object.assign(new TypeError('fetch failed'), { cause: Object.assign(new Error(code), { code }) })
|
|
const timeout = (): Error => new DOMException('The operation was aborted due to timeout', 'TimeoutError')
|
|
|
|
describe('classifySendError', () => {
|
|
it('never resends blindly when the message may have gone out', () => {
|
|
expect(classifySendError(timeout())).toBe('unknown')
|
|
expect(classifySendError(netError('ECONNRESET'))).toBe('unknown')
|
|
expect(classifySendError(new Error('voip.ms HTTP 502'))).toBe('unknown')
|
|
expect(classifySendError(new SyntaxError('Unexpected token <'))).toBe('unknown')
|
|
})
|
|
it('resends when the request never reached voip.ms or voip.ms says it failed', () => {
|
|
expect(classifySendError(netError('ENOTFOUND'))).toBe('safe')
|
|
expect(classifySendError(netError('ECONNREFUSED'))).toBe('safe')
|
|
expect(classifySendError(new VoipMsError('sms_failed'))).toBe('safe')
|
|
})
|
|
it('gives up on rejections', () => {
|
|
expect(classifySendError(new VoipMsError('invalid_dst'))).toBe('fatal')
|
|
expect(classifySendError(new VoipMsError('not_signed_in'))).toBe('fatal')
|
|
})
|
|
})
|
|
|
|
describe('sendErrorMessage', () => {
|
|
it('explains failures in plain words', () => {
|
|
expect(sendErrorMessage(timeout())).toBe("voip.ms didn't respond in time.")
|
|
expect(sendErrorMessage(netError('ENOTFOUND'))).toMatch(/internet connection/)
|
|
expect(sendErrorMessage(new VoipMsError('invalid_dst'))).toBe('Invalid destination number.')
|
|
})
|
|
})
|