Files
openchamber/packages/ui/src/lib/updateInstallError.test.ts
T
Iuliia Ivashko 52d79cb368 fix(desktop): surface failed update installs
"Restart to Update" answered the renderer with null before the install was
attempted, so a rejected install only reached main.log and the button looked
dead. The apply-update path now keeps the IPC call open until the app quits or
autoUpdater reports the failure, rolls the quit/install flags back when the app
stays up, and the update dialog shows the real reason with a translated hint for
a rejected code signature.

Also settle the download promise on downloadUpdate() itself: an already cached
payload emits no 'update-downloaded', which left that promise pending with its
listeners attached on every retry.
2026-08-28 14:47:09 +03:00

36 lines
1.4 KiB
TypeScript

import { describe, expect, test } from 'bun:test';
import { classifyUpdateInstallError, getUpdateInstallErrorMessage } from './updateInstallError';
describe('classifyUpdateInstallError', () => {
test('recognizes a rejected code signature', () => {
const error = new Error(
'Code signature at URL file:///Users/me/Library/Caches/dev.openchamber.desktop.ShipIt/update.afN56TW/OpenChamber.app/ did not pass validation: code failed to satisfy specified code requirement(s)',
);
expect(classifyUpdateInstallError(error)).toBe('signature');
});
test('recognizes the disabled updater session left by an earlier failure', () => {
expect(classifyUpdateInstallError(new Error('The command is disabled and cannot be executed'))).toBe(
'updater-disabled',
);
});
test('leaves an unknown installer failure unclassified', () => {
expect(classifyUpdateInstallError(new Error('ENOSPC: no space left on device'))).toBe('unknown');
});
});
describe('getUpdateInstallErrorMessage', () => {
test('keeps the raw updater text for an unknown failure', () => {
expect(getUpdateInstallErrorMessage(new Error('ENOSPC: no space left on device'))).toBe(
'ENOSPC: no space left on device',
);
});
test('never returns an empty message', () => {
expect(getUpdateInstallErrorMessage(new Error(' ')).length).toBeGreaterThan(0);
expect(getUpdateInstallErrorMessage(new Error('')).length).toBeGreaterThan(0);
});
});