mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
fix: serializing edited shadows (#5424)
* fix: serializing shadows * tests: add tests for serializing editted shadows
This commit is contained in:
committed by
alschmiedt
parent
410365f4a1
commit
448c433abe
@@ -257,7 +257,7 @@ const saveNextBlocks = function(block, state) {
|
||||
* shadow block, or any connected real block.
|
||||
*/
|
||||
const saveConnection = function(connection) {
|
||||
const shadow = connection.getShadowState();
|
||||
const shadow = connection.getShadowState(true);
|
||||
const child = connection.targetBlock();
|
||||
if (!shadow && !child) {
|
||||
return null;
|
||||
|
||||
@@ -431,6 +431,62 @@ suite('JSO Serialization', function() {
|
||||
};
|
||||
});
|
||||
|
||||
suite('Editing shadow value', function() {
|
||||
test('Not overwritten', function() {
|
||||
const block = this.workspace.newBlock('text_print');
|
||||
block.getInput('TEXT').connection.setShadowState({
|
||||
'type': 'text',
|
||||
'id': 'id'
|
||||
});
|
||||
block.getInputTargetBlock('TEXT').setFieldValue('new value', 'TEXT');
|
||||
const jso = Blockly.serialization.blocks.save(block);
|
||||
this.assertInput(
|
||||
jso,
|
||||
'TEXT',
|
||||
{
|
||||
'shadow': {
|
||||
'type': 'text',
|
||||
'id': 'id',
|
||||
'fields': {
|
||||
'TEXT': 'new value'
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('Overwritten', function() {
|
||||
const block = this.workspace.newBlock('text_print');
|
||||
block.getInput('TEXT').connection.setShadowState({
|
||||
'type': 'text',
|
||||
'id': 'id'
|
||||
});
|
||||
block.getInputTargetBlock('TEXT').setFieldValue('new value', 'TEXT');
|
||||
const childBlock = this.workspace.newBlock('text');
|
||||
block.getInput('TEXT').connection.connect(
|
||||
childBlock.outputConnection);
|
||||
const jso = Blockly.serialization.blocks.save(block);
|
||||
this.assertInput(
|
||||
jso,
|
||||
'TEXT',
|
||||
{
|
||||
'shadow': {
|
||||
'type': 'text',
|
||||
'id': 'id',
|
||||
'fields': {
|
||||
'TEXT': 'new value'
|
||||
}
|
||||
},
|
||||
'block': {
|
||||
'type': 'text',
|
||||
'id': 'id3',
|
||||
'fields': {
|
||||
'TEXT': ''
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('Value', function() {
|
||||
suite('With serialization', function() {
|
||||
test('Child', function() {
|
||||
|
||||
Reference in New Issue
Block a user