Preserve API item paths while building editor context
This commit is contained in:
1 parent
1851187076
commit
5b5af1a7b9
2 files changed
+10
-3
No files matched your search
@@ -306,6 +306,8 @@
|
|||||||
var sourceOptions = String(context.sourceOptions || '');
|
var sourceOptions = String(context.sourceOptions || '');
|
||||||
var itemsPathValue = context.itemsPath !== undefined
|
var itemsPathValue = context.itemsPath !== undefined
|
||||||
? String(context.itemsPath === null ? '' : context.itemsPath)
|
? String(context.itemsPath === null ? '' : context.itemsPath)
|
||||||
|
: config.items_path !== undefined
|
||||||
|
? String(config.items_path === null ? '' : config.items_path)
|
||||||
: String(config.default_items_path || '');
|
: String(config.default_items_path || '');
|
||||||
var sampleDataPreview = String(context.sampleDataPreview || '');
|
var sampleDataPreview = String(context.sampleDataPreview || '');
|
||||||
|
|
||||||
|
|||||||
@@ -256,15 +256,20 @@ test('API editor preserves saved item paths instead of replacing them with the s
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (const [savedPath, expectedPath] of [['data.players', 'data.players'], ['', ''], [null, ''], [undefined, 'data']]) {
|
for (const [savedPath, expectedPath] of [['data.players', 'data.players'], ['', ''], [null, ''], [undefined, 'data']]) {
|
||||||
const markup = editor.renderEditorCard({ ...context, config: { ...context.config, items_path: savedPath } });
|
const savedContext = { ...context, config: { ...context.config, items_path: savedPath } };
|
||||||
|
const builtContext = editor.buildEditorCardContext(savedContext, {}, []);
|
||||||
|
assert.equal(builtContext.itemsPath, expectedPath);
|
||||||
|
for (const cardContext of [savedContext, builtContext]) {
|
||||||
|
const markup = editor.renderEditorCard(cardContext);
|
||||||
assert.match(markup, new RegExp('name="region_api_items_path_23"[^>]*value="' + expectedPath.replace('.', '\\.') + '"'));
|
assert.match(markup, new RegExp('name="region_api_items_path_23"[^>]*value="' + expectedPath.replace('.', '\\.') + '"'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const explicitContext = editor.renderEditorCard({
|
const explicitContext = editor.renderEditorCard(editor.buildEditorCardContext({
|
||||||
...context,
|
...context,
|
||||||
itemsPath: 'other.players',
|
itemsPath: 'other.players',
|
||||||
config: { ...context.config, items_path: 'data.players' }
|
config: { ...context.config, items_path: 'data.players' }
|
||||||
});
|
}, {}, []));
|
||||||
assert.match(explicitContext, /name="region_api_items_path_23"[^>]*value="other\.players"/);
|
assert.match(explicitContext, /name="region_api_items_path_23"[^>]*value="other\.players"/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user