This commit is contained in:
Vlad Stan
2026-03-26 19:22:15 +02:00
parent 0b8b530ca6
commit 2e77dcf393
+96 -14
View File
@@ -1506,7 +1506,7 @@
> >
<div class="section-title"> <div class="section-title">
<div> <div>
<h3>Test Mock Definition {{ itemIndex + 1 }}</h3> <h3>{{ testMockItemTitle(item, itemIndex) }}</h3>
</div> </div>
<q-btn <q-btn
color="negative" color="negative"
@@ -1611,6 +1611,15 @@
<q-card-section class="q-pa-lg"> <q-card-section class="q-pa-lg">
<div v-if="currentFundingSource"> <div v-if="currentFundingSource">
<div class="q-mb-lg">
<q-checkbox
v-model="currentFundingSourceSkip"
label="Skip this funding source in generated wallet tests"
color="warning"
keep-color
></q-checkbox>
</div>
<div class="settings-editor" v-if="currentFundingSourceSettingRows.length"> <div class="settings-editor" v-if="currentFundingSourceSettingRows.length">
<div class="settings-table"> <div class="settings-table">
<div class="settings-table-header settings-table-grid"> <div class="settings-table-header settings-table-grid">
@@ -2494,6 +2503,7 @@
datasets, datasets,
editorDialog: false, editorDialog: false,
fundingSourceSettingsDialog: false, fundingSourceSettingsDialog: false,
lastFilePickerHandle: null,
functionMockDraftRowId: 0, functionMockDraftRowId: 0,
functionMocksDialog: false, functionMocksDialog: false,
functionMockDrafts, functionMockDrafts,
@@ -2537,6 +2547,38 @@
) || null ) || 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() { currentFundingSourceSettingRows() {
if (!this.currentFundingSourceName) { if (!this.currentFundingSourceName) {
return [] return []
@@ -2946,6 +2988,16 @@
return availableName?.value || '' 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) { addTestMockBinding(testEntry, mockSet) {
mockSet.bindings.push( mockSet.bindings.push(
this.createTestMockBindingDraft( this.createTestMockBindingDraft(
@@ -3702,20 +3754,35 @@
return '' 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() { async openFilePicker() {
if (window.showOpenFilePicker) { if (window.showOpenFilePicker) {
try { try {
const [handle] = await window.showOpenFilePicker({ const [handle] = await window.showOpenFilePicker(
multiple: false, this.openFilePickerOptions()
types: [ )
{
description: 'JSON fixture file',
accept: {
'application/json': ['.json']
}
}
]
})
if (!handle) { if (!handle) {
return return
@@ -3780,6 +3847,11 @@
sourceLabel: options.sourceLabel || `Loaded from ${file.name}`, sourceLabel: options.sourceLabel || `Loaded from ${file.name}`,
loadError: '' loadError: ''
}) })
if (options.fileHandle) {
this.lastFilePickerHandle = options.fileHandle
}
this.notify(`Loaded ${file.name}.`, 'positive') this.notify(`Loaded ${file.name}.`, 'positive')
}, },
async saveDataset(datasetKey) { async saveDataset(datasetKey) {
@@ -3813,7 +3885,8 @@
if (window.showSaveFilePicker) { if (window.showSaveFilePicker) {
try { try {
const handle = await window.showSaveFilePicker({ const savePickerOptions = {
id: 'lnbits-wallet-fixture-studio',
suggestedName: dataset.fileName, suggestedName: dataset.fileName,
types: [ 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() const writable = await handle.createWritable()
await writable.write(contents) await writable.write(contents)
await writable.close() await writable.close()
dataset.fileHandle = handle dataset.fileHandle = handle
this.lastFilePickerHandle = handle
dataset.sourceLabel = `Save picker: ${dataset.fileName}` dataset.sourceLabel = `Save picker: ${dataset.fileName}`
this.notify(`Saved ${dataset.fileName}.`, 'positive') this.notify(`Saved ${dataset.fileName}.`, 'positive')
return return