Preserve API item paths while building editor context
This commit is contained in:
1 parent
1851187076
commit
5b5af1a7b9
2 files changed
+12
-5
No files matched your search
@@ -306,7 +306,9 @@
|
||||
var sourceOptions = String(context.sourceOptions || '');
|
||||
var itemsPathValue = context.itemsPath !== undefined
|
||||
? String(context.itemsPath === null ? '' : context.itemsPath)
|
||||
: String(config.default_items_path || '');
|
||||
: config.items_path !== undefined
|
||||
? String(config.items_path === null ? '' : config.items_path)
|
||||
: String(config.default_items_path || '');
|
||||
var sampleDataPreview = String(context.sampleDataPreview || '');
|
||||
|
||||
return {
|
||||
|
||||
@@ -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']]) {
|
||||
const markup = editor.renderEditorCard({ ...context, config: { ...context.config, items_path: savedPath } });
|
||||
assert.match(markup, new RegExp('name="region_api_items_path_23"[^>]*value="' + expectedPath.replace('.', '\\.') + '"'));
|
||||
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('.', '\\.') + '"'));
|
||||
}
|
||||
}
|
||||
|
||||
const explicitContext = editor.renderEditorCard({
|
||||
const explicitContext = editor.renderEditorCard(editor.buildEditorCardContext({
|
||||
...context,
|
||||
itemsPath: 'other.players',
|
||||
config: { ...context.config, items_path: 'data.players' }
|
||||
});
|
||||
}, {}, []));
|
||||
assert.match(explicitContext, /name="region_api_items_path_23"[^>]*value="other\.players"/);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user