From 2e77dcf393456abd45bb9da51009b70b8a5850f4 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Thu, 26 Mar 2026 19:22:15 +0200 Subject: [PATCH] feat: ui --- tests/wallets/index.html | 110 ++++++++++++++++++++++++++++++++++----- 1 file changed, 96 insertions(+), 14 deletions(-) diff --git a/tests/wallets/index.html b/tests/wallets/index.html index d641a3624..77317da69 100644 --- a/tests/wallets/index.html +++ b/tests/wallets/index.html @@ -1506,7 +1506,7 @@ >
-

Test Mock Definition {{ itemIndex + 1 }}

+

{{ testMockItemTitle(item, itemIndex) }}

+
+ +
+
@@ -2494,6 +2503,7 @@ datasets, editorDialog: false, fundingSourceSettingsDialog: false, + lastFilePickerHandle: null, functionMockDraftRowId: 0, functionMocksDialog: false, functionMockDrafts, @@ -2537,6 +2547,38 @@ ) || null ) }, + currentFundingSourceSkip: { + get() { + return Boolean(this.currentFundingSource?.skip) + }, + set(value) { + if (!this.currentFundingSourceName) { + return + } + + this.applyDatasetMutation( + this.selectedDatasetKey, + data => { + const fundingSource = + data.funding_sources?.[this.currentFundingSourceName] + + if (!fundingSource) { + return + } + + if (value) { + fundingSource.skip = true + } else { + delete fundingSource.skip + } + }, + { + preserveSettingsDrafts: true, + preserveFunctionMockDrafts: true + } + ) + } + }, currentFundingSourceSettingRows() { if (!this.currentFundingSourceName) { return [] @@ -2946,6 +2988,16 @@ return availableName?.value || '' }, + testMockItemTitle(item, itemIndex) { + const parsed = parseJsonText(item?.text || '') + const description = parsed.ok ? parsed.data?.description : '' + + if (typeof description === 'string' && description.trim() !== '') { + return description.trim() + } + + return `Test Mock Definition ${itemIndex + 1}` + }, addTestMockBinding(testEntry, mockSet) { mockSet.bindings.push( this.createTestMockBindingDraft( @@ -3702,20 +3754,35 @@ return '' }, + openFilePickerOptions() { + const options = { + id: 'lnbits-wallet-fixture-studio', + multiple: false, + types: [ + { + description: 'JSON fixture file', + accept: { + 'application/json': ['.json'] + } + } + ] + } + + const startIn = + this.currentDataset.fileHandle || this.lastFilePickerHandle + + if (startIn) { + options.startIn = startIn + } + + return options + }, async openFilePicker() { if (window.showOpenFilePicker) { try { - const [handle] = await window.showOpenFilePicker({ - multiple: false, - types: [ - { - description: 'JSON fixture file', - accept: { - 'application/json': ['.json'] - } - } - ] - }) + const [handle] = await window.showOpenFilePicker( + this.openFilePickerOptions() + ) if (!handle) { return @@ -3780,6 +3847,11 @@ sourceLabel: options.sourceLabel || `Loaded from ${file.name}`, loadError: '' }) + + if (options.fileHandle) { + this.lastFilePickerHandle = options.fileHandle + } + this.notify(`Loaded ${file.name}.`, 'positive') }, async saveDataset(datasetKey) { @@ -3813,7 +3885,8 @@ if (window.showSaveFilePicker) { try { - const handle = await window.showSaveFilePicker({ + const savePickerOptions = { + id: 'lnbits-wallet-fixture-studio', suggestedName: dataset.fileName, types: [ { @@ -3823,13 +3896,22 @@ } } ] - }) + } + const saveStartIn = + dataset.fileHandle || this.lastFilePickerHandle + + if (saveStartIn) { + savePickerOptions.startIn = saveStartIn + } + + const handle = await window.showSaveFilePicker(savePickerOptions) const writable = await handle.createWritable() await writable.write(contents) await writable.close() dataset.fileHandle = handle + this.lastFilePickerHandle = handle dataset.sourceLabel = `Save picker: ${dataset.fileName}` this.notify(`Saved ${dataset.fileName}.`, 'positive') return