refactor!: Use JSON instead of XML for defining dynamic toolbox categories. (#8658)

* refactor!: Use JSON instead of XML for defining dynamic toolbox categories.

* chore: Fix tests.

* chore: Remove unused import.

* chore: Update docstrings.

* chore: Revert removal of XML-based category functions.

* chore: Add deprecation notices.
This commit is contained in:
Aaron Dodson
2025-01-08 11:50:18 -08:00
committed by GitHub
parent 4dcffa0914
commit 80a6d85c26
6 changed files with 362 additions and 83 deletions

View File

@@ -531,28 +531,6 @@ suite('XML', function () {
teardown(function () {
workspaceTeardown.call(this, this.workspace);
});
suite('Dynamic Category Blocks', function () {
test('Untyped Variables', function () {
this.workspace.createVariable('name1', '', 'id1');
const blocksArray = Blockly.Variables.flyoutCategoryBlocks(
this.workspace,
);
for (let i = 0, xml; (xml = blocksArray[i]); i++) {
Blockly.Xml.domToBlock(xml, this.workspace);
}
});
test('Typed Variables', function () {
this.workspace.createVariable('name1', 'String', 'id1');
this.workspace.createVariable('name2', 'Number', 'id2');
this.workspace.createVariable('name3', 'Colour', 'id3');
const blocksArray = Blockly.VariablesDynamic.flyoutCategoryBlocks(
this.workspace,
);
for (let i = 0, xml; (xml = blocksArray[i]); i++) {
Blockly.Xml.domToBlock(xml, this.workspace);
}
});
});
suite('Comments', function () {
suite('Headless', function () {
test('Text', function () {
@@ -910,42 +888,4 @@ suite('XML', function () {
});
});
});
suite('generateVariableFieldDom', function () {
test('Case Sensitive', function () {
const varId = 'testId';
const type = 'testType';
const name = 'testName';
const mockVariableModel = {
type: type,
name: name,
getId: function () {
return varId;
},
getName: function () {
return name;
},
getType: function () {
return type;
},
};
const generatedXml = Blockly.Xml.domToText(
Blockly.Variables.generateVariableFieldDom(mockVariableModel),
);
const expectedXml =
'<field xmlns="https://developers.google.com/blockly/xml"' +
' name="VAR"' +
' id="' +
varId +
'"' +
' variabletype="' +
type +
'"' +
'>' +
name +
'</field>';
assert.equal(generatedXml, expectedXml);
});
});
});