Files
LocalAI/addons/quantization/ui/test/progress.test.mjs
T
Ettore Di Giacinto 1604a67c1f feat(addons): add the add-on runtime, navigation and first-party add-ons
Add the add-on runtime to LocalAI: manifests, the host operation broker,
admin gating by account role, the add-on UI bundle builder and the SDK
for add-on pages. Move the navigation to Chat, Models, Add-ons and
Settings, with pinned add-ons in the sidebar and an Add-ons drawer.

Ship the first-party add-ons (voice, face, fine-tuning, quantization) as
packages for linux/amd64, linux/arm64 and darwin/arm64. Intel macOS
(darwin/amd64) is enabled in the platform files.

Squashed from the review branch. The tree is unchanged; the pre-squash
history is kept on a local backup branch.

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
2026-10-20 20:54:43 +00:00

29 lines
1.1 KiB
JavaScript

import test from 'node:test'
import assert from 'node:assert/strict'
import { percentOf, ACTIVE } from '../src/lib/progress.js'
test('completed is 100', () => {
assert.equal(percentOf({ status: 'completed', progress_percent: 0 }), 100)
})
test('a working job whose percent reads 0 is unknown, not 0', () => {
assert.deepEqual(ACTIVE, ['queued', 'downloading', 'converting', 'quantizing'])
for (const status of ACTIVE) assert.equal(percentOf({ status, progress_percent: 0 }), null, status)
assert.equal(percentOf({ status: 'quantizing' }), null)
})
test('a working job with a percent above 0 reports it, capped at 100', () => {
assert.equal(percentOf({ status: 'quantizing', progress_percent: 42.4 }), 42.4)
assert.equal(percentOf({ status: 'converting', progress_percent: 140 }), 100)
})
test('no event is unknown', () => {
assert.equal(percentOf(null), null)
assert.equal(percentOf(undefined), null)
})
test('a failed or stopped job keeps the percent it reported, and 0 there is a real 0', () => {
assert.equal(percentOf({ status: 'failed', progress_percent: 0 }), 0)
assert.equal(percentOf({ status: 'stopped', progress_percent: 30 }), 30)
})