Skip to content

Commit 8a59b99

Browse files
authored
test(Mover): Add test for moving value blocks right/left (#710)
* fix(tests): Suppress tsc unintentional comparison error When PAUSE_TIME is set to a value other than 0 the comparison in sendKeyAndWait generates a TS unintentionl comparison error. * refactor(tests): Simplify moveTest Simplify moveTest (and the tests that use it) by assuming that the move always finishes in the same location it started in. We will leave testing various move end scenarios (e.g. healing) for a separate suite of move-finishing tests, akin to existing move start tests. * fix(tests): eslint-disable to ignore @ts-igonre * test(Mover): Introduce test blocks and suite for value move tests Introduce moveValueTestBlocks and a suite 'Value expression move tests' for each of two renderers (geras, zelos) to test constrained movement of value blocks. * test(Mover): Add value expression right/left move tests Moving value blocks left/right behaves as expected when using geras, but in zelos there is a bug where external inputs are not visited in the expected order (not that external inputs _look_ external when using geras, but still it is a possible configuration and should behave as expected). Note that two of these tests fail due to a bug; this will be dealt with in the next commit. * refactor(tests): Use text_join, nested suites Refactor the simple value expression move tests as follows: - Use text_join rather than text_count, as the former is a more plausible example of an value block with multiple external inputs. - Use common outer suite with nested suites for each of the different renderers, moving common constants to outer suite. * feat(tests): Add blocks for complex value block move tests * refactor(tests): Further organise with nested suites * test(Mover): Add value row (no free inputs) right/left tests * test(Mover): Add unary expression right/left tests * chore(tests): Skip failing zelos value block move tests due to #707. * chore(tests): Skip failing unary move right tests due to #709 * fix(tests): Remove debugging console.log * fix(tests): Ignore unhelpful lint error
1 parent 83b8b1b commit 8a59b99

File tree

4 files changed

+371
-91
lines changed

4 files changed

+371
-91
lines changed

test/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@
114114
<option value="moveStatementTestBlocks">
115115
move statement test blocks
116116
</option>
117+
<option value="moveValueTestBlocks">
118+
move value test blocks
119+
</option>
117120
<option value="comments">comments</option>
118121
</select>
119122
</div>

test/loadTestBlocks.js

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,171 @@ const moveStatementTestBlocks = {
974974
},
975975
};
976976

977+
const moveValueTestBlocks = {
978+
'blocks': {
979+
'languageVersion': 0,
980+
'blocks': [
981+
{
982+
'type': 'p5_setup',
983+
'id': 'p5_setup',
984+
'x': 75,
985+
'y': 75,
986+
'deletable': false,
987+
'inputs': {
988+
'STATEMENTS': {
989+
'block': {
990+
'type': 'p5_canvas',
991+
'id': 'p5_canvas',
992+
'deletable': false,
993+
'movable': false,
994+
'fields': {
995+
'WIDTH': 400,
996+
'HEIGHT': 400,
997+
},
998+
},
999+
},
1000+
},
1001+
},
1002+
{
1003+
'type': 'text',
1004+
'id': 'unattached',
1005+
'x': 75,
1006+
'y': 200,
1007+
'fields': {
1008+
'TEXT': 'unattached value',
1009+
},
1010+
},
1011+
{
1012+
'type': 'p5_draw',
1013+
'id': 'p5_draw',
1014+
'x': 75,
1015+
'y': 260,
1016+
'deletable': false,
1017+
'inputs': {
1018+
'STATEMENTS': {
1019+
'block': {
1020+
'type': 'text_print',
1021+
'id': 'print0',
1022+
'inputs': {
1023+
'TEXT': {
1024+
'block': {
1025+
'type': 'text_changeCase',
1026+
'id': 'complex_mover',
1027+
'fields': {
1028+
'CASE': 'TITLECASE',
1029+
},
1030+
'inputs': {
1031+
'TEXT': {
1032+
'block': {
1033+
'type': 'text',
1034+
'id': 'simple_mover',
1035+
'fields': {
1036+
'TEXT': 'simple mover',
1037+
},
1038+
},
1039+
},
1040+
},
1041+
},
1042+
},
1043+
},
1044+
'next': {
1045+
'block': {
1046+
'type': 'text_print',
1047+
'id': 'print1',
1048+
'next': {
1049+
'block': {
1050+
'type': 'text_print',
1051+
'id': 'print2',
1052+
'inputs': {
1053+
'TEXT': {
1054+
'shadow': {
1055+
'type': 'text',
1056+
'id': 'shadow_print2',
1057+
'fields': {
1058+
'TEXT': 'shadow',
1059+
},
1060+
},
1061+
},
1062+
},
1063+
'next': {
1064+
'block': {
1065+
'type': 'draw_emoji',
1066+
'id': 'draw_emoji',
1067+
'fields': {
1068+
'emoji': '🐻',
1069+
},
1070+
'next': {
1071+
'block': {
1072+
'type': 'text_print',
1073+
'id': 'print3',
1074+
'inputs': {
1075+
'TEXT': {
1076+
'block': {
1077+
'type': 'text_join',
1078+
'id': 'text_join1',
1079+
'inline': true,
1080+
'inputs': {
1081+
'ADD0': {
1082+
'shadow': {
1083+
'type': 'text',
1084+
'id': 'shadow_join',
1085+
'fields': {
1086+
'TEXT': 'inline',
1087+
},
1088+
},
1089+
},
1090+
},
1091+
},
1092+
},
1093+
},
1094+
'next': {
1095+
'block': {
1096+
'type': 'controls_repeat_ext',
1097+
'id': 'controls_repeat_ext',
1098+
'inputs': {
1099+
'TIMES': {
1100+
'shadow': {
1101+
'type': 'math_number',
1102+
'id': 'shadow_repeat',
1103+
'fields': {
1104+
'NUM': 1,
1105+
},
1106+
},
1107+
},
1108+
'DO': {
1109+
'block': {
1110+
'type': 'text_print',
1111+
'id': 'print4',
1112+
'inputs': {
1113+
'TEXT': {
1114+
'block': {
1115+
'type': 'text_join',
1116+
'id': 'text_join2',
1117+
'inline': false,
1118+
},
1119+
},
1120+
},
1121+
},
1122+
},
1123+
},
1124+
},
1125+
},
1126+
},
1127+
},
1128+
},
1129+
},
1130+
},
1131+
},
1132+
},
1133+
},
1134+
},
1135+
},
1136+
},
1137+
},
1138+
],
1139+
},
1140+
};
1141+
9771142
const comments = {
9781143
'workspaceComments': [
9791144
{
@@ -1101,6 +1266,7 @@ export const load = function (workspace, scenarioString) {
11011266
moreBlocks,
11021267
moveStartTestBlocks,
11031268
moveStatementTestBlocks,
1269+
moveValueTestBlocks,
11041270
navigationTestBlocks,
11051271
simpleCircle,
11061272
'sun': sunnyDay,

0 commit comments

Comments
 (0)