- {{ walletEntry.note }}
+
-
-
-
+
+
+
+
+ No tests are defined for this function.
-
-
-
-
-
-
-
Raw JSON Editor
-
- Edit the current fixture file directly, then apply or save the changes.
-
-
-
-
-
-
-
- {{ currentDataset.parseError }}
-
-
-
-
-
-
+
+
+
+
+
Raw JSON Editor
+
+ Edit the current fixture file directly, then apply, save, or download the changes.
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ currentDataset.parseError }}
+
+
+
+
+
+
+
{
datasets[def.key] = createDatasetState(def)
selectedFunctionByDataset[def.key] = ''
- selectedTestIndexByDataset[def.key] = 0
+ selectedFundingSourceByDataset[def.key] = ''
})
return {
datasetDefs: DATASET_DEFS,
datasets,
+ editorDialog: false,
selectedDatasetKey: 'rest',
selectedFunctionByDataset,
- selectedTestIndexByDataset,
- search: ''
+ selectedFundingSourceByDataset
}
},
computed: {
@@ -1750,6 +1735,41 @@
currentFundingSources() {
return this.currentDataset.analysis?.fundingSources || []
},
+ fundingSourceOptions() {
+ return this.currentFundingSources.map(fs => ({
+ label: `${fs.name} · ${fs.wallet_class}`,
+ value: fs.name
+ }))
+ },
+ currentFundingSourceName() {
+ return this.selectedFundingSourceByDataset[this.selectedDatasetKey] || ''
+ },
+ currentFundingSource() {
+ return (
+ this.currentFundingSources.find(
+ fs => fs.name === this.currentFundingSourceName
+ ) || null
+ )
+ },
+ currentFundingSourceSettings() {
+ if (!this.currentFundingSource?.settings) {
+ return []
+ }
+
+ return Object.entries(this.currentFundingSource.settings).map(
+ ([key, value]) => ({
+ key,
+ value
+ })
+ )
+ },
+ functionOptions() {
+ const functions = this.currentDataset.analysis?.functions || []
+ return functions.map(fn => ({
+ label: `${fn.name} · ${fn.tests.length} tests`,
+ value: fn.name
+ }))
+ },
currentFunctionName() {
return this.selectedFunctionByDataset[this.selectedDatasetKey] || ''
},
@@ -1760,68 +1780,6 @@
) || null
)
},
- currentTestIndex() {
- return this.selectedTestIndexByDataset[this.selectedDatasetKey] || 0
- },
- selectedRawTest() {
- if (!this.currentFunction) {
- return null
- }
-
- return (
- this.currentFunction.tests.find(
- test => test.index === this.currentTestIndex
- ) || this.currentFunction.tests[0] || null
- )
- },
- filteredFunctions() {
- const functions = this.currentDataset.analysis?.functions || []
- const query = this.search.toLowerCase().trim()
-
- if (!query) {
- return functions
- }
-
- return functions.filter(fn => {
- const walletNames = fn.baseMockWallets
- .map(entry => entry.fundingSource.name)
- .join(' ')
- const testDescriptions = fn.tests
- .map(test => test.description)
- .join(' ')
-
- return `${fn.name} ${walletNames} ${testDescriptions}`
- .toLowerCase()
- .includes(query)
- })
- },
- filteredTests() {
- if (!this.currentFunction) {
- return []
- }
-
- const query = this.search.toLowerCase().trim()
-
- if (!query) {
- return this.currentFunction.tests
- }
-
- return this.currentFunction.tests.filter(test => {
- const walletNames = test.walletCoverage
- .map(entry => entry.fundingSource.name)
- .join(' ')
- return `${test.description} ${walletNames}`
- .toLowerCase()
- .includes(query)
- })
- },
- selectedRawTestPath() {
- if (!this.currentFunction || !this.selectedRawTest) {
- return ''
- }
-
- return `functions.${this.currentFunction.name}.tests[${this.selectedRawTest.index}]`
- },
currentDatasetKindHelp() {
if (this.selectedDatasetKey === 'rest') {
return 'HTTP funding sources with request and response mocks consumed by pytest_httpserver.'
@@ -1832,74 +1790,121 @@
editorDirty() {
return this.currentDataset.rawText !== this.currentDataset.snapshotText
},
- expandedWalletEntries() {
- if (!this.currentFunction || !this.selectedRawTest) {
+ currentFunctionBaseMockEntry() {
+ if (!this.currentFunction || !this.currentFundingSource) {
+ return null
+ }
+
+ return (
+ this.currentFunction.baseMockWallets.find(
+ entry => entry.fundingSource.name === this.currentFundingSource.name
+ ) || null
+ )
+ },
+ currentFunctionBaseMockEntries() {
+ return this.currentFunctionBaseMockEntry?.mockEntries || []
+ },
+ currentFunctionBaseMockPath() {
+ if (!this.currentFunction || !this.currentFundingSource) {
+ return ''
+ }
+
+ return this.baseWalletPath(
+ this.currentFunction.name,
+ this.currentFundingSource.name
+ )
+ },
+ currentFunctionTestsForFundingSource() {
+ if (!this.currentFunction || !this.currentFundingSource) {
return []
}
- return this.currentFundingSources.map(fs => {
- const variants = testsForFundingSource(
- fs,
- this.currentFunction.name,
- this.currentFunction.raw,
- this.selectedRawTest.raw,
- this.selectedRawTest.index
+ return this.currentFunction.tests.map(test => {
+ const rawHasMocksBlock = Object.prototype.hasOwnProperty.call(
+ test.raw || {},
+ 'mocks'
)
- const hasMocksEntry = Boolean(
- this.selectedRawTest.raw?.mocks &&
+ const hasMockEntry = Boolean(
+ rawHasMocksBlock &&
Object.prototype.hasOwnProperty.call(
- this.selectedRawTest.raw.mocks,
- fs.name
+ test.raw.mocks || {},
+ this.currentFundingSource.name
)
)
- const basePath = this.baseWalletPath(this.currentFunction.name, fs.name)
- const testPath = hasMocksEntry
+ const rawWalletMockValue = hasMockEntry
+ ? test.raw.mocks[this.currentFundingSource.name]
+ : undefined
+ const rawWalletPath = hasMockEntry
? this.testWalletPath(
this.currentFunction.name,
- this.selectedRawTest.index,
- fs.name
+ test.index,
+ this.currentFundingSource.name
)
: ''
+ const rawMockSets = rawWalletMockValue === undefined
+ ? []
+ : (Array.isArray(rawWalletMockValue)
+ ? rawWalletMockValue
+ : [rawWalletMockValue]
+ ).map((mockSet, index) => ({
+ label: Array.isArray(rawWalletMockValue)
+ ? `Mock set ${index + 1}`
+ : 'Mock set',
+ path: Array.isArray(rawWalletMockValue)
+ ? `${rawWalletPath}[${index}]`
+ : rawWalletPath,
+ value: deepClone(mockSet)
+ }))
+ const variants = testsForFundingSource(
+ this.currentFundingSource,
+ this.currentFunction.name,
+ this.currentFunction.raw,
+ test.raw,
+ test.index
+ )
- let note = ''
let status = {
label: 'Ready',
color: 'positive'
}
+ let note = ''
- if (fs.skip) {
+ if (this.currentFundingSource.skip) {
status = {
- label: 'Skipped wallet',
+ label: 'Wallet skipped',
color: 'warning'
}
- note = 'This funding source is marked with `skip: true` in the fixture file.'
- } else if (!hasMocksEntry && this.selectedRawTest.raw?.mocks) {
+ note = 'The selected funding source is marked with `skip: true` in the fixture configuration.'
+ } else if (rawHasMocksBlock && !hasMockEntry) {
status = {
- label: 'Missing mock entry',
+ label: 'Missing wallet mocks',
color: 'negative'
}
- note = 'This raw test omits this funding source under its `mocks` section, so the generated wallet test is skipped.'
- } else if (!variants.length) {
+ note = 'This test has a `mocks` block, but it does not define one for the selected funding source.'
+ } else if (rawHasMocksBlock && hasMockEntry && !rawMockSets.length) {
status = {
- label: 'No variants',
+ label: 'Empty wallet mocks',
color: 'grey-7'
}
- note = 'This wallet has a mock entry, but it expands to zero generated variants.'
- } else if (variants.every(variant => variant.skip)) {
+ note = 'This test defines the selected funding source, but the mock set is empty.'
+ } else if (!rawHasMocksBlock) {
status = {
- label: 'All skipped',
- color: 'warning'
+ label: 'No test-level mocks',
+ color: 'grey-7'
}
+ note = 'This test case does not include a `mocks` section.'
}
return {
- fundingSource: fs,
+ ...test,
+ rawWalletPath,
+ rawMockSets,
variants,
- hasMocksEntry,
- basePath,
- testPath,
+ variantCount: variants.length,
+ status,
note,
- status
+ expectedBlock: test.expect ?? test.expect_error,
+ expectedLabel: test.expect ? 'Expect' : 'Expect Error'
}
})
}
@@ -1954,62 +1959,48 @@
return pieces.join(' · ') || 'No mock metadata'
},
- cleanMockForDisplay(mock) {
- const clone = deepClone(mock)
- delete clone._meta
- return clone
- },
- coverageChipColor(coverage) {
- if (coverage.fundingSource.skip) {
- return 'warning'
+ prettyValue(value) {
+ if (typeof value === 'string') {
+ return value
}
- if (!coverage.hasMocksEntry) {
- return 'negative'
- }
- if (!coverage.variantCount) {
- return 'grey-7'
- }
- if (!coverage.readyCount) {
- return 'warning'
- }
- return 'positive'
- },
- variantDisplayLabel(variant) {
- const raw = variant._meta?.rawDescription || variant.description || ''
- const extra = variant._meta?.extraDescription
-
- if (extra) {
- return `${raw} / ${extra}`
+ if (
+ typeof value === 'number' ||
+ typeof value === 'boolean' ||
+ value === null
+ ) {
+ return String(value)
}
- return raw || variant.description || 'Generated variant'
+ return safeStringify(value)
},
- buildTestId,
baseWalletPath(functionName, fundingSourceName) {
return `functions.${functionName}.mocks.${fundingSourceName}`
},
testWalletPath(functionName, testIndex, fundingSourceName) {
return `functions.${functionName}.tests[${testIndex}].mocks.${fundingSourceName}`
},
- baseMockPath(functionName, fundingSourceName, mockName) {
- return `functions.${functionName}.mocks.${fundingSourceName}.${mockName}`
- },
- testMockPath(
- functionName,
- testIndex,
- fundingSourceName,
- mockName,
- mockIndex
- ) {
- return `functions.${functionName}.tests[${testIndex}].mocks.${fundingSourceName}.${mockName}[${mockIndex}]`
- },
ensureSelections(datasetKey) {
const dataset = this.datasets[datasetKey]
+ const fundingSources = dataset.analysis?.fundingSources || []
const functions = dataset.analysis?.functions || []
+ if (!fundingSources.length) {
+ this.selectedFundingSourceByDataset[datasetKey] = ''
+ } else {
+ const currentFundingSourceName =
+ this.selectedFundingSourceByDataset[datasetKey]
+ const selectedFundingSource = fundingSources.find(
+ fs => fs.name === currentFundingSourceName
+ )
+
+ if (!selectedFundingSource) {
+ this.selectedFundingSourceByDataset[datasetKey] =
+ fundingSources[0].name
+ }
+ }
+
if (!functions.length) {
this.selectedFunctionByDataset[datasetKey] = ''
- this.selectedTestIndexByDataset[datasetKey] = 0
return
}
@@ -2021,33 +2012,6 @@
if (!selectedFunction) {
this.selectedFunctionByDataset[datasetKey] = functions[0].name
}
-
- const nextFunction = functions.find(
- fn => fn.name === this.selectedFunctionByDataset[datasetKey]
- )
- const tests = nextFunction?.tests || []
- const currentIndex = this.selectedTestIndexByDataset[datasetKey]
-
- if (!tests.length) {
- this.selectedTestIndexByDataset[datasetKey] = 0
- return
- }
-
- const matchingTest = tests.find(test => test.index === currentIndex)
- if (!matchingTest) {
- this.selectedTestIndexByDataset[datasetKey] = tests[0].index
- }
- },
- selectFunction(functionName) {
- this.selectedFunctionByDataset[this.selectedDatasetKey] = functionName
- const fn = this.currentDataset.analysis?.functions.find(
- item => item.name === functionName
- )
- this.selectedTestIndexByDataset[this.selectedDatasetKey] =
- fn?.tests[0]?.index || 0
- },
- selectTest(testIndex) {
- this.selectedTestIndexByDataset[this.selectedDatasetKey] = testIndex
},
commitDataset(datasetKey, parsedData, options = {}) {
const dataset = this.datasets[datasetKey]