expand_more
@@ -2328,7 +2328,7 @@
expand_more
@@ -3543,6 +3543,34 @@
return false
}
},
+ clearPersistedFixtureState() {
+ if (!this.canUseLocalStorage()) {
+ return
+ }
+
+ DATASET_DEFS.forEach(def => {
+ window.localStorage.removeItem(this.storageKey(def.key))
+ })
+ window.localStorage.removeItem(this.activeDatasetStorageKey())
+ window.localStorage.removeItem(this.uiStateStorageKey())
+ },
+ resetInMemoryFixtureState(nextDatasetKey = this.selectedDatasetKey) {
+ DATASET_DEFS.forEach(def => {
+ this.datasets[def.key] = createDatasetState(def)
+ this.selectedFunctionByDataset[def.key] = ''
+ this.selectedFundingSourceByDataset[def.key] = ''
+ this.selectedTestFundingSourceByDataset[def.key] = ''
+ })
+
+ this.functionMockDrafts = {}
+ this.settingsDrafts = {}
+ this.selectedTestMockBindingByScope = {}
+ this.selectedTestTypeByScope = {}
+ this.functionMockDraftRowId = 0
+ this.settingsDraftRowId = 0
+ this.lastFilePickerHandle = null
+ this.selectedDatasetKey = nextDatasetKey
+ },
persistDatasetToStorage(datasetKey) {
if (!this.canUseLocalStorage()) {
return
@@ -4554,8 +4582,8 @@
return 'Method: HTTP verb used by this REST mock, such as GET or POST.'
},
- handleFunctionMockRequestTypeChange(row) {
- row.requestType = row.requestType === 'function' ? 'function' : ''
+ handleFunctionMockRequestTypeChange(row, value) {
+ row.requestType = value === 'function' ? 'function' : ''
if (row.requestType === 'function') {
row.uri = ''
@@ -4566,7 +4594,21 @@
row.responseText = ''
}
- this.persistFunctionMocks({ silent: true })
+ this.$nextTick(() => {
+ this.persistFunctionMocks({ silent: true })
+ })
+ },
+ handleFunctionMockResponseTypeChange(row, value) {
+ row.responseType = typeof value === 'string' ? value : ''
+ this.$nextTick(() => {
+ this.persistFunctionMocks({ silent: true })
+ })
+ },
+ handleTestMockSelectChange(testEntry, mockSet, item, field, value) {
+ item[field] = typeof value === 'string' ? value : ''
+ this.$nextTick(() => {
+ this.persistTestMockSet(testEntry, mockSet, { silent: true })
+ })
},
parseEditableTestJson(text, label) {
const parsed = parseJsonText(text)
@@ -5565,14 +5607,15 @@
return
}
- this.selectedDatasetKey = datasetKey
-
if (!parsed.ok) {
this.datasets[datasetKey].parseError = `Invalid JSON in ${file.name}: ${parsed.error}`
this.notify(`Could not read ${file.name}.`, 'negative')
return
}
+ this.clearPersistedFixtureState()
+ this.resetInMemoryFixtureState(datasetKey)
+
const formatted = JSON.stringify(parsed.data, null, 2)
this.commitDataset(datasetKey, parsed.data, {
rawText: formatted,