diff --git a/frontend/index.html b/frontend/index.html index ed32b10..4f7eb80 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -701,7 +701,10 @@ '), out); assert.ok(out.includes('>Requires (1)'), out); @@ -228,4 +229,39 @@ test('the CAP inputs and their action buttons are wired', () => { assert.match(html, /id="ram-cap-info"/); assert.match(html, /id="scripts-cap-info"/); assert.match(html, /\/api\/cap-info/); + // the report lives in a bordered fieldset with the title in the border + // (the simulator/eSIM pattern); the JS fills the body div + assert.match(html, /
]*>\s*]*data-l10n="CAP details">/); + assert.match(html, /
]*>\s*]*data-l10n="CAP details">/); + assert.match(html, /id="ram-cap-body"/); + assert.match(html, /id="scripts-cap-body"/); +}); + +test('capRenderAnalysis toggles the border box and fills its body', () => { + eval(extractFunc(html, 'capRenderAnalysis')); + const box = { hidden: true, classList: { + add() { box.hidden = true; }, + remove() { box.hidden = false; }, + } }; + const body = { innerHTML: '' }; + globalThis.document = { getElementById: id => ({ + 'ram-cap-info': box, 'ram-cap-body': body, + }[id] || null) }; + // idle: hidden and empty + _capAnalysis.ram = { key: null, status: 'idle', memory: null, error: null, token: 0 }; + capRenderAnalysis('ram'); + assert.ok(box.hidden && body.innerHTML === ''); + // a finished analysis: shown, body carries the report + _capAnalysis.ram = { key: null, status: 'ok', memory: memFixture(), error: null, token: 0 }; + capRenderAnalysis('ram'); + assert.ok(!box.hidden, 'the box is shown'); + assert.ok(body.innerHTML.includes('>Requires (1)'), body.innerHTML); + // a failure: shown with the error and a retry + _capAnalysis.ram = { key: null, status: 'error', memory: null, error: 'bad zip', token: 0 }; + capRenderAnalysis('ram'); + assert.ok(!box.hidden && body.innerHTML.includes('bad zip') && body.innerHTML.includes('Retry'), body.innerHTML); + // analyzing: shown with the progress line + _capAnalysis.ram = { key: null, status: 'analyzing', memory: null, error: null, token: 0 }; + capRenderAnalysis('ram'); + assert.ok(body.innerHTML.includes('Analyzing CAP file...'), body.innerHTML); }); diff --git a/pyproject.toml b/pyproject.toml index 00ecb0e..0dbf7a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pysim-simple-server" -version = "3.5.18" +version = "3.5.19" description = "HTTP REST server wrapping pysim for the SIMple PWA" requires-python = ">=3.8" # pysim is a git-only dependency installed explicitly by setup.bat/setup.sh. diff --git a/pysim_simple_server/server.py b/pysim_simple_server/server.py index b70fa3e..724b2ba 100644 --- a/pysim_simple_server/server.py +++ b/pysim_simple_server/server.py @@ -31,7 +31,7 @@ from osmocom.tlv import BER_TLV_IE from osmocom.utils import rpad -VERSION = '3.5.18' +VERSION = '3.5.19' MAX_ENVELOPE_SEGMENTS = 5 # max SMS segments for outgoing C-APDU in ENVELOPE