Files
StarPilot/openpilot/starpilot/galaxy/tests/test_offline_status.mjs
T
firestar5683 fab3ec9aeb Galaxy UI
Add Galaxy web assets and client settings interfaces with their bundled vendor notices.

Co-authored-by: Danny <dannyirwin31@yahoo.com>
Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu>
Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com>
Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com>

Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com>
Co-authored-by: prabhaavp <prabhaav@msu.edu>
2026-10-14 19:56:17 -05:00

23 lines
1.7 KiB
JavaScript

import assert from 'node:assert/strict'
import { validOperation, formatBytes, MapOperationsPanel } from '../web/js/map-operations.js'
const generation = 'a'.repeat(64)
const status = { schemaVersion: 1, ownerSession: 'owner', operationId: 'owner:1', state: 'completed', regionToken: 'us_state.Oklahoma',
bounds: [35, -98, 35.25, -97.75], completedGroups: 1, totalGroups: 1, transferredBytes: 256, transferBudgetBytes: 1024,
preparedGeneration: generation, selectedGeneration: generation, errorCode: null, selectedForNextShadowStart: true,
selectedSnapshot: { generation, storedBytes: 1024, tileCount: 1, bounds: [35, -98, 35.25, -97.75] } }
assert.equal(validOperation(status), true)
for (const info of [undefined, null, { ...status.selectedSnapshot, storedBytes: 0 },
{ ...status.selectedSnapshot, tileCount: 0 }, { ...status.selectedSnapshot, generation: 'b'.repeat(64) },
{ ...status.selectedSnapshot, bounds: null }, { ...status.selectedSnapshot, storedBytes: Number.NaN }]) {
assert.equal(validOperation({ ...status, selectedSnapshot: info }), false)
}
assert.equal(formatBytes(512), '512 B')
assert.equal(formatBytes(1024), '1.0 KiB')
assert.equal(formatBytes(2 * 1024 ** 2), '2.0 MiB')
assert.equal(formatBytes(2 * 1024 ** 3), '2.0 GiB')
assert.match(MapOperationsPanel.template, /Offline map database/)
assert.match(MapOperationsPanel.template, /selectedSnapshot.storedBytes/)
assert.match(MapOperationsPanel.template, /selectedSnapshot.tileCount/)
assert.doesNotMatch(MapOperationsPanel.template, /Download complete\. This map will be used/)
console.log('PASS: nonempty package identity required for completed projection; actual size and units rendered')