Skip to content

Commit 2bbd602

Browse files
committed
chore(tests): Improve value move tests checking vs. unconnected block
Use an unconnected (top-level) block with two empty value inputs, to allow us to better compare order of visiting inputs vs. outputs of top-level blocks.
1 parent 47b637e commit 2bbd602

File tree

2 files changed

+70
-78
lines changed

2 files changed

+70
-78
lines changed

test/loadTestBlocks.js

Lines changed: 59 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -983,101 +983,92 @@ const moveValueTestBlocks = {
983983
},
984984
},
985985
{
986-
'type': 'text',
987-
'id': 'unattached',
986+
'type': 'text_join',
987+
'id': 'join0',
988988
'x': 75,
989989
'y': 200,
990-
'fields': {
991-
'TEXT': 'unattached value',
992-
},
993990
},
994991
{
995992
'type': 'p5_draw',
996993
'id': 'p5_draw',
997994
'x': 75,
998-
'y': 260,
995+
'y': 300,
999996
'deletable': false,
1000997
'inputs': {
1001998
'STATEMENTS': {
1002999
'block': {
10031000
'type': 'text_print',
1004-
'id': 'print0',
1001+
'id': 'print1',
10051002
'next': {
10061003
'block': {
10071004
'type': 'text_print',
1008-
'id': 'print1',
1005+
'id': 'print2',
1006+
'inputs': {
1007+
'TEXT': {
1008+
'shadow': {
1009+
'type': 'text',
1010+
'id': 'shadow_print2',
1011+
'fields': {
1012+
'TEXT': 'shadow',
1013+
},
1014+
},
1015+
},
1016+
},
10091017
'next': {
10101018
'block': {
1011-
'type': 'text_print',
1012-
'id': 'print2',
1013-
'inputs': {
1014-
'TEXT': {
1015-
'shadow': {
1016-
'type': 'text',
1017-
'id': 'shadow_print2',
1018-
'fields': {
1019-
'TEXT': 'shadow',
1020-
},
1021-
},
1022-
},
1019+
'type': 'draw_emoji',
1020+
'id': 'draw_emoji',
1021+
'fields': {
1022+
'emoji': '🐻',
10231023
},
10241024
'next': {
10251025
'block': {
1026-
'type': 'draw_emoji',
1027-
'id': 'draw_emoji',
1028-
'fields': {
1029-
'emoji': '🐻',
1026+
'type': 'text_print',
1027+
'id': 'print3',
1028+
'inputs': {
1029+
'TEXT': {
1030+
'block': {
1031+
'type': 'text_join',
1032+
'id': 'join1',
1033+
'inline': true,
1034+
'inputs': {
1035+
'ADD0': {
1036+
'shadow': {
1037+
'type': 'text',
1038+
'id': 'shadow_join',
1039+
'fields': {
1040+
'TEXT': 'inline',
1041+
},
1042+
},
1043+
},
1044+
},
1045+
},
1046+
},
10301047
},
10311048
'next': {
10321049
'block': {
1033-
'type': 'text_print',
1034-
'id': 'print3',
1050+
'type': 'controls_repeat_ext',
1051+
'id': 'controls_repeat_ext',
10351052
'inputs': {
1036-
'TEXT': {
1037-
'block': {
1038-
'type': 'text_join',
1039-
'id': 'text_join1',
1040-
'inline': true,
1041-
'inputs': {
1042-
'ADD0': {
1043-
'shadow': {
1044-
'type': 'text',
1045-
'id': 'shadow_join',
1046-
'fields': {
1047-
'TEXT': 'inline',
1048-
},
1049-
},
1050-
},
1053+
'TIMES': {
1054+
'shadow': {
1055+
'type': 'math_number',
1056+
'id': 'shadow_repeat',
1057+
'fields': {
1058+
'NUM': 1,
10511059
},
10521060
},
10531061
},
1054-
},
1055-
'next': {
1056-
'block': {
1057-
'type': 'controls_repeat_ext',
1058-
'id': 'controls_repeat_ext',
1059-
'inputs': {
1060-
'TIMES': {
1061-
'shadow': {
1062-
'type': 'math_number',
1063-
'id': 'shadow_repeat',
1064-
'fields': {
1065-
'NUM': 1,
1066-
},
1067-
},
1068-
},
1069-
'DO': {
1070-
'block': {
1071-
'type': 'text_print',
1072-
'id': 'print4',
1073-
'inputs': {
1074-
'TEXT': {
1075-
'block': {
1076-
'type': 'text_join',
1077-
'id': 'text_join2',
1078-
'inline': false,
1079-
},
1080-
},
1062+
'DO': {
1063+
'block': {
1064+
'type': 'text_print',
1065+
'id': 'print4',
1066+
'inputs': {
1067+
'TEXT': {
1068+
'block': {
1069+
'type': 'text_join',
1070+
'id': 'join2',
1071+
'inline': false,
10811072
},
10821073
},
10831074
},

test/webdriverio/test/move_test.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -357,18 +357,19 @@ suite(`Value expression move tests`, function () {
357357
* pressing ArrowRight n times.
358358
*/
359359
const EXPECTED_SIMPLE_RIGHT = [
360-
{id: 'print0', index: 2, ownIndex: 0}, // Print block; starting location.
360+
{id: 'join0', index: 1, ownIndex: 0}, // Join block ADD0 input.
361+
{id: 'join0', index: 2, ownIndex: 0}, // Join block ADD1 input.
361362
{id: 'print1', index: 2, ownIndex: 0}, // Print block with no shadow.
362363
{id: 'print2', index: 2, ownIndex: 0}, // Print block with shadow.
363364
// Skip draw_emoji block as it has no value inputs.
364365
{id: 'print3', index: 2, ownIndex: 0}, // Replacing join expression.
365-
{id: 'text_join1', index: 1, ownIndex: 0}, // Join block ADD0 input.
366-
{id: 'text_join1', index: 2, ownIndex: 0}, // Join block ADD1 input.
366+
{id: 'join1', index: 1, ownIndex: 0}, // Join block ADD0 input.
367+
{id: 'join1', index: 2, ownIndex: 0}, // Join block ADD1 input.
367368
// Skip controls_repeat_ext block's TIMES input as it is incompatible.
368369
{id: 'print4', index: 2, ownIndex: 0}, // Replacing join expression.
369-
{id: 'text_join2', index: 1, ownIndex: 0}, // Join block ADD0 input.
370-
{id: 'text_join2', index: 2, ownIndex: 0}, // Join block ADD1 input.
371-
// Skip unconnected text block as it has no inputs.
370+
{id: 'join2', index: 1, ownIndex: 0}, // Join block ADD0 input.
371+
{id: 'join2', index: 2, ownIndex: 0}, // Join block ADD1 input.
372+
// Skip input of unattached join block.
372373
];
373374
/**
374375
* Expected connection candidates when moving BLOCK_SIMPLE, after
@@ -404,7 +405,7 @@ suite(`Value expression move tests`, function () {
404405
* pressing ArrowRight n times.
405406
*/
406407
const EXPECTED_UNARY_RIGHT = EXPECTED_SIMPLE_RIGHT.concat([
407-
{id: 'unattached', index: 0, ownIndex: 1}, // Unattached text to own input.
408+
{id: 'join0', index: 0, ownIndex: 1}, // Unattached block to own input.
408409
]);
409410
/**
410411
* Expected connection candidates when moving row consisting of
@@ -431,7 +432,7 @@ suite(`Value expression move tests`, function () {
431432

432433
suite('Constrained moves of a simple reporter block', function () {
433434
setup(async function () {
434-
await appendBlock(this.browser, VALUE_SIMPLE, 'print0', 'TEXT');
435+
await appendBlock(this.browser, VALUE_SIMPLE, 'join0', 'ADD0');
435436
});
436437
test(
437438
'moving right',
@@ -445,7 +446,7 @@ suite(`Value expression move tests`, function () {
445446

446447
suite('Constrained moves of row of value blocks', function () {
447448
setup(async function () {
448-
await appendBlock(this.browser, VALUE_ROW, 'print0', 'TEXT');
449+
await appendBlock(this.browser, VALUE_ROW, 'join0', 'ADD0');
449450
});
450451
test(
451452
'moving right',
@@ -459,7 +460,7 @@ suite(`Value expression move tests`, function () {
459460

460461
suite('Constrained moves of unary expression block', function () {
461462
setup(async function () {
462-
await appendBlock(this.browser, VALUE_UNARY, 'print0', 'TEXT');
463+
await appendBlock(this.browser, VALUE_UNARY, 'join0', 'ADD0');
463464
});
464465
// TODO(#709): Reenable test once crash bug is fixed.
465466
test.skip(

0 commit comments

Comments
 (0)